/* ============================================================
   Lustrol Fleet - Modern Dashboard Theme
   ============================================================ */

/* Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --sidebar-bg: #0f1b2d;
    --sidebar-hover: #162540;
    --sidebar-active: #1a3a5c;
    --sidebar-text: #8b9dc3;
    --sidebar-text-active: #ffffff;
    --sidebar-accent: #3b82f6;
    --topbar-height: 0px;
    --content-bg: #f0f4f8;
    --card-bg: #ffffff;
    --card-border: rgba(0,0,0,0.06);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-info: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-secondary: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --glass-bg: rgba(255,255,255,0.12);
    --glass-border: rgba(255,255,255,0.18);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.app-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: width var(--transition);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 20px 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 80px;
    text-decoration: none;
}
.sidebar-brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 8px;
}
.sidebar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}
.sidebar-brand-text h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}
.sidebar-brand-text small {
    color: var(--sidebar-text);
    font-size: 11px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-section {
    padding: 0 12px;
    margin-bottom: 6px;
}
.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(139,157,195,0.5);
    padding: 10px 12px 6px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    gap: 12px;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}
.sidebar-item i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-item:hover {
    background: var(--sidebar-hover);
    color: #cad5e8;
}
.sidebar-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}
.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--sidebar-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
}
.sidebar-footer .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}
.sidebar-footer-info {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition);
}
.sidebar-footer-info .user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}
.sidebar-footer-info .user-role {
    font-size: 11px;
    color: var(--sidebar-text);
}
.sidebar-footer .btn-logout {
    margin-left: auto;
    color: var(--sidebar-text);
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
    text-decoration: none;
    display: flex;
    flex-shrink: 0;
}
.sidebar-footer .btn-logout:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

/* Sidebar toggle button */
.sidebar-toggle {
    position: absolute;
    top: 28px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    border: 2px solid rgba(255,255,255,0.1);
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1041;
    font-size: 14px;
    transition: all var(--transition);
}
.sidebar-toggle:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-color: var(--sidebar-accent);
}

/* Collapsed sidebar */
body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed);
}
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-item span,
body.sidebar-collapsed .sidebar-footer-info,
body.sidebar-collapsed .sidebar-footer .btn-logout {
    opacity: 0;
    pointer-events: none;
    width: 0;
}
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 20px 8px;
}
body.sidebar-collapsed .sidebar-item {
    justify-content: center;
    padding: 10px 0;
}
body.sidebar-collapsed .sidebar-footer {
    justify-content: center;
    padding: 12px 8px;
}
body.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}
body.sidebar-collapsed .app-content {
    margin-left: var(--sidebar-collapsed);
}

/* ── App Content ── */
.app-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition);
    display: flex;
    flex-direction: column;
}

.app-content > main {
    flex: 1;
    padding: 24px;
}

/* ── Page enter animation ── */
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.app-content > main > * {
    animation: pageEnter 0.35s ease-out;
}

/* ── Footer ── */
.app-content > .footer {
    background: #fff;
    border-top: 1px solid var(--card-border);
    padding: 0;
}
.app-content > .footer img {
    display: block;
    margin: 0 auto;
    max-width: 30vw;
    height: auto;
}
.app-content > .footer .bg-dark {
    background: var(--sidebar-bg) !important;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--card-border);
    background: transparent;
    padding: 14px 20px;
}

.card-body {
    padding: 20px;
}

/* Dashboard gradient cards (glassmorphism) */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning,
.card.bg-danger,
.card.bg-secondary {
    border: none;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
}
.card.bg-primary { background: var(--gradient-primary) !important; }
.card.bg-success { background: var(--gradient-success) !important; }
.card.bg-info { background: var(--gradient-info) !important; }
.card.bg-warning { background: var(--gradient-warning) !important; }
.card.bg-danger { background: var(--gradient-danger) !important; }
.card.bg-secondary { background: var(--gradient-secondary) !important; }

.card.bg-primary::before,
.card.bg-success::before,
.card.bg-info::before,
.card.bg-warning::before,
.card.bg-danger::before,
.card.bg-secondary::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--glass-bg);
    top: -40px;
    right: -20px;
}
.card.bg-primary::after,
.card.bg-success::after,
.card.bg-info::after,
.card.bg-warning::after,
.card.bg-danger::after,
.card.bg-secondary::after {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--glass-bg);
    bottom: -20px;
    left: -10px;
}

.card.bg-primary .card-body,
.card.bg-success .card-body,
.card.bg-info .card-body,
.card.bg-warning .card-body,
.card.bg-danger .card-body,
.card.bg-secondary .card-body {
    position: relative;
    z-index: 1;
    padding: 20px;
}

.card.bg-primary:hover,
.card.bg-success:hover,
.card.bg-info:hover,
.card.bg-warning:hover,
.card.bg-danger:hover,
.card.bg-secondary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition);
}

/* ── Tables ── */
.table {
    margin-bottom: 0;
}
.table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    padding: 12px 16px;
}
.table td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: #f1f5f9;
    font-size: 13.5px;
}
.table-hover tbody tr:hover {
    background: rgba(59,130,246,0.04);
}
.table-responsive {
    border-radius: var(--radius-sm);
}

/* ── Buttons ── */
.btn {
    font-weight: 500;
    font-size: 13.5px;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    transition: all var(--transition);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active {
    transform: translateY(0);
}

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

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
    border-radius: 6px;
}

/* ── Forms ── */
.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid #e2e8f0;
    font-size: 13.5px;
    padding: 9px 12px;
    transition: all var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.input-group-text {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}

/* ── Badges ── */
.badge {
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.3px;
    padding: 5px 10px;
    border-radius: 6px;
}

/* ── Alerts (inline in login) ── */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    padding: 12px 16px;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast-item {
    pointer-events: auto;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
    min-width: 300px;
    max-width: 420px;
    border-left: 4px solid var(--accent);
    animation: toastIn 0.35s ease-out;
    transition: all var(--transition);
}
.toast-item.toast-success { border-left-color: #10b981; }
.toast-item.toast-danger { border-left-color: #ef4444; }
.toast-item.toast-warning { border-left-color: #f59e0b; }
.toast-item.toast-info { border-left-color: #06b6d4; }
.toast-item.toast-error { border-left-color: #ef4444; }

.toast-item i {
    font-size: 18px;
    flex-shrink: 0;
}
.toast-item.toast-success i { color: #10b981; }
.toast-item.toast-danger i,
.toast-item.toast-error i { color: #ef4444; }
.toast-item.toast-warning i { color: #f59e0b; }
.toast-item.toast-info i { color: #06b6d4; }

.toast-item .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 16px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity var(--transition);
}
.toast-item .toast-close:hover { opacity: 1; }

.toast-item.toast-out {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(60px); }
}

/* ── Login Page ── */
body.login-page {
    background: linear-gradient(135deg, #0f1b2d 0%, #1a3a5c 40%, #3b82f6 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

body.login-page::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(59,130,246,0.12);
    top: -150px;
    right: -100px;
    animation: loginFloat 6s ease-in-out infinite;
}
body.login-page::after {
    content: '';
    position: absolute;
    width: 350px;
    height: 350px;
    border-radius: 50%;
    background: rgba(16,185,129,0.08);
    bottom: -100px;
    left: -80px;
    animation: loginFloat 8s ease-in-out infinite reverse;
}

@keyframes loginFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(20px, -20px); }
}

.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
    position: relative;
    z-index: 1;
    animation: loginCardIn 0.5s ease-out;
}

@keyframes loginCardIn {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-header {
    background: var(--gradient-primary);
    padding: 32px 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.login-header::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--glass-bg);
    top: -40px;
    right: -20px;
}
.login-header::after {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--glass-bg);
    bottom: -30px;
    left: -10px;
}
.login-header img {
    width: 240px;
    height: 240px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255,255,255,0.15);
    padding: 10px;
    position: relative;
    z-index: 1;
}
.login-header h4 {
    color: #fff;
    font-weight: 700;
    margin: 12px 0 2px;
    font-size: 18px;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}
.login-header p {
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    margin: 0;
    position: relative;
    z-index: 1;
}

.login-body {
    padding: 28px 28px 32px;
}
.login-body .form-label {
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.login-body .btn-primary {
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    background: var(--gradient-primary);
    border: none;
}
.login-body .btn-primary:hover {
    box-shadow: 0 4px 15px rgba(59,130,246,0.4);
    transform: translateY(-1px);
}

/* ── Mobile Responsive ── */
.mobile-topbar {
    display: none;
}
.sidebar-overlay {
    display: none;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    .app-sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: none;
    }

    .app-content {
        margin-left: 0 !important;
    }
    body.sidebar-collapsed .app-content {
        margin-left: 0;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        background: var(--sidebar-bg);
        color: #fff;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 1030;
    }
    .mobile-topbar .mobile-toggle {
        background: none;
        border: none;
        color: #fff;
        font-size: 22px;
        padding: 4px 8px;
        cursor: pointer;
    }
    .mobile-topbar .mobile-brand {
        font-weight: 700;
        font-size: 15px;
        letter-spacing: 0.3px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1039;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.active {
        display: block;
    }

    .login-card { max-width: 90%; margin: 20px; }
}

@media (max-width: 575.98px) {
    .app-content > main { padding: 16px; }
    .card-body { padding: 16px; }
    .toast-container { left: 12px; right: 12px; }
    .toast-item { min-width: unset; }
}

/* ── Print Styles ── */
@media print {
    .app-sidebar,
    .mobile-topbar,
    .sidebar-toggle,
    .toast-container,
    .btn,
    .footer {
        display: none !important;
    }
    .app-content {
        margin-left: 0 !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
        break-inside: avoid;
    }
    .card.bg-primary, .card.bg-success, .card.bg-info,
    .card.bg-warning, .card.bg-danger, .card.bg-secondary {
        color: #000 !important;
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
    }
}

/* ── Preserve existing utilities ── */
.vehiculo-imagen {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.estado-activo { background-color: #10b981; }
.estado-inactivo { background-color: #64748b; }

/* Timeline */
.timeline {
    position: relative;
    padding-left: 30px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e2e8f0;
}
.timeline-item {
    position: relative;
    padding-bottom: 1rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent);
}

/* Spinner overlay */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Upload preview */
.upload-preview {
    max-width: 200px;
    max-height: 200px;
    margin-top: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
}

/* Action buttons */
.action-buttons .btn {
    margin-right: 0.25rem;
}
.action-buttons .btn:last-child {
    margin-right: 0;
}

/* Progress bars */
.progress {
    border-radius: 6px;
    background: #f1f5f9;
}
.progress-bar {
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

/* Modal improvements */
.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--card-border);
    padding: 16px 20px;
}
.modal-body {
    padding: 20px;
}

/* Card header color variants keep their colors */
.card-header.bg-danger { background-color: #ef4444 !important; border-radius: var(--radius) var(--radius) 0 0; }
.card-header.bg-warning { background-color: #f59e0b !important; border-radius: var(--radius) var(--radius) 0 0; }
.card-header.bg-success { background-color: #10b981 !important; border-radius: var(--radius) var(--radius) 0 0; }
.card-header.bg-primary { background-color: #3b82f6 !important; border-radius: var(--radius) var(--radius) 0 0; }
.card-header.bg-dark { background-color: #1e293b !important; border-radius: var(--radius) var(--radius) 0 0; }

/* Dropdown menus */
.dropdown-menu {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--card-border);
    padding: 6px;
}
.dropdown-item {
    border-radius: 6px;
    font-size: 13.5px;
    padding: 8px 12px;
}
.dropdown-item:hover {
    background: rgba(59,130,246,0.06);
}

/* Clickable dashboard cards */
.card-link-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}
.card-link-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
