/* ================================================= */
/* ==       OFFLINE FONT DEFINITIONS (LOCAL)      == */
/* ================================================= */

/* --- Poppins --- */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 500; /* Medium */
  src: url('../fonts/Poppins-Medium.ttf') format('truetype');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700; /* Bold */
  src: url('../fonts/Poppins-Bold.ttf') format('truetype');
}

/* --- Roboto --- */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400; /* Regular */
  src: url('../fonts/Roboto-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500; /* Medium */
  src: url('../fonts/Roboto-Medium.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700; /* Bold */
  src: url('../fonts/Roboto-Bold.ttf') format('truetype');
}
/* ================================================= */
/* ==   DEFINITIVE RESPONSIVE STYLES FOR SHIV RMS   == */
/* ================================================= */

:root {
    /* Custom Colors for Modern Look */
    --bs-primary: #0d6efd;
    --bs-primary-dark: #0b5dd7;
    --bs-secondary: #6c757d;
    --bs-light-gray: #f2f4f6;
    --bs-card-bg: #ffffff;
    --bs-sidebar-bg: #2b3035;
    --bs-sidebar-hover: #3d434a;
    --bs-sidebar-active: #0d6efd;
    --bs-success-light: #d4edda;
}

body {
    font-family: 'Roboto', sans-serif;
    font-size: .875rem;
    background-color: var(--bs-light-gray); /* Lighter overall background */
}

/* --- Top Navbar --- */
.bg-primary-dark {
    background-color: var(--bs-primary-dark) !important;
}

.navbar-brand {
    font-family: 'Poppins', sans-serif;
    padding-top: .75rem;
    padding-bottom: .75rem;
    background-color: var(--bs-primary-dark);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}
.navbar .navbar-toggler {
    top: .25rem;
    right: 1rem;
}

/* --- Sidebar Styling --- */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: 1px 0 5px rgba(0, 0, 0, 0.1);
    background-color: var(--bs-sidebar-bg); /* Darker, modern background */
}
@media (max-width: 767.98px) {
    .sidebar {
        padding-top: 0;
        top: 56px;
    }
}

.sidebar .position-sticky {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    overflow-y: auto;
}

/* --- CUSTOM BRANDING HEADER (Modernized Colors) --- */
.sidebar-header {
    background-color: #383d42; /* Slightly contrasting color */
    padding: 20px 15px;
    text-align: center;
    border-bottom: 1px solid var(--bs-sidebar-hover);
}
.sidebar-header .logo {
    width: 70px; /* Slightly smaller logo */
    height: 70px;
    margin-bottom: 10px;
    object-fit: contain;
    background-color: #ffffff;
    border-radius: 50%;
    padding: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.sidebar-header h4 {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    color: #f8f9fa;
    line-height: 1.2;
    margin-bottom: 0;
}
.sidebar-header h4 span {
    display: block;
    font-size: 1.5rem; /* Slightly reduced font size for cleaner look */
    font-weight: 700;
    color: #4dc2ff; /* Lighter blue for contrast */
    line-height: 1.1;
    margin-top: 5px;
}

/* --- Sidebar Navigation Links --- */
.sidebar-nav {
    flex-grow: 1;
    list-style: none;
    padding: 15px 0;
    margin: 0;
}
.sidebar-nav .nav-link {
    font-weight: 500;
    color: #adb5bd;
    padding: 12px 16px; /* Increased padding */
    display: flex;
    align-items: center;
    transition: background-color 0.15s, color 0.15s;
}
.sidebar-nav .nav-link:hover {
    color: #fff;
    background-color: var(--bs-sidebar-hover);
}
.sidebar-nav .nav-link.active {
    color: #fff;
    background-color: var(--bs-sidebar-active);
    border-left: 4px solid #fff; /* Highlight active link */
    padding-left: 12px;
}
.sidebar-nav .nav-link .icon {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}
.sidebar-nav hr {
    border-color: #444 !important;
    margin: 1rem 0;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #444;
}

/* --- Main Content Area --- */
main {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 48px);
}
.footer-main {
    padding: 15px 20px;
    background-color: var(--bs-light-gray);
    border-top: 1px solid #dee2e6;
    text-align: center;
    margin-top: auto;
    font-size: 0.8rem;
}

/* --- General Card & Button Styling (Modernizing the look) --- */
.card {
    border: none;
    border-radius: 12px; /* Smoother corners */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); /* Subtle depth */
}
.card-header {
    background-color: var(--bs-card-bg);
    border-bottom: 1px solid var(--bs-light-gray);
    border-radius: 12px 12px 0 0 !important;
    font-weight: 500;
    color: #343a40;
}
.btn-primary {
    /* Match Bootstrap's primary color */
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    font-weight: 500;
}

/* --- Dashboard Status Cards (New Visual Style) --- */
.status-card {
    position: relative;
    overflow: hidden;
    color: #fff !important;
    border-radius: 12px;
    transition: transform 0.2s;
    background: linear-gradient(135deg, var(--color-light), var(--color-dark));
}
.status-card-link {
    text-decoration: none;
    display: block;
}
.status-card-link:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    border-radius: 12px;
}
.status-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}
.status-card .card-body {
    position: relative;
    z-index: 2;
    padding: 1rem;
}
.status-card .card-title {
    font-size: 1.8rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    line-height: 1;
}
.status-card .card-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 500;
}
/* Color Schemes for Status Cards */
.status-card.arrived {
    --color-light: #6c757d;
    --color-dark: #5a6268;
}
.status-card.diagnostics {
    --color-light: #17a2b8;
    --color-dark: #138496;
}
.status-card.at-service {
    --color-light: #ffc107;
    --color-dark: #e0a800;
}
.status-card.awaiting-parts {
    --color-light: #dc3545;
    --color-dark: #c82333;
}
.status-card.completed {
    --color-light: #28a745;
    --color-dark: #1e7e34;
}
.status-card.total-active {
    --color-light: #343a40;
    --color-dark: #23272b;
}

/* Ticket status badges — each stage has a unique color (no overlap) */
.rms-status-badge {
    font-weight: 600;
    letter-spacing: 0.01em;
}
.rms-status-partial { background-color: #f59e0b; color: #1a1a1a; }
.rms-status-all-returned { background-color: #0b5ed7; color: #fff; }
.rms-status-handed-over { background-color: #157347; color: #fff; }
.rms-status-arrived { background-color: #495057; color: #fff; }
.rms-status-diagnostics { background-color: #0aa2c0; color: #fff; }
.rms-status-at-service { background-color: #6f42c1; color: #fff; }
.rms-status-awaiting { background-color: #6c757d; color: #fff; }
.rms-status-repaired-iw { background-color: #20c997; color: #1a1a1a; }
.rms-status-repaired-oow { background-color: #e8590c; color: #fff; }
.rms-status-not-repaired { background-color: #bb2d3b; color: #fff; }
.rms-status-default { background-color: #adb5bd; color: #1a1a1a; }
.rms-product-received { background-color: #20c997; color: #1a1a1a; }
.rms-product-at-sc { background-color: #6f42c1; color: #fff; }

/* --- Master Ledger Report --- */
.rms-ledger-page .rms-ledger-filter-card {
    border-radius: 12px;
}
.rms-ledger-kpi {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bs-card-bg);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.15s ease;
}
.rms-ledger-kpi:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.rms-ledger-kpi-highlight {
    border-color: rgba(220, 53, 69, 0.25);
    background: linear-gradient(135deg, #fff 0%, #fff5f5 100%);
}
.rms-ledger-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.rms-ledger-kpi-label {
    margin: 0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary);
    font-weight: 600;
}
.rms-ledger-kpi-value {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    color: #212529;
}
.rms-ledger-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    border-bottom-width: 1px;
    white-space: nowrap;
}
.rms-ledger-table tbody tr.rms-ledger-row td {
    vertical-align: middle;
    border-bottom-color: #eef1f4;
}
.rms-ledger-detail-row > td {
    border-top: none !important;
}
.rms-ledger-timeline li {
    position: relative;
    padding-left: 1.25rem;
    padding-bottom: 0.75rem;
    border-left: 2px solid #dee2e6;
    margin-left: 0.35rem;
}
.rms-ledger-timeline li:last-child {
    padding-bottom: 0;
    border-left-color: transparent;
}
.rms-ledger-timeline-dot {
    position: absolute;
    left: -0.45rem;
    top: 0.2rem;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--bs-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #dee2e6;
}
.rms-ledger-empty {
    border-radius: 12px;
    background: linear-gradient(180deg, #fff 0%, #f8f9fb 100%);
}
@media (max-width: 767.98px) {
    .rms-ledger-kpi-value {
        font-size: 0.95rem;
    }
    .rms-ledger-search {
        max-width: 100% !important;
        width: 100%;
    }
}

/* --- Financial Stats Report --- */
.rms-stats-filter-card {
    border-radius: 12px;
    overflow: hidden;
}
.rms-stats-tabs .nav-link {
    border: none;
    color: var(--bs-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
}
.rms-stats-tabs .nav-link.active {
    color: var(--bs-primary);
    background: transparent;
    border-bottom: 2px solid var(--bs-primary);
}
.rms-stats-chart-wrap {
    position: relative;
    height: 320px;
}
.rms-stats-chart-wrap-sm {
    height: 320px;
}
.rms-stats-table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    white-space: nowrap;
}
.rms-stats-table tbody td {
    border-bottom-color: #eef1f4;
}
.rms-stats-empty {
    border-radius: 12px;
    background: linear-gradient(180deg, #fff 0%, #f8f9fb 100%);
}
.rms-stats-note {
    border-radius: 12px;
}
@media (max-width: 991.98px) {
    .rms-stats-chart-wrap,
    .rms-stats-chart-wrap-sm {
        height: 260px;
    }
}

/* --- Ticket List: Mobile View Overhaul --- */
/* The base table view remains the same for desktop (md and up) */
@media (max-width: 767.98px) {
    
    /* Hide the standard table headers */
    .table-responsive.d-none { display: none !important; }
    .table-responsive.d-none.d-md-block { display: none !important; }
    
    /* Ensure the mobile ticket list view is visible (scoped — do NOT target all .d-md-none) */
    .ticket-list-mobile.d-md-none { display: block !important; }
    
    .ticket-list-mobile {
        padding: 0;
    }
    .ticket-item-mobile {
        background-color: var(--bs-card-bg);
        border: 1px solid #ddd;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        margin-bottom: 15px;
        padding: 15px;
    }
    .ticket-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px dashed #eee;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }
    .ticket-details-mobile p {
        margin-bottom: 4px;
        font-size: 0.85rem;
    }
    .ticket-details-mobile strong {
        font-weight: 500;
    }
    .ticket-details-mobile .label {
        color: #6c757d;
        display: inline-block;
        min-width: 80px;
        font-weight: 400;
    }
}

/* ================================================= */
/* ==   MOBILE APP SHELL + MODERN UI ENHANCEMENTS  == */
/* ================================================= */

/* --- Mobile bottom navigation bar --- */
.rms-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-around;
    align-items: stretch;
    width: 100%;
    background: #ffffff;
    border-top: 1px solid #e3e7eb;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.rms-bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px 6px;
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 0.68rem;
    font-weight: 500;
    text-decoration: none;
    min-height: 56px;
    transition: color 0.15s ease;
    white-space: nowrap;
}
.rms-bottom-nav-item i {
    font-size: 1.25rem;
    line-height: 1;
}
.rms-bottom-nav-item.active,
.rms-bottom-nav-item:active {
    color: var(--bs-primary);
}
.rms-bottom-nav-item:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: -2px;
    border-radius: 8px;
}

/* --- Mobile app dashboard branding (phone / installed PWA only) --- */
.rms-app-dashboard-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px 16px 10px;
    margin-bottom: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    border: 1px solid #e3e7eb;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.rms-app-brand-logo {
    display: block;
    max-height: 56px;
    max-width: min(300px, 88vw);
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Keep page content clear of the fixed bottom nav on small screens. */
@media (max-width: 767.98px) {
    body {
        padding-bottom: 64px;
    }
    /* Larger tap targets and comfortable inputs on touch devices. */
    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
        font-size: 0.95rem;
    }
    .input-group .btn {
        min-height: 44px;
    }
    .card-body {
        padding: 1rem;
    }
    /* Full-width primary actions feel more app-like on phones. */
    .btn-lg {
        width: 100%;
    }
}

/* --- Modern polish (applies everywhere, safe on desktop) --- */
.btn {
    border-radius: 9px;
    transition: transform 0.08s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.btn:active {
    transform: translateY(1px);
}
.btn-primary {
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.25);
}
.form-control,
.form-select {
    border-radius: 9px;
    border-color: #d9dee3;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}
.input-group > .btn {
    border-top-right-radius: 9px;
    border-bottom-right-radius: 9px;
}

/* --- Camera / scan trigger buttons --- */
.rms-scan-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Camera + contact buttons are only meaningful on capable devices; JS reveals them. */
.rms-mobile-only {
    display: none;
}
body.rms-can-scan .rms-scan-btn.rms-mobile-only {
    display: inline-flex;
}
body.rms-can-contacts .rms-contacts-btn.rms-mobile-only {
    display: inline-flex;
}

/* --- Barcode scanner modal --- */
.rms-scanner-reader {
    width: 100%;
    min-height: 260px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}
.rms-scanner-reader video {
    width: 100% !important;
    border-radius: 10px;
    object-fit: cover;
}
.rms-scanner-hint {
    font-size: 0.85rem;
    color: #6c757d;
}
.rms-scanner-status {
    font-size: 0.85rem;
}
.rms-scanner-privacy strong {
    font-weight: 600;
}
.rms-scanner-picker {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 10px;
    background: #f8f9fb;
    max-height: 220px;
    overflow-y: auto;
}
.rms-scanner-picker-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}
.rms-scanner-pick-btn {
    text-align: left;
}
.rms-scanner-pick-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

/* --- Generic "table becomes cards" helper for opt-in tables on mobile --- */
@media (max-width: 575.98px) {
    table.rms-cards-mobile thead {
        display: none;
    }
    table.rms-cards-mobile,
    table.rms-cards-mobile tbody,
    table.rms-cards-mobile tr,
    table.rms-cards-mobile td {
        display: block;
        width: 100%;
    }
    table.rms-cards-mobile tr {
        background: #fff;
        border: 1px solid #e3e7eb;
        border-radius: 10px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        margin-bottom: 12px;
        padding: 6px 12px;
    }
    table.rms-cards-mobile td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
        border: none;
        border-bottom: 1px dashed #eef1f4;
        padding: 8px 0;
    }
    table.rms-cards-mobile td:last-child {
        border-bottom: none;
    }
    table.rms-cards-mobile td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        text-align: left;
        flex: 0 0 45%;
    }
}