:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --tyre-empty: rgba(255, 255, 255, 0.05);
    --tyre-installed: rgba(16, 185, 129, 0.2);
    --tyre-installed-border: #10b981;
}

.hidden {
    display: none !important;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
}

.swap-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid #f59e0b;
    color: #fcd34d;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
}

.swap-message.hidden {
    display: none;
}

.main-content {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Lorry Layout */
.lorry-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background: var(--glass-bg);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    max-width: 800px;
    width: 100%;
    margin-bottom: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.axle-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.steer-axle {
    margin-bottom: 2rem;
}

.steer-group-left, .steer-group-right {
    width: 168px; /* 80px + 8px gap + 80px */
}

.steer-group-left {
    justify-content: flex-end;
}

.steer-group-right {
    justify-content: flex-start;
}

.dual-axle {
    justify-content: space-between;
}

.dual-group {
    display: flex;
    gap: 0.5rem;
}

.axle-spacer {
    flex-grow: 1;
    height: 4px;
    background: rgba(255,255,255,0.1); /* Virtual chassis rendering */
    margin: 0 1rem;
    border-radius: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.axle-spacer::after {
    content: attr(data-label);
    background: #0f172a; /* Match body/modal background to cutout the line */
    padding: 0 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.spare-spacer {
    width: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spare-spacer::after {
    content: attr(data-label);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.tyre-pos {
    background: var(--tyre-empty);
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    width: 80px;
    height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.5rem;
}

.tyre-pos:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.tyre-pos.installed {
    background: var(--tyre-installed);
    border: 2px solid var(--tyre-installed-border);
}

/* Swap Mode Styles */
.swap-mode .tyre-pos {
    cursor: crosshair;
}

.swap-mode .tyre-pos:not(.swap-source) {
    animation: target-pulse 1.5s infinite;
    border-color: rgba(59, 130, 246, 0.5);
}

.tyre-pos.swap-source {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
    animation: source-pulse 2s infinite;
}

.tyre-pos.swap-target-hover {
    border-color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.3) !important;
}

@keyframes source-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes target-pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.pos-label {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.tyre-pos.installed .pos-label {
    color: var(--text-primary);
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    pointer-events: none;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.modal .glass-panel {
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.active {
    opacity: 1;
}

.modal.active .glass-panel {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}
.btn-primary {
    background: var(--primary-color);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.history-item {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-action {
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive Overrides */
@media (max-width: 800px) {
    .lorry-grid {
        padding: 1.5rem;
    }
    
    .steer-axle {
        gap: 5rem;
    }
    
    .tyre-pos {
        width: 70px;
        height: 100px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .glass-panel {
        min-width: 90vw;
        padding: 1.5rem;
    }
    
    .steer-axle {
        gap: 3rem;
    }

    .dual-group {
        gap: 0.25rem;
    }

    .tyre-pos {
        width: 60px;
        height: 90px;
        padding: 0.25rem;
    }
    
    .pos-label {
        font-size: 1rem;
    }

    .status-badge, .serial-badge {
        font-size: 0.6rem;
    }
}
.btn-close:hover {
    color: #ef4444;
}

.actions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-action:hover {
    background: var(--primary-color);
    border-color: var(--primary-hover);
    transform: translateX(5px);
}

/* Utilities */
.status-badge {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
}

/* Manage Lorries Revised Styles */
.sticky-header {
    position: sticky;
    top: 0;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn-page {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: var(--primary-color);
    border-color: var(--primary-hover);
}

.btn-page:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.history-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s, background 0.2s;
}

.history-card:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(5px);
}

.tyre-pos.active-filter {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 15px var(--primary-color);
    background: rgba(37, 99, 235, 0.15) !important;
}

.input-field {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.3s;
}

.input-field:focus {
    border-color: var(--primary-color);
}

select.input-field option {
    background-color: #0f172a; /* slate-900 */
    color: var(--text-primary);
}

.brand-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    transition: background 0.2s;
}

.brand-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.brand-name {
    flex: 1;
    font-size: 1rem;
    padding-left: 0.75rem;
}

.star-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.5rem;
    transition: color 0.2s, transform 0.2s;
}

.star-btn:hover {
    transform: scale(1.1);
}

.star-btn.active {
    color: #fbbf24; /* yellow-400 */
}

/* Custom checkbox style */
.brand-checkbox {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.tyres-filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.tyres-table th {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.tyres-table td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.tyres-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.tyres-table tbody tr:last-child td {
    border-bottom: none;
}

.tyre-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.tyre-action-btn:hover {
    color: var(--primary-color);
}

/* New Tracking Styles */
.field-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.activity-log-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.activity-table {
    width: 100%;
    border-collapse: collapse;
}

.activity-table th {
    text-align: center;
    padding: 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    white-space: nowrap;
}

.activity-table td {
    padding: 0.75rem;
    font-size: 0.85rem;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.action-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.action-fix { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.action-out { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.action-switch { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.cond-badge {
    font-size: 0.95rem;
    font-weight: 700;
    opacity: 1;
}

.activity-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.activity-item {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--primary-color);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-item .activity-title {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.activity-item .activity-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Glowing for SWITCH flow */
.glowing {
    animation: glow-pulse 1.5s infinite alternate;
    border-style: solid !important;
}

@keyframes glow-pulse {
    from {
        box-shadow: 0 0 5px rgba(37, 99, 235, 0.4), 0 0 10px rgba(37, 99, 235, 0.2);
        border-color: rgba(37, 99, 235, 0.6);
    }
    to {
        box-shadow: 0 0 15px rgba(37, 99, 235, 0.8), 0 0 30px rgba(37, 99, 235, 0.4);
        border-color: rgba(37, 99, 235, 1);
    }
}

/* Layout Utilities */
/* Sidebar Navigation */
.burger-menu-btn, .back-dashboard-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1100;
    background: var(--primary-color);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.burger-menu-btn:hover, .back-dashboard-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.return-icon {
    font-size: 1.4rem;
    font-weight: bold;
}

.burger-bar {
    width: 24px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* sidebar-active state for burger bars */
.sidebar-active .burger-bar:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}
.sidebar-active .burger-bar:nth-child(2) {
    opacity: 0;
}
.sidebar-active .burger-bar:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

.sidebar {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1050;
    padding: 6rem 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 1px solid var(--glass-border);
}

.sidebar.active {
    right: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.nav-top, .nav-bottom {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-bottom {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.sidebar-nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-nav-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-hover);
    transform: translateX(-5px);
}

.sidebar-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: left;
}
/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
