/* ==========================================================================
   TransVIP First Inc. — High-Density Enterprise TMS Cockpit (admin.css)
   Aesthetic: Sleek Luxury Dark Executive Design System
   Micro-Typography, Zero Bloat, Tactical Contrast
   ========================================================================== */

:root {
    --adm-bg: #060a14;
    --adm-sidebar: #090f1f;
    --adm-surface: #0c152b;
    --adm-surface-hover: #111e3d;
    --adm-border: rgba(255, 255, 255, 0.08);
    --adm-border-focus: rgba(0, 132, 255, 0.5);
    
    --blue-primary: #0084ff;
    --blue-hover: #0070e0;
    --cyan-accent: #00d2ff;
    --cyan-glow: #38bdf8;
    
    --emerald: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --purple: #a855f7;
    
    --text-white: #ffffff;
    --text-silver: #cbd5e1;
    --text-muted: #8492a6;
    --text-dark: #475569;
    
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 9999px;
    
    --shadow-subtle: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-modal: 0 25px 60px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    --transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--adm-bg);
    color: var(--text-white);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Sidebar Navigation (Refined & Compact)
   ========================================================================== */
.admin-sidebar {
    width: 240px;
    background: var(--adm-sidebar);
    border-right: 1px solid var(--adm-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header img {
    height: 28px;
    width: auto;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    overflow-y: auto;
}

.nav-item-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-item-btn:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-white);
}

.nav-item-btn.active {
    background: rgba(0, 132, 255, 0.14);
    color: var(--cyan-accent);
    border-left: 3px solid var(--blue-primary);
}

.nav-icon {
    font-size: 1rem;
    opacity: 0.9;
}

.sidebar-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--adm-border);
    font-size: 0.75rem;
    color: var(--text-dark);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at 90% 10%, rgba(0, 132, 255, 0.06), transparent 50%);
}

.admin-topbar {
    height: 52px;
    background: rgba(9, 15, 31, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--adm-border);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.dispatch-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--emerald);
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald);
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-sm-action {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--adm-border);
    color: var(--text-silver);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
}

.btn-sm-action:hover {
    background: rgba(0, 132, 255, 0.2);
    border-color: var(--blue-primary);
    color: #fff;
}

.btn-primary-action {
    background: var(--blue-primary);
    border: 1px solid var(--blue-primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-primary-action:hover {
    background: var(--blue-hover);
    box-shadow: 0 2px 10px rgba(0, 132, 255, 0.4);
}

/* Page Workspace */
.admin-workspace {
    padding: 1.25rem;
    flex: 1;
}

/* ==========================================================================
   KPI Cards Row (Compact, Clean Metrics)
   ========================================================================== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.kpi-card:hover {
    border-color: rgba(255, 255, 255, 0.16);
    background: var(--adm-surface-hover);
}

.kpi-meta span {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.2rem;
}

.kpi-meta strong {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #fff;
}

.kpi-icon {
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--emerald); }
.kpi-icon.blue { background: rgba(0, 132, 255, 0.12); color: var(--cyan-accent); }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.12); color: var(--amber); }
.kpi-icon.purple { background: rgba(168, 85, 247, 0.12); color: var(--purple); }

/* Tab Panes */
.tab-view-pane {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-view-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Tables & Data Presentation
   ========================================================================== */
.table-panel-box {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-subtle);
}

.panel-header-toolbar {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(5, 9, 20, 0.6);
}

.panel-header-toolbar h4 {
    font-size: 0.92rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-pills-row {
    display: flex;
    gap: 0.35rem;
}

.pill-filter-btn {
    background: transparent;
    border: 1px solid var(--adm-border);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: var(--transition);
}

.pill-filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.pill-filter-btn.active {
    background: var(--blue-primary);
    border-color: var(--blue-primary);
    color: #fff;
}

.dense-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.dense-table th {
    background: rgba(4, 7, 16, 0.8);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--adm-border);
}

.dense-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-silver);
    vertical-align: middle;
}

.dense-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Micro Badges */
.badge-state {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-paid { background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-verification { background: rgba(245, 158, 11, 0.15); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.badge-maintenance { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.35); }
.badge-neutral { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* Table Action Buttons */
.btn-grid-action {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--adm-border);
    color: var(--text-silver);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
}

.btn-grid-action:hover {
    background: var(--blue-primary);
    border-color: var(--blue-primary);
    color: #fff;
}

/* Driver / Vehicle Avatar */
.avatar-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    background: #0d1a38;
    border: 1px solid var(--adm-border);
}

/* ==========================================================================
   Leaflet Tactical Map & OpenStreetMap Controls
   ========================================================================== */
.tactical-map-wrap {
    height: 540px;
    background: #060b18;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--adm-border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

#fleet_map {
    width: 100%;
    height: 100%;
}

.map-status-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: rgba(6, 10, 20, 0.92);
    border: 1px solid var(--adm-border);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    z-index: 1000;
    display: flex;
    gap: 1rem;
}

.legend-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-silver);
    font-weight: 600;
}

.legend-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* OpenStreetMap & Leaflet Theme Customization */
.leaflet-control-layers {
    background: rgba(10, 18, 36, 0.94) !important;
    border: 1px solid var(--adm-border) !important;
    color: #fff !important;
    border-radius: var(--radius-xs) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6) !important;
    font-family: inherit !important;
    font-size: 0.78rem !important;
    backdrop-filter: blur(8px) !important;
    padding: 0.4rem 0.6rem !important;
}

.leaflet-control-layers-base label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.35rem;
    cursor: pointer;
    color: var(--text-silver);
}

.leaflet-control-layers-base label:hover {
    color: #fff;
}

.leaflet-bar {
    border: 1px solid var(--adm-border) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5) !important;
}

.leaflet-bar a {
    background-color: #0a1226 !important;
    border-color: var(--adm-border) !important;
    color: #00d2ff !important;
}

.leaflet-bar a:hover {
    background-color: #122144 !important;
    color: #fff !important;
}

.leaflet-popup-content-wrapper {
    background: #0a1226 !important;
    color: #fff !important;
    border: 1px solid var(--accent) !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.7) !important;
    padding: 2px !important;
}

.leaflet-popup-tip {
    background: #0a1226 !important;
    border: 1px solid var(--accent) !important;
}

.custom-fleet-pin {
    transition: transform 0.2s ease;
}

.custom-fleet-pin:hover {
    transform: scale(1.15);
    z-index: 1500 !important;
}

.hub-landmark-pin {
    transition: transform 0.2s ease;
}

.hub-landmark-pin:hover {
    transform: scale(1.2);
}

/* ==========================================================================
   Modal Dialogs (Chauffeurs, Vehicles, Leg Assignment)
   ========================================================================== */
.modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(6px) !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    z-index: 2000 !important;
    padding: 1rem !important;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-dialog {
    background: #0a1224;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(5, 9, 20, 0.7);
    flex-shrink: 0;
}

.modal-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close-modal:hover {
    color: #fff;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--adm-border);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    background: #080f20;
    flex-shrink: 0;
}

.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.modal-form-group {
    margin-bottom: 0.75rem;
}

.modal-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-silver);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.modal-input {
    width: 100%;
    background: rgba(14, 25, 48, 0.85);
    border: 1px solid var(--adm-border);
    border-radius: var(--radius-xs);
    color: #fff;
    font-family: inherit;
    font-size: 0.82rem;
    padding: 0.45rem 0.65rem;
    outline: none;
    transition: var(--transition);
}

.modal-input:focus {
    border-color: var(--blue-primary);
    box-shadow: 0 0 8px rgba(0, 132, 255, 0.35);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 900px) {
    .admin-sidebar {
        width: 60px;
    }
    .sidebar-header img, .nav-item-btn span, .sidebar-footer {
        display: none;
    }
    .nav-item-btn {
        justify-content: center;
        padding: 0.65rem;
    }
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
    .form-grid-2col {
        grid-template-columns: 1fr;
    }
}
