/* ============================================================
    💎 FLETES APP - PREMIUM DARK UI
    High-End Glassmorphism & Cyber Aesthetics
============================================================ */

:root {
    /* 🌑 Core Palette - PREMIUM DARK */
    --bg-main: #0f172a;
    /* Slate 950 */
    --bg-secondary: #1e293b;
    /* Slate 800 */

    /* 🎨 Accents */
    --primary: #3b82f6;
    /* Blue 500 */
    --primary-hover: #2563eb;
    /* Blue 600 */
    --primary-glow: rgba(59, 130, 246, 0.5);

    --secondary: #10b981;
    /* Emerald 500 */
    --warning: #f59e0b;
    /* Amber 500 */
    --danger: #ef4444;
    /* Red 500 */
    --info: #06b6d4;
    /* Cyan 500 */

    /* 🌫️ Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --backdrop-blur: blur(12px);

    /* 🔤 Typography */
    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --font-family: 'Inter', system-ui, sans-serif;

    --transition: 0.3s ease;
    --sidebar-width: 260px;

    /* 📊 Tables */
    --table-head-bg: rgba(30, 41, 59, 0.8);

    /* ⌨️ Inputs */
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-focus-bg: #1e293b;

    /* 🌈 Gradient Text Colors */
    --title-gradient-end: #ffffff;
    /* Fades to white in Dark Mode */
}

html[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-secondary: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.08);
    --input-bg: #ffffff;
    --input-focus-bg: #fdfdfd;
    --table-head-bg: #f1f5f9;

    /* 🌈 Gradient Text Colors */
    --title-gradient-end: #334155;
    /* Fades to dark slate in Light Mode */
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
}

/* ============================================================
    ✨ GLASS COMPONENTS
============================================================ */
.glass-card,
.glass-sidebar,
.glass-header,
.modal-glass {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-card {
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    transition: transform 0.3s ease;
}

/* ============================================================
    🟢 SIDEBAR
============================================================ */
.sidebar {
    position: fixed;
    width: var(--sidebar-width);
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-img {
    width: 40px;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.4));
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.nav-links {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, transparent 100%);
    border-left: 3px solid var(--primary);
    color: var(--primary);
}

.sidebar-footer {
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.actions {
    display: flex;
    justify-content: space-around;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

/* Timer Progress Bar */
.swal2-timer-progress-bar {
    background: var(--primary) !important;
}

/* PDF Configuration Form - Custom Styles */
.pdf-config-form {
    text-align: left !important;
    padding: 0 !important;
    margin: 0 !important;
}

.pdf-config-form label {
    display: block !important;
    margin-bottom: 8px !important;
    margin-top: 16px !important;
    font-weight: 600 !important;
    color: var(--text-main) !important;
    font-family: var(--font-family) !important;
    font-size: 0.9rem !important;
}

.pdf-config-form label:first-child {
    margin-top: 0 !important;
}

.pdf-config-form .swal2-input {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 8px 0 !important;
    box-sizing: border-box !important;
}

/* Ensure buttons are same height and aligned */
.swal2-actions:not(.swal2-loading) .swal2-styled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Fix button container alignment */
.swal2-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    /* Espaciado saludable */
}

/* Hide deny button explicitly if needed, but let JS control it usually */
/* .swal2-deny { display: none; } */

/* Center text in PDF config form */
.pdf-config-form {
    text-align: center !important;
}

.pdf-config-form label {
    text-align: center !important;
}

/* Textarea styling for adicionales */
textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 60px;
    transition: 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: var(--input-focus-bg);
}

textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

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

/* Theme Switch */
.theme-switch-wrapper {
    display: flex;
    justify-content: center;
}

.theme-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

.theme-switch input {
    display: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    border-radius: 34px;
    transition: 0.4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 3px;
    background-color: var(--primary);
    border-radius: 50%;
    transition: 0.4s;
}

input:checked+.slider:before {
    transform: translateX(30px);
}

.sun-icon {
    color: #f59e0b;
    font-size: 14px;
}

.moon-icon {
    color: #f8fafc;
    font-size: 14px;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--danger);
    font-weight: 600;
    padding: 10px;
    border-radius: 8px;
    transition: 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================================
    🔵 MAIN CONTENT
============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    width: calc(100% - var(--sidebar-width));
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 16px 24px;
    border-radius: 16px;
    position: relative;
    /* Allow absolute positioning inside if needed */
}

.menu-btn {
    display: none;
    /* Mobile only */
    font-size: 1.5rem;
    color: var(--text-main);
    background: transparent;
}

#pageTitle {
    font-size: 1.5rem;
    /* Adjusted for better fit */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -1px;
    background: linear-gradient(to right, var(--primary), var(--title-gradient-end));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    margin: 0;
    flex-grow: 1;
    /* Allow it to take space */
    text-align: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    /* Box Styling */
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 16px;
    /* Inner spacing */
    border-radius: 12px;
    /* Smooth corners */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    margin-left: auto;
    /* Push to right just in case */
    z-index: 10;
}

.badge {
    background: rgba(249, 115, 22, 0.1);
    /* Orange-ish base */
    color: #f97316;
    /* Orange color */
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid rgba(249, 115, 22, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.05);
}

#companyBadge {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border-color: rgba(249, 115, 22, 0.3);
    font-weight: 800;
    font-size: 0.85rem;
}

#userRoleBadge {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border-color: var(--glass-border);
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary);
}

/* ============================================================
    📊 DASHBOARD GRID & KPI
============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 20px;
    border-left: 4px solid var(--primary);
}

.kpi-icon {
    font-size: 2.5rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 12px;
    border-radius: 12px;
}

.kpi-info h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
}

/* ============================================================
    📝 FORMS
============================================================ */
.card-header {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 16px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

input,
select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: var(--input-focus-bg);
}

/* Special Inputs */
.money-input {
    color: var(--secondary);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.input-total {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 800;
    font-size: 1.1rem;
    text-align: right;
}

.input-readonly {
    background: var(--input-bg);
    opacity: 0.8;
    cursor: default;
}

.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-excel {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
}

.btn-excel:hover {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.btn-pdf {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
}

.btn-pdf:hover {
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}

.btn-primary.btn-glow {
    box-shadow: 0 0 20px var(--primary-glow);
}

/* CHECKBOX LIST UI */
.select-checkbox-container {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    height: 100px;
    /* Reducido para ser más compacto */
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-main);
    font-size: 0.9rem;
    user-select: none;
}

.checkbox-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

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

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================================
    📅 TABLES & FILTERS
============================================================ */
.flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filters input,
.filters select {
    padding: 8px 12px;
    font-size: 0.9rem;
    width: auto;
}

.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-top: 16px;
}

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

thead th {
    background: var(--table-head-bg);
    text-align: left;
    padding: 16px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

tbody td {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
    color: var(--text-main);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.price-cell {
    font-weight: 700;
    color: var(--secondary);
}

.badge-plate {
    background: #fbbf24;
    color: #000;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    border: 2px solid #000;
    font-family: monospace;
}

.actions-col {
    width: 100px;
    text-align: center;
}

.btn-icon {
    padding: 6px;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-icon.edit:hover {
    color: var(--primary);
}

.btn-icon.delete:hover {
    color: var(--danger);
}

/* ============================================================
    📊 CHARTS
============================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    /* Important for Chart.js */
    width: 100%;
}

/* ============================================================
    🛑 MODALS
============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    /* JS toggles class 'visible' */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.3s;
}

.modal-overlay.visible {
    display: flex;
    opacity: 1;
}

.modal-glass {
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 0;
    /* Header/Body/Footer handle padding */
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.close-btn {
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 4px;
    background: transparent;
}

.close-btn:hover {
    color: var(--danger);
}

/* ============================================================
    📱 RESPONSIVE
============================================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 24px;
    }

    .topbar {
        flex-direction: row;
        /* Keep row but maybe wrap if tight */
        padding: 12px 16px;
    }

    #pageTitle {
        position: static;
        /* No longer absolute centered */
        transform: none;
        font-size: 1.2rem;
        /* Smaller */
        text-align: center;
        flex: 1;
        /* Take available space */
    }

    .menu-btn {
        display: block;
        margin-right: 12px;
    }

    .user-profile {
        padding: 4px 8px;
        gap: 8px;
    }

    .badget {
        font-size: 0.75rem;
        padding: 2px 8px;
    }

    .avatar {
        width: 32px;
        height: 32px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    .menu-btn {
        display: block;
        margin-right: 12px;
    }

    .filters {
        width: 100%;
        flex-direction: column;
    }

    .filters input,
    .filters select {
        width: 100%;
    }
}

/* Utils */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.tab-content {
    display: none;
}

.tab-content.visible {
    display: block;
}

/* Login Page Extras */
.login-card {
    text-align: center;
    max-width: 400px;
    margin: auto;
}