:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1a1d21;
    --sidebar-hover: #2a2d35;
    --accent: #58a6ff;
}
body { overflow-x: hidden; }

/* Sidebar */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #333;
}
.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 0.5rem 0;
}
.sidebar-nav .nav-link {
    color: #adb5bd; padding: 0.6rem 1.2rem;
    display: flex; align-items: center; gap: 0.6rem;
    text-decoration: none; font-size: 0.9rem;
    transition: background 0.15s;
}
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-hover); color: var(--accent); border-left: 3px solid var(--accent); }
.sidebar-nav .nav-link i { width: 20px; text-align: center; }
.sidebar-footer { border-top: 1px solid #333; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding-top: 0;
}

/* Mobile */
@media (max-width: 767.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; padding-top: 56px; }
}

/* Cards */
.card {
    background: #21252b; border: 1px solid #333;
    border-radius: 8px;
}
.card:hover { border-color: #555; }

/* Tables */
.table { --bs-table-bg: transparent; }
.table th { font-weight: 600; font-size: 0.85rem; text-transform: uppercase; color: #8b949e; }

/* Buttons */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #4090e0; border-color: #4090e0; }

/* ─── Mobile Responsive Fixes ──────────────────────────────── */

/* Sidebar: larger tap targets on touch */
@media (max-width: 767.98px) {
    .sidebar-nav .nav-link {
        padding: 0.85rem 1.2rem;
        font-size: 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    .sidebar-nav .nav-link i {
        font-size: 1.2rem;
        width: 24px;
    }
    .sidebar-footer .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Forms/Modals: fullscreen on mobile (Bootstrap built-in, but ensure) */
    .modal-dialog:not(.modal-fullscreen-sm-down) {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    .modal-fullscreen-sm-down .modal-content {
        border-radius: 0;
    }
    
    /* Vehicle detail: compact buttons */
    .d-flex.gap-2 .btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Container padding */
    .container-fluid.py-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 1rem !important;
    }
    
    /* Vehicle info cards stack */
    .col-md-8, .col-md-4 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Tab nav scroll on mobile */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-tabs .nav-item {
        white-space: nowrap;
    }
}

/* Vehicles table → card layout on mobile */
@media (max-width: 767.98px) {
    #vehicleTable thead { display: none; }
    #vehicleTable tbody tr {
        display: block;
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        background: #21252b;
        border: 1px solid #333;
        border-radius: 8px;
    }
    #vehicleTable tbody tr:hover {
        border-color: #555;
    }
    #vehicleTable tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
    }
    #vehicleTable tbody td::before {
        font-weight: 600;
        font-size: 0.8rem;
        text-transform: uppercase;
        color: #8b949e;
        margin-right: 0.5rem;
    }
    #vehicleTable tbody td:nth-child(1)::before { content: "Kennzeichen"; }
    #vehicleTable tbody td:nth-child(2)::before { content: "Fahrzeug"; }
    #vehicleTable tbody td:nth-child(3)::before { content: "Marke"; }
    #vehicleTable tbody td:nth-child(4)::before { content: "Motor"; }
    #vehicleTable tbody td:nth-child(5)::before { content: "Dateien"; }
    #vehicleTable tbody td:nth-child(6)::before { content: "Logs"; }
    #vehicleTable tbody td:nth-child(7)::before { content: "Geändert"; }
    #vehicleTable tbody td:nth-child(8)::before { content: "Besitzer"; }
    
    /* Hide sort indicators on mobile */
    #vehicleTable th[onclick] { cursor: default; }
    
    /* Orders table cards on mobile */
    .table-responsive .table tbody tr {
        cursor: pointer;
    }
}

/* Dropdown menus: ensure they work on mobile */
@media (max-width: 767.98px) {
    .dropdown-menu {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        min-width: 200px;
    }
    
    /* Form controls: larger on mobile */
    .form-control, .form-select {
        min-height: 44px;
        font-size: 1rem;
    }
    .form-check-label {
        padding-top: 2px;
    }
    .form-check-input {
        width: 1.2em;
        height: 1.2em;
    }
    
    /* Badges wrap */
    td small {
        word-break: break-word;
    }
}

/* Log Viewer vehicle link */
.vehicle-link { margin-top: 2px; }
.vehicle-link a { font-size: 0.75rem; opacity: 0.8; }
.vehicle-link a:hover { opacity: 1; }
