/* ============================================
   HCON-Cars - Main Stylesheet
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3a56;
    --accent: #e67e22;
    --bg-light: #f4f6f9;
    --bg-sidebar: #1a2332;
    --bg-sidebar-hover: #243447;
    --bg-sidebar-active: #2c3e50;
    --text-sidebar: #b8c7d6;
    --text-sidebar-active: #ffffff;
    --border-color: #dee2e6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: var(--bg-light);
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   Layout
   ============================================ */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-width: 0;
}

.page-content {
    padding: 24px;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

/* Desktop: toggle hides sidebar */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-brand i {
    font-size: 22px;
    color: var(--accent);
}

.sidebar-logo {
    max-width: 100px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 13.5px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-left-color: var(--accent);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.sidebar-nav .nav-link .badge {
    font-size: 10px;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 20px;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

/* ============================================
   Top Bar
   ============================================ */

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    color: #555;
    font-size: 18px;
    text-decoration: none;
}

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

.topbar-alerts .btn-link {
    color: #555;
    font-size: 18px;
    text-decoration: none;
}

.user-menu {
    color: #333;
    text-decoration: none;
    font-size: 13px;
}

/* ============================================
   Cards & Stats
   ============================================ */

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 12.5px;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.border-warning { border-left-color: #f39c12; }
.stat-card.border-danger { border-left-color: #e74c3c; }
.stat-card.border-success { border-left-color: #27ae60; }
.stat-card.border-info { border-left-color: #3498db; }

/* ============================================
   Content Cards
   ============================================ */

.content-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.content-card .card-header {
    background: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-card .card-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-dark);
}

.content-card .card-body {
    padding: 20px;
}

.content-card .nav-tabs {
    padding: 0 20px;
    position: relative;
    z-index: 2;
}

.content-card .tab-content {
    padding: 0 20px 20px;
    position: relative;
}

/* ============================================
   Tables
   ============================================ */

.table-responsive {
    border-radius: var(--radius);
}

.data-table {
    margin-bottom: 0;
}

.data-table th {
    background: #f8f9fb;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    border-bottom-width: 2px;
    white-space: nowrap;
    padding: 12px 16px;
}

.data-table td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 13.5px;
}

.data-table tbody tr:hover {
    background: #f8f9fc;
}

.data-table .actions {
    white-space: nowrap;
}

/* The last column of every list table is the actions column. Keep its
   buttons on a single line so they never wrap (e.g. the delete button
   dropping under the others) when the table narrows on smaller screens. */
.data-table th:last-child,
.data-table td:last-child {
    white-space: nowrap;
}

.data-table .actions .btn,
.data-table td:last-child .btn {
    padding: 4px 8px;
    font-size: 12px;
}

/* Clickable list rows — reusable pattern (see assets/js/app.js).
   Give a row class="clickable-row" + data-href="..." and the whole
   row navigates. Hover is a light tint of --primary (#1a5276),
   slightly stronger than the default row hover, so clickability
   is noticeable. */
tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:hover td {
    background-color: rgba(26, 82, 118, 0.10);
}

/* Bootstrap's .table-hover paints its own gray hover as an inset
   box-shadow ON TOP of the cell background; make it transparent for
   clickable rows so the brand tint above shows cleanly. */
.table-hover > tbody > tr.clickable-row:hover > * {
    --bs-table-hover-bg: transparent;
}

/* ============================================
   Badges
   ============================================ */

.badge {
    font-weight: 500;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 20px;
}

/* ============================================
   Driver Multi-Select Dropdown
   ============================================ */

.driver-multiselect {
    position: relative;
}

.driver-multiselect-toggle {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    min-height: 38px;
}

.driver-multiselect-toggle i {
    transition: transform 0.2s ease;
    color: #999;
}

.driver-multiselect.open .driver-multiselect-toggle i {
    transform: rotate(180deg);
}

.driver-multiselect-label {
    font-size: 13px;
    color: #777;
}

.driver-multiselect-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.driver-multiselect.open .driver-multiselect-dropdown {
    display: block;
}

.driver-multiselect-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    margin: 0;
}

.driver-multiselect-item:hover {
    background: #f0f4f8;
}

.driver-multiselect-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.driver-multiselect-item .driver-name {
    font-weight: 500;
    color: #333;
}

.driver-multiselect-item .driver-spec {
    font-size: 11.5px;
    color: #999;
}

/* Selected driver tags */
.driver-multiselect-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.driver-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.driver-tag .remove-driver {
    cursor: pointer;
    opacity: 0.7;
    font-size: 10px;
}

.driver-tag .remove-driver:hover {
    opacity: 1;
}

/* ============================================
   Forms
   ============================================ */

.form-label {
    font-weight: 500;
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}

.form-label .required {
    color: #e74c3c;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: #d1d5db;
    font-size: 13.5px;
    padding: 8px 12px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

/* ============================================
   Page Header
   ============================================ */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
}

.breadcrumb {
    font-size: 12.5px;
    margin: 0;
}

/* ============================================
   Vehicle Profile
   ============================================ */

.vehicle-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.vehicle-header .vehicle-code {
    font-size: 12px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.vehicle-header .vehicle-name {
    font-size: 24px;
    font-weight: 700;
}

.vehicle-photo {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.3);
}

.vehicle-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    opacity: 0.5;
}

.info-item {
    padding: 10px 14px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    height: 100%;
}

.info-item label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.info-item .value {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    word-break: break-word;
}

/* ============================================
   Timeline
   ============================================ */

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e0e0e0;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
    padding: 16px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2px solid #fff;
}

.timeline-item.event-fault::before { background: #e74c3c; }
.timeline-item.event-accident::before { background: #e74c3c; }
.timeline-item.event-service::before { background: #f39c12; }
.timeline-item.event-note::before { background: #3498db; }

.timeline-date {
    font-size: 12px;
    color: #888;
}

/* ============================================
   Alerts List
   ============================================ */

.alert-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: var(--transition);
}

.alert-item:hover {
    background: #fafbfc;
}

.alert-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.alert-icon.danger { background: #fdecea; color: #e74c3c; }
.alert-icon.warning { background: #fff8e1; color: #f39c12; }
.alert-icon.info { background: #e3f2fd; color: #2196f3; }
.alert-icon.success { background: #e8f5e9; color: #27ae60; }

/* ============================================
   Login Page
   ============================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo i {
    font-size: 48px;
    color: var(--primary);
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 12px;
}

.login-logo p {
    color: #888;
    font-size: 13px;
}

/* ============================================
   Quick Actions
   ============================================ */

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: #333;
    text-decoration: none;
    transition: var(--transition);
}

.quick-action:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.quick-action i {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    color: var(--primary);
    font-size: 14px;
}

/* ============================================
   Filters Bar
   ============================================ */

.filters-bar {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h5 {
    color: #666;
    margin-bottom: 8px;
}

/* ============================================
   Health Indicator
   ============================================ */

.health-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.health-dot.green { background: #27ae60; }
.health-dot.orange { background: #f39c12; }
.health-dot.red { background: #e74c3c; }
.health-dot.gray { background: #95a5a6; }

/* ============================================
   Responsive
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    pointer-events: none;
}

body.sidebar-open .sidebar-overlay {
    pointer-events: auto;
}

/* Mid-size laptops (1200-1439px): narrower sidebar, modest tightening */
@media (max-width: 1439.98px) {
    :root { --sidebar-width: 220px; }
    .page-content { padding: 20px; }
    .data-table th, .data-table td { padding: 10px 12px; }
}

/* Small laptops (1024-1199px): narrower sidebar, tighter spacing */
@media (max-width: 1199.98px) {
    :root { --sidebar-width: 220px; }
    .sidebar-nav .nav-link { font-size: 12.5px; padding: 9px 16px; }
    .sidebar-header { padding: 12px 16px; }
    .sidebar-logo { max-width: 85px; }
    .page-content { padding: 16px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-icon { display: none; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 12.5px; }
    .filters-bar { padding: 12px 16px; }
    .content-card .card-body { padding: 16px; }
    .content-card .card-header { padding: 12px 16px; }
}

/* Tablets / small screens: sidebar offscreen */
@media (max-width: 991.98px) {
    :root { --sidebar-width: 260px; }
    .sidebar {
        transform: translateX(-100%);
    }
    /* Mobile: toggle opens sidebar */
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    body.sidebar-open .sidebar-overlay {
        display: block;
    }
    /* Undo desktop collapse on mobile */
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: 16px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar { padding: 0 12px; }
}

/* Hide less-important columns on smaller screens */
@media (max-width: 1399.98px) {
    .d-xxl-table-cell { display: none !important; }
}

@media (max-width: 1199.98px) {
    .d-xl-table-cell { display: none !important; }
}

@media (max-width: 767.98px) {
    .stat-card .stat-value {
        font-size: 22px;
    }
    .vehicle-header {
        padding: 16px;
    }
    .info-grid {
        grid-template-columns: 1fr 1fr;
    }
    .data-table th, .data-table td { padding: 6px 8px; font-size: 12px; }
    .vehicle-header .vehicle-name { font-size: 18px; }
    .d-md-table-cell { display: none !important; }
}

/* ============================================
   Print
   ============================================ */

@media print {
    .sidebar, .topbar, .sidebar-overlay, .btn, .filters-bar { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}

/* ============================================
   Dark Mode
   ============================================ */

body.dark-mode {
    --bg-light: #1a1d23;
    --border-color: #2d3139;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    background: #1a1d23;
    color: #d1d5db;
}

body.dark-mode .topbar {
    background: #22262e;
    border-bottom-color: #2d3139;
}

body.dark-mode .sidebar-toggle,
body.dark-mode .topbar-alerts .btn-link {
    color: #9ca3af;
}

body.dark-mode .user-menu {
    color: #d1d5db;
}

body.dark-mode .content-card,
body.dark-mode .stat-card,
body.dark-mode .filters-bar {
    background: #22262e;
    border-color: #2d3139;
}

body.dark-mode .content-card .card-header {
    border-bottom-color: #2d3139;
}

body.dark-mode .content-card .card-header h5 {
    color: #e5e7eb;
}

/* Tables - override Bootstrap's --bs-table-bg */
body.dark-mode .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #2a2e36;
    --bs-table-hover-bg: #2a2e36;
    --bs-table-color: #d1d5db;
    --bs-table-border-color: #2d3139;
    color: #d1d5db;
}
body.dark-mode .table th,
body.dark-mode .data-table th { background: #2a2e36; color: #9ca3af; border-color: #2d3139; }
body.dark-mode .table td { border-color: #2d3139; }
body.dark-mode .table-hover > tbody > tr:hover > * {
    --bs-table-hover-bg: #2a2e36;
    --bs-table-hover-color: #d1d5db;
    background-color: #2a2e36 !important;
    color: #d1d5db;
}
body.dark-mode .data-table tbody tr:hover { background: #2a2e36; }

/* Clickable list rows in dark mode: steel-blue hover (matches the
   sidebar active shade #2c3e50) instead of the flat #2a2e36. The
   !important + extra class out-specifies the .table-hover rule above. */
body.dark-mode tr.clickable-row:hover td { background-color: #2c3e50; }
body.dark-mode .table-hover > tbody > tr.clickable-row:hover > * {
    --bs-table-hover-bg: transparent;
    background-color: #2c3e50 !important;
}

/* Forms */
body.dark-mode .form-control,
body.dark-mode .form-select {
    background: #2a2e36;
    border-color: #3d4250;
    color: #e5e7eb;
}

body.dark-mode .form-control::placeholder {
    color: #6b7280;
    opacity: 1;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    border-color: var(--primary-light);
    background: #2a2e36;
    color: #e5e7eb;
}

body.dark-mode .form-select option {
    background: #22262e;
    color: #d1d5db;
}

body.dark-mode .form-label { color: #9ca3af; }
body.dark-mode .form-text { color: #6b7280; }
body.dark-mode .form-check-input {
    background-color: #3d4250;
    border-color: #4b5563;
}
body.dark-mode .form-check-input:checked {
    background-color: var(--primary-light);
    border-color: var(--primary-light);
}
body.dark-mode .text-muted { color: #6b7280 !important; }
body.dark-mode .text-dark { color: #d1d5db !important; }
body.dark-mode .text-body { color: #d1d5db !important; }
body.dark-mode strong { color: #e5e7eb; }

/* Alerts / flash messages */
body.dark-mode .alert {
    --bs-alert-bg: #2a2e36;
    border-color: #3d4250;
    color: #d1d5db;
}
body.dark-mode .alert-danger { --bs-alert-bg: #3b1f1f; border-color: #5a2d2d; color: #f8a0a0; }
body.dark-mode .alert-warning { --bs-alert-bg: #3b3420; border-color: #5a4f2d; color: #f5d98a; }
body.dark-mode .alert-success { --bs-alert-bg: #1f3b27; border-color: #2d5a3a; color: #8af5a0; }
body.dark-mode .alert-info { --bs-alert-bg: #1f2e3b; border-color: #2d4a5a; color: #8ad8f5; }

/* Card body inside table wrappers */
body.dark-mode .card-body,
body.dark-mode .table-responsive { background: transparent; }

/* Input group */
body.dark-mode .input-group-text {
    background: #2a2e36;
    border-color: #3d4250;
    color: #9ca3af;
}

body.dark-mode .stat-card .stat-value { color: #e5e7eb; }
body.dark-mode .page-header h1,
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 { color: #e5e7eb; }

body.dark-mode .info-item { background: #2a2e36; }
body.dark-mode .info-item label { color: #6b7280; }
body.dark-mode .info-item .value { color: #d1d5db; }

body.dark-mode .dropdown-menu {
    background: #22262e;
    border-color: #2d3139;
}
body.dark-mode .dropdown-item { color: #d1d5db; }
body.dark-mode .dropdown-item:hover { background: #2a2e36; color: #fff; }
body.dark-mode .dropdown-item-text { color: #d1d5db; }
body.dark-mode .dropdown-divider { border-color: #2d3139; }

body.dark-mode .list-group-item {
    background: #22262e;
    border-color: #2d3139;
    color: #d1d5db;
}

body.dark-mode .modal-content {
    background: #22262e;
    border-color: #2d3139;
    color: #d1d5db;
}
body.dark-mode .modal-header { border-bottom-color: #2d3139; }
body.dark-mode .modal-footer { border-top-color: #2d3139; }
body.dark-mode .btn-close { filter: invert(1); }

body.dark-mode .badge.bg-light { background: #2a2e36 !important; color: #d1d5db !important; }
body.dark-mode .bg-light { background: #2a2e36 !important; }

body.dark-mode .alert-item:hover { background: #2a2e36; }
body.dark-mode .timeline-item { background: #22262e; }
body.dark-mode .timeline::before { background: #3d4250; }

body.dark-mode .nav-tabs { border-bottom-color: #2d3139; }
body.dark-mode .nav-tabs .nav-link { color: #9ca3af; background: transparent; border-color: transparent; }
body.dark-mode .nav-tabs .nav-link:hover { color: #e5e7eb; border-color: #3d4250 #3d4250 #2d3139; }
body.dark-mode .nav-tabs .nav-link.active { color: #e5e7eb; background: #22262e; border-color: #2d3139 #2d3139 #22262e; }
body.dark-mode .tab-content { background: #22262e; }
body.dark-mode .tab-pane { color: #d1d5db; }

body.dark-mode a { color: var(--primary-light); }
body.dark-mode a:hover { color: #5dade2; }
/* Solid buttons — ensure white text is visible */
body.dark-mode .btn-primary { background-color: var(--primary-light); border-color: var(--primary-light); color: #fff; }
body.dark-mode .btn-primary:hover { background-color: #3498db; border-color: #3498db; color: #fff; }
body.dark-mode .btn-secondary { background-color: #4b5563; border-color: #4b5563; color: #e5e7eb; }
body.dark-mode .btn-secondary:hover { background-color: #6b7280; border-color: #6b7280; color: #fff; }
body.dark-mode .btn-success { background-color: #27ae60; border-color: #27ae60; color: #fff; }
body.dark-mode .btn-danger { background-color: #e74c3c; border-color: #e74c3c; color: #fff; }
body.dark-mode .btn-info { background-color: #2980b9; border-color: #2980b9; color: #fff; }
body.dark-mode .btn-light { background-color: #374151; border-color: #4b5563; color: #e5e7eb; }
body.dark-mode .btn-light:hover { background-color: #4b5563; color: #fff; }

/* Outline buttons */
body.dark-mode .btn-outline-primary { color: #5dade2; border-color: #5dade2; }
body.dark-mode .btn-outline-primary:hover { background-color: #5dade2; color: #fff; }
body.dark-mode .btn-outline-secondary { color: #9ca3af; border-color: #3d4250; }
body.dark-mode .btn-outline-secondary:hover { background-color: #3d4250; color: #e5e7eb; }
body.dark-mode .btn-outline-danger { color: #e74c3c; border-color: #e74c3c; }
body.dark-mode .btn-outline-danger:hover { background-color: #e74c3c; color: #fff; }
body.dark-mode .btn-outline-success { color: #27ae60; border-color: #27ae60; }
body.dark-mode .btn-outline-success:hover { background-color: #27ae60; color: #fff; }
body.dark-mode .btn-outline-info { color: #3498db; border-color: #3498db; }
body.dark-mode .btn-outline-info:hover { background-color: #3498db; color: #fff; }
body.dark-mode .btn-outline-warning { color: #f39c12; border-color: #f39c12; }
body.dark-mode .btn-outline-warning:hover { background-color: #f39c12; color: #fff; }

body.dark-mode .pagination .page-link {
    background: #22262e;
    border-color: #2d3139;
    color: #d1d5db;
}
body.dark-mode .pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

body.dark-mode .form-check-label { color: #d1d5db; }

/* Driver multi-select dark mode */
body.dark-mode .driver-multiselect-dropdown {
    background: #2a2e36;
    border-color: #3d4250;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
body.dark-mode .driver-multiselect-item:hover {
    background: #343840;
}
body.dark-mode .driver-multiselect-item .driver-name {
    color: #e5e7eb;
}
body.dark-mode .driver-multiselect-item .driver-spec {
    color: #6b7280;
}
body.dark-mode .driver-multiselect-label {
    color: #9ca3af;
}
body.dark-mode .driver-tag {
    background: var(--primary-light);
}

body.dark-mode code { color: #e67e22; background: #2a2e36; padding: 2px 6px; border-radius: 3px; }

body.dark-mode hr { border-color: #2d3139; }
body.dark-mode .border-bottom { border-bottom-color: #3d4250 !important; }
body.dark-mode .border-top { border-top-color: #3d4250 !important; }

/* Badge overrides */
body.dark-mode .badge.bg-light.border { background: #2a2e36 !important; border-color: #3d4250 !important; color: #d1d5db !important; }
body.dark-mode .badge.text-dark { color: #d1d5db !important; }

/* Bootstrap bg utility overrides */
body.dark-mode .bg-white { background-color: #22262e !important; }
body.dark-mode .bg-opacity-10 { --bs-bg-opacity: 0.15; }
body.dark-mode .border { border-color: #3d4250 !important; }

/* Filters bar embedded in content-card */
body.dark-mode .filters-bar .form-control,
body.dark-mode .filters-bar .form-select {
    background: #1e2229;
    border-color: #3d4250;
    color: #e5e7eb;
}

/* Fix the vehicle thumbnail placeholder */
body.dark-mode .bg-light.rounded { background: #2a2e36 !important; }

/* Card footer (pagination area) */
body.dark-mode .card-footer {
    background: #22262e;
    border-top-color: #2d3139;
}

/* ============================================
   iOS PWA — safe-area insets (notch / home bar)
   Active when user installed the app to home screen.
   `viewport-fit=cover` + `apple-mobile-web-app-status-bar-style:
   black-translucent` makes content draw behind the status bar
   and home indicator, so we need explicit insets.
   ============================================ */

/* Apply insets only in standalone (installed) mode so a normal
   browser tab doesn't get extra padding. Two display modes are
   needed because iOS uses display:standalone differently than the
   spec's display-mode media query in some Safari versions. */
@media (display-mode: standalone), (display-mode: fullscreen) {

    /* Sidebar starts under the status bar — push it down */
    .sidebar {
        padding-top: env(safe-area-inset-top, 0);
    }

    /* Sidebar footer + main content footer respect the home indicator */
    .sidebar-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    }

    /* Main content respects left notch on landscape iPhones,
       and the home indicator at the bottom */
    .main-content {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .page-content {
        padding-left:  calc(24px + env(safe-area-inset-left, 0));
        padding-right: calc(24px + env(safe-area-inset-right, 0));
    }

    /* Top mobile bar (Bootstrap navbar on phones) — push below notch */
    .topbar,
    nav.navbar {
        padding-top: calc(8px + env(safe-area-inset-top, 0));
    }

    /* Login page wrapper — center vertically without ducking under the
       status bar / home indicator */
    .login-wrapper {
        padding-top:    calc(env(safe-area-inset-top, 0) + 16px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
    }

    /* Sticky-bottom alerts / toolbars (rare in this app, but defensive) */
    .fixed-bottom,
    .sticky-bottom {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* iOS Safari: prevent the auto-zoom on input focus when a field has
   font-size < 16px. Only on iPhones (max-width hint) — desktop is fine. */
@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* iOS: respect user dark/light system without forcing webview into
   a weird hybrid. Users can still override with the manual toggle. */
@supports (-webkit-touch-callout: none) {
    /* Smooth momentum scrolling inside scrollable areas */
    .sidebar,
    .table-responsive,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }

    /* Disable the gray tap highlight that flashes on every touch */
    a, button, .nav-link, .btn {
        -webkit-tap-highlight-color: transparent;
    }
}

