/* =====================================================
   MitraServices VTS — Modern Admin CSS
   ===================================================== */

/* ---- CSS Variables ---- */
:root {
    --sidebar-w: 260px;
    --topbar-h: 60px;

    --primary:       #4f46e5;
    --primary-light: #ede9fe;
    --primary-dark:  #3730a3;

    --bg:            #f1f5f9;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --border:        #e2e8f0;

    --text:          #0f172a;
    --text-muted:    #64748b;

    --sidebar-bg:    #0f172a;
    --sidebar-text:  #94a3b8;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active-bg: rgba(79,70,229,.18);
    --sidebar-active-text: #a5b4fc;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.12);

    --radius:    .75rem;
    --radius-sm: .5rem;
}

[data-theme="dark"] {
    --bg:           #0b1120;
    --surface:      #131d2e;
    --surface-2:    #1a2540;
    --border:       #1e2d45;
    --text:         #e2e8f0;
    --text-muted:   #94a3b8;
    --sidebar-bg:   #08101c;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
    --shadow-md:    0 4px 16px rgba(0,0,0,.4);
}

*,*::before,*::after{box-sizing:border-box}
body{margin:0;font-family:'Inter',system-ui,-apple-system,sans-serif;font-size:.9rem;background:var(--bg);color:var(--text);overflow-x:hidden}

/* =====================================================  SIDEBAR  */
.ms-sidebar{position:fixed;top:0;left:0;bottom:0;width:var(--sidebar-w);background:var(--sidebar-bg);display:flex;flex-direction:column;z-index:1040;transition:transform .25s ease,width .25s ease;overflow-y:auto;overflow-x:hidden}
.ms-sidebar-brand{display:flex;align-items:center;gap:.75rem;padding:1.25rem 1.25rem 1rem;border-bottom:1px solid rgba(255,255,255,.07);flex-shrink:0}
.ms-brand-icon{width:36px;height:36px;background:var(--primary);border-radius:.6rem;display:flex;align-items:center;justify-content:center;color:#fff;flex-shrink:0}
.ms-brand-text{font-size:.95rem;font-weight:700;color:#fff;letter-spacing:-.01em;white-space:nowrap}
.ms-sidebar-close{margin-left:auto;background:none;border:none;color:var(--sidebar-text);cursor:pointer;padding:4px;line-height:1}
.ms-sidebar-section-label{font-size:.7rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--sidebar-text);padding:1.1rem 1.25rem .4rem;opacity:.7}
.ms-sidebar-nav{padding:0 .75rem;display:flex;flex-direction:column;gap:2px}
.ms-nav-item{display:flex;align-items:center;gap:.75rem;padding:.6rem .75rem;border-radius:var(--radius-sm);color:var(--sidebar-text);text-decoration:none;font-weight:500;font-size:.875rem;transition:background .15s,color .15s;cursor:pointer}
.ms-nav-item:hover{background:var(--sidebar-hover);color:#e2e8f0}
.ms-nav-item.active{background:var(--sidebar-active-bg);color:var(--sidebar-active-text)}
.ms-nav-item.active .ms-nav-icon{color:#818cf8}
.ms-nav-icon{width:20px;height:20px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.ms-nav-label{white-space:nowrap}
.ms-sidebar-footer{margin-top:auto;padding:1rem .75rem;border-top:1px solid rgba(255,255,255,.07);flex-shrink:0}
.ms-user-pill{display:flex;align-items:center;gap:.75rem;padding:.5rem .6rem;border-radius:var(--radius-sm);background:rgba(255,255,255,.04)}
.ms-user-avatar{width:34px;height:34px;border-radius:50%;background:var(--primary);color:#fff;font-size:.8rem;font-weight:700;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.ms-user-name{font-size:.82rem;font-weight:600;color:#e2e8f0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ms-user-role{font-size:.72rem;color:var(--sidebar-text)}
.ms-sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:1039;opacity:0;transition:opacity .25s}
.ms-sidebar-overlay.show{display:block;opacity:1}

/* =====================================================  MAIN  */
.ms-main-wrapper{margin-left:var(--sidebar-w);min-height:100vh;display:flex;flex-direction:column;transition:margin-left .25s ease}

/* =====================================================  TOPBAR  */
.ms-topbar{height:var(--topbar-h);background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 1.5rem;position:sticky;top:0;z-index:100;box-shadow:var(--shadow-sm)}
.ms-topbar-left{display:flex;align-items:center;gap:1rem}
.ms-topbar-toggle{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:6px;border-radius:.4rem;display:flex;align-items:center;transition:background .15s,color .15s}
.ms-topbar-toggle:hover{background:var(--border);color:var(--text)}
.auth-card-body h4{color:var(--text);font-weight:700;font-size:2rem;letter-spacing:-.02em}
.auth-card-body .text-muted{color:var(--text-muted) !important}
.auth-card-body .form-label{color:var(--text-muted);font-weight:600}
.auth-card-body .form-check-label{color:var(--text)}
.auth-card-body .form-control{height:44px}
.auth-card-body a{color:#2563eb;font-weight:500;text-decoration:none}
.auth-card-body a:hover{text-decoration:underline}

.auth-card-body input:-webkit-autofill,
.auth-card-body input:-webkit-autofill:hover,
.auth-card-body input:-webkit-autofill:focus,
.auth-card-body input:-webkit-autofill:active{
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 5000s ease-in-out 0s;
}
.ms-breadcrumb{display:flex;align-items:center;gap:.4rem;font-size:.82rem;color:var(--text-muted)}
.ms-breadcrumb-root{color:var(--text-muted)}
.ms-breadcrumb-current{color:var(--text);font-weight:600}
[data-theme="dark"] .auth-card{border:1px solid rgba(148,163,184,.2);box-shadow:0 18px 55px rgba(2,8,23,.65)}
[data-theme="dark"] .auth-card-body{background:linear-gradient(180deg,#0f172a 0%,#0b1324 100%)}
[data-theme="dark"] .auth-card-body h4{color:#dbe7ff}
[data-theme="dark"] .auth-card-body .text-muted{color:#94a3b8 !important}
[data-theme="dark"] .auth-card-body .form-label{color:#8ea3c0}
[data-theme="dark"] .auth-card-body .form-control{background:#0d1a31;border-color:#2e3e66;color:#e5efff}
[data-theme="dark"] .auth-card-body .form-control:focus{border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,.24)}
[data-theme="dark"] .auth-card-body .form-check-input{background-color:#10203d;border-color:#334a75}
[data-theme="dark"] .auth-card-body .form-check-input:checked{background-color:#4f46e5;border-color:#4f46e5}
[data-theme="dark"] .auth-card-body a{color:#7dd3fc}
[data-theme="dark"] .auth-card-body .btn-primary{background:linear-gradient(90deg,#4f46e5,#4338ca);border-color:#4f46e5}
[data-theme="dark"] .auth-card-body .btn-primary:hover{background:linear-gradient(90deg,#6366f1,#4f46e5)}

.ms-topbar-right{display:flex;align-items:center;gap:.75rem}
.ms-icon-btn{background:none;border:1px solid var(--border);color:var(--text-muted);width:36px;height:36px;border-radius:.5rem;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background .15s,color .15s}
.ms-icon-btn:hover{background:var(--border);color:var(--text)}
.ms-user-topbar{display:flex;align-items:center;gap:.5rem;background:none;border:1px solid var(--border);border-radius:.5rem;padding:.3rem .75rem .3rem .4rem;color:var(--text);font-size:.84rem;font-weight:500;cursor:pointer;transition:background .15s}
.ms-user-topbar:hover{background:var(--border)}
.ms-user-avatar-sm{width:28px;height:28px;border-radius:50%;background:var(--primary);color:#fff;font-size:.72rem;font-weight:700;display:flex;align-items:center;justify-content:center}

/* =====================================================  CONTENT  */
.ms-content{flex:1;padding:1.75rem}
.ms-page-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1.5rem;flex-wrap:wrap}
.ms-page-title{font-size:1.35rem;font-weight:700;color:var(--text);margin:0 0 .2rem}
.ms-page-subtitle{font-size:.82rem;color:var(--text-muted);margin:0}

/* =====================================================  STAT CARDS  */
.ms-stat-card{background:var(--surface);border-radius:var(--radius);padding:1.4rem 1.5rem;box-shadow:var(--shadow-sm);border:1px solid var(--border);display:flex;align-items:center;gap:1.25rem;transition:box-shadow .2s,transform .2s;position:relative;overflow:hidden}
.ms-stat-card:hover{box-shadow:var(--shadow-md);transform:translateY(-2px)}
.ms-stat-card::before{content:'';position:absolute;top:0;left:0;right:0;height:3px;background:var(--stat-color,var(--primary));border-radius:var(--radius) var(--radius) 0 0}
.ms-stat-icon{width:52px;height:52px;border-radius:.8rem;background:var(--stat-color-light,var(--primary-light));color:var(--stat-color,var(--primary));display:flex;align-items:center;justify-content:center;flex-shrink:0}
.ms-stat-value{font-size:1.8rem;font-weight:800;line-height:1;color:var(--text);margin-bottom:.2rem}
.ms-stat-label{font-size:.78rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--text-muted)}
.stat-indigo{--stat-color:#4f46e5;--stat-color-light:#ede9fe}
.stat-emerald{--stat-color:#10b981;--stat-color-light:#d1fae5}
.stat-amber{--stat-color:#f59e0b;--stat-color-light:#fef3c7}
.stat-rose{--stat-color:#f43f5e;--stat-color-light:#ffe4e6}
.stat-sky{--stat-color:#0ea5e9;--stat-color-light:#e0f2fe}

/* =====================================================  CARDS  */
.ms-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-sm)}
.ms-card-header{padding:1rem 1.25rem;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:.75rem;flex-wrap:wrap}
.ms-card-title{font-size:.95rem;font-weight:700;color:var(--text);margin:0}
.ms-card-body{padding:1.25rem}

/* =====================================================  BS OVERRIDES  */
.card{background:var(--surface);border:1px solid var(--border);color:var(--text)}
.card-header,.card-footer{background:var(--surface-2);border-color:var(--border);color:var(--text)}
.table{color:var(--text);border-color:var(--border);--bs-table-color:var(--text);--bs-table-bg:var(--surface);--bs-table-striped-color:var(--text);--bs-table-striped-bg:var(--surface-2);--bs-table-hover-color:var(--text);--bs-table-hover-bg:rgba(79,70,229,.05)}
.table thead th{font-size:.75rem;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-muted);background:var(--surface-2);border-bottom:2px solid var(--border)}
.table > :not(caption) > * > *{color:var(--text);border-color:var(--border)}
.modal-content{background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-lg)}
.modal-header,.modal-footer{border-color:var(--border)}
.form-control,.form-select{background:var(--surface);border-color:var(--border);color:var(--text);border-radius:var(--radius-sm);font-size:.875rem}
.form-control:focus,.form-select:focus{background:var(--surface);color:var(--text);border-color:var(--primary);box-shadow:0 0 0 3px rgba(79,70,229,.15)}
.form-label{font-size:.8rem;font-weight:600;color:var(--text-muted);margin-bottom:.4rem}
.btn{font-size:.84rem;font-weight:600;border-radius:var(--radius-sm);padding:.45rem 1rem;transition:all .15s}
.btn-primary{background:var(--primary);border-color:var(--primary)}
.btn-primary:hover{background:var(--primary-dark);border-color:var(--primary-dark)}
.btn-playback{display:inline-flex;align-items:center;gap:.4rem;background:#2563eb;border-color:#2563eb;color:#fff}
.btn-playback:hover{background:#1d4ed8;border-color:#1d4ed8;color:#fff}
[data-theme="dark"] .btn-playback{background:#3b82f6;border-color:#3b82f6;color:#fff}
[data-theme="dark"] .btn-playback:hover{background:#60a5fa;border-color:#60a5fa;color:#0b1120}
.btn-report{display:inline-flex;align-items:center;gap:.4rem;background:#0f766e;border-color:#0f766e;color:#fff}
.btn-report:hover{background:#0d9488;border-color:#0d9488;color:#fff}
[data-theme="dark"] .btn-report{background:#14b8a6;border-color:#14b8a6;color:#062b27}
[data-theme="dark"] .btn-report:hover{background:#2dd4bf;border-color:#2dd4bf;color:#042f2e}
.btn-report-icon{display:inline-flex;align-items:center;justify-content:center;width:44px;min-width:44px;height:38px;padding:0;background:var(--surface-2);border:1px solid var(--border);color:var(--text-muted)}
.btn-report-icon:hover{background:#0f766e;border-color:#0f766e;color:#fff}
[data-theme="dark"] .btn-report-icon{background:#162235;border-color:#223451;color:#93a4be}
[data-theme="dark"] .btn-report-icon:hover{background:#14b8a6;border-color:#14b8a6;color:#062b27}
.playback-filter-actions{display:flex;align-items:center;gap:.75rem;width:100%}
.playback-filter-actions .btn{height:38px}
.playback-filter-actions #loadPlayback{flex:0 0 auto;min-width:112px;justify-content:center}
.playback-filter-actions #reportPlayback{flex:0 0 auto;min-width:126px;justify-content:center}
@media(max-width:1199.98px){
    .playback-filter-actions{justify-content:flex-start}
}
.dropdown-menu{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);color:var(--text);font-size:.84rem;min-width:180px}
.dropdown-item{color:var(--text);padding:.5rem .9rem;border-radius:.3rem;display:flex;align-items:center}
.dropdown-item:hover{background:var(--surface-2);color:var(--text)}
.dropdown-divider{border-color:var(--border)}
.badge{font-weight:600;font-size:.72rem;border-radius:.4rem}

/* Select2 */
.select2-container .select2-selection--single{height:38px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm)}
.select2-container .select2-selection--single .select2-selection__rendered{color:var(--text);padding-top:5px;padding-left:10px}
.select2-container .select2-selection--single .select2-selection__arrow{top:6px}
.select2-dropdown{background:var(--surface);border-color:var(--border);color:var(--text)}
.select2-results__option--highlighted{background:var(--primary) !important}

/* DataTables */
.dataTables_wrapper .dataTables_filter input,.dataTables_wrapper .dataTables_length select{background:var(--surface);border:1px solid var(--border);color:var(--text);border-radius:var(--radius-sm);padding:.3rem .6rem;font-size:.84rem}
.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_paginate .paginate_button{font-size:.82rem;color:var(--text-muted) !important}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover{background:var(--primary) !important;border-color:var(--primary) !important;color:#fff !important;border-radius:.4rem}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover{background:var(--border) !important;border-color:var(--border) !important;color:var(--text) !important;border-radius:.4rem}
#map{min-height:500px;border-radius:var(--radius);border:1px solid var(--border)}
.stop-label-tooltip{background:transparent;border:0;box-shadow:none;color:#fff;font-size:.72rem;font-weight:700;margin-top:-1px}
.stop-label-tooltip::before{display:none}
.stop-balloon-marker{background:transparent;border:0}
.stop-balloon-pin{position:relative;display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:50% 50% 50% 0;background:#dc2626;border:2px solid #fff;box-shadow:0 8px 18px rgba(15,23,42,.28);transform:rotate(-45deg)}
.stop-balloon-pin::after{content:'';position:absolute;inset:5px;border-radius:50%;background:rgba(255,255,255,.12)}
.stop-balloon-pin span{position:relative;z-index:1;color:#fff;font-size:.78rem;font-weight:700;transform:rotate(45deg)}
.route-point-marker{background:transparent;border:0}
.route-point-pin{position:relative;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50% 50% 50% 0;border:2px solid #fff;box-shadow:0 10px 22px rgba(15,23,42,.3);transform:rotate(-45deg)}
.route-point-pin span{position:relative;z-index:1;color:#fff;font-size:.8rem;font-weight:800;transform:rotate(45deg)}
.route-point-start{background:#16a34a}
.route-point-end{background:#0f172a}
.map-picker-marker{background:transparent;border:0}
.map-picker-pin{position:relative;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50% 50% 50% 0;background:#2563eb;border:2px solid #fff;box-shadow:0 8px 18px rgba(15,23,42,.28);transform:rotate(-45deg)}
.map-picker-pin span{position:relative;z-index:1;color:#fff;font-size:1rem;font-weight:800;line-height:1;transform:rotate(45deg)}
.ms-map-picker-canvas{height:380px;border:1px solid var(--border);border-radius:18px;overflow:hidden;background:#e5eef7}

/* =====================================================  SIDEBAR COLLAPSED  */
body.sidebar-collapsed .ms-sidebar{width:70px}
body.sidebar-collapsed .ms-sidebar .ms-brand-text,
body.sidebar-collapsed .ms-sidebar .ms-nav-label,
body.sidebar-collapsed .ms-sidebar .ms-user-info,
body.sidebar-collapsed .ms-sidebar .ms-sidebar-section-label,
body.sidebar-collapsed .ms-sidebar .ms-user-pill{display:none}
body.sidebar-collapsed .ms-sidebar .ms-sidebar-brand{justify-content:center;padding:1.25rem .5rem 1rem}
body.sidebar-collapsed .ms-sidebar .ms-sidebar-nav{padding:0 .35rem}
body.sidebar-collapsed .ms-sidebar .ms-nav-item{justify-content:center;padding:.65rem .5rem}
body.sidebar-collapsed .ms-sidebar .ms-sidebar-footer{padding:.75rem .5rem}
body.sidebar-collapsed .ms-main-wrapper{margin-left:70px}

/* =====================================================  RESPONSIVE  */
@media(max-width:991.98px){
    .ms-sidebar{transform:translateX(-100%)}
    .ms-sidebar.open{transform:translateX(0);box-shadow:var(--shadow-lg)}
    .ms-main-wrapper{margin-left:0 !important}
    .ms-content{padding:1.25rem}
}

/* =====================================================  AUTH  */
body.auth-body{background:linear-gradient(135deg,#4f46e5 0%,#7c3aed 50%,#0ea5e9 100%);min-height:100vh;display:flex;align-items:center;justify-content:center;padding:2rem 1rem}
.auth-card{background:var(--surface);border-radius:1.25rem;box-shadow:var(--shadow-lg);width:100%;max-width:440px;overflow:hidden}
.auth-card-header{background:linear-gradient(135deg,#4f46e5,#7c3aed);padding:2rem 2rem 1.5rem;text-align:center;color:#fff}
.auth-logo{width:52px;height:52px;background:rgba(255,255,255,.2);border-radius:.9rem;display:flex;align-items:center;justify-content:center;margin:0 auto .75rem;backdrop-filter:blur(4px)}
.auth-brand-name{font-size:1.2rem;font-weight:700;margin:0 0 .2rem}
.auth-brand-sub{font-size:.8rem;opacity:.8;margin:0}
.auth-card-body{padding:2rem}

[data-theme="dark"] body.auth-body{background:linear-gradient(145deg,#050b16 0%,#0f1d33 45%,#0b2338 100%)}
[data-theme="dark"] .auth-card-header{background:linear-gradient(135deg,#1d4ed8,#0f766e)}
.guest-theme-toggle{position:fixed;top:1rem;right:1rem;z-index:20;background:var(--surface);border:1px solid var(--border);color:var(--text)}
.guest-theme-toggle:hover{background:var(--surface-2)}
