:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #22c55e;
    --dark: #1e293b;
    --gray: #64748b;
    --light-gray: #f1f5f9;
    --white: #ffffff;
    --gradient-1: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    --gradient-2: linear-gradient(135deg, #3b82f6 0%, #0ea5e9 100%);
    --gradient-3: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--light-gray);
    color: var(--dark);
    line-height: 1.6;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 80vh;
    /* Ensure enough height to push footer down reasonably */
}

.header {
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    transition: color 0.3s;
}

.nav a:hover {
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin: 24px 0;
}

/* Stats Cards */
.stat-card {
    background: var(--gradient-1);
    color: var(--white);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: scale(1.05);
}

.stat-card.green {
    background: var(--gradient-3);
}

.stat-card.orange {
    background: var(--gradient-2);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin: 10px 0;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-secondary:hover {
    background: #475569;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Range Slider */
.range-slider {
    margin: 20px 0;
}

.range-input {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, var(--primary) 0%, var(--primary) 50%, #e2e8f0 50%, #e2e8f0 100%);
    outline: none;
    -webkit-appearance: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.range-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    border: none;
}

.range-value {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary);
    color: var(--white);
    border-radius: 6px;
    font-weight: 600;
    margin-top: 8px;
}

/* Circular Images */
.vehicle-circle,
.operator-circle,
.user-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: contain;
    border: 4px solid var(--primary);
    display: block;
    margin: 0 auto 16px;
    transition: transform 0.3s;
    background: #ffffff;
}

.vehicle-circle:hover,
.operator-circle:hover,
.user-circle:hover {
    transform: scale(1.1);
}

.vehicle-small {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: contain;
    border: 3px solid var(--primary);
    display: block;
    background: #ffffff;
}

/* Vehicle/Operator Grid */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.selection-item {
    background: var(--white);
    border: 3px solid transparent;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.selection-item:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
}

.selection-item.selected {
    border-color: var(--primary);
    background: #f0f4ff;
}

.selection-item img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    margin-bottom: 8px;
    border: 3px solid var(--primary);
    background: #ffffff;
}

.selection-item h4 {
    font-size: 14px;
    margin: 8px 0 4px;
}

.selection-item p {
    font-size: 12px;
    color: var(--gray);
}

/* Notifications */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 16px 24px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification.success {
    border-left: 4px solid var(--success);
}

.notification.error {
    border-left: 4px solid var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay .loading {
    width: 50px;
    height: 50px;
    border-width: 5px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
}

.modal-close:hover {
    color: var(--dark);
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.table th {
    background: var(--light-gray);
    font-weight: 600;
}

.table tr:hover {
    background: var(--light-gray);
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-1);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 20px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark);
}

/* Responsive */
/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
        padding: 0 15px;
    }

    .nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        gap: 15px;
        white-space: nowrap;
        /* Hide scrollbar but keep functionality */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav a {
        padding: 8px 12px;
        background: var(--light-gray);
        border-radius: 20px;
        font-size: 14px;
    }

    .nav a:hover {
        background: #e2e8f0;
    }

    .selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 28px;
    }

    /* Mobile Card View for Tables */
    .table-responsive {
        overflow: visible;
        margin: 0;
        padding: 0;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        margin-bottom: 15px;
        background: var(--white);
        border-radius: 12px;
        box-shadow: var(--shadow);
        padding: 15px;
        border: 1px solid #e2e8f0;
    }

    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        text-align: right;
        border-bottom: 1px solid #f1f5f9;
        font-size: 14px;
    }

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

    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray);
        text-align: left;
        margin-right: 15px;
    }

    /* Adjust modal size */
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }
}

/* Default Table Responsive (Desktop) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

/* Footer */
.footer {
    background: var(--white);
    padding: 20px 0;
    margin-top: 40px;
    /* Fixed margin */
    text-align: center;
    color: var(--gray);
    font-size: 14px;
    border-top: 1px solid #e2e8f0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.hidden {
    display: none;
}