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

:root {
    /* Paleta Claro y Limpio (Premium) */
    --bg-color: #f4f7fa; 
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    --border-color: #e2e8f0;
    --border-focus: #93c5fd;
    
    /* Sombras Elegantes */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 9999px;
}

[data-theme="dark"] {
    --bg-color: #0f172a; 
    --sidebar-bg: #1e293b;
    --card-bg: #1e293b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;
    
    --primary: #38bdf8;
    --primary-hover: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.1);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    
    --border-color: #334155;
    --border-focus: #7dd3fc;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.8), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* Loader */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    z-index: 9999;
}
.loader {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
    margin-bottom: 20px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Layout SaaS */
#panel-admin {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Limpio y Claro */
.sidebar {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}
.sidebar-header {
    padding: 30px 20px 20px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-header .logo {
    max-width: 180px;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    margin-bottom: 15px;
}
.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.sidebar-nav button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 20px;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-nav button:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}
.sidebar-nav button.activa {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.plan-badge {
    display: inline-block;
    padding: 6px 14px;
    background: var(--success-light);
    color: var(--success);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    min-width: 0;
}
.main-header {
    background: var(--card-bg);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 5;
}
.main-header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-main);
}
#saludo-usuario {
    font-weight: 500;
    color: var(--text-muted);
}

/* Dashboard Containers & Grid */
.admin-container {
    padding: 40px;
    animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.admin-container h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--text-main);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}
.dashboard-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.02);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}
.dashboard-card h3 {
    margin: 0 0 15px 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.big-number {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    line-height: 1;
}

/* Tablas Modernas */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 15px;
}
th {
    padding: 15px;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }

td {
    padding: 15px;
    color: var(--text-main);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    background-color: var(--bg-color);
}

/* Badges de Estado */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }

/* Formularios Elegantes */
input[type="text"], 
input[type="number"], 
input[type="email"], 
input[type="file"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: #fff;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: all 0.2s ease;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Botones */
.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}
.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}
.btn:active {
    transform: translateY(0);
}
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover {
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: none;
}

/* Botón Destructivo/Eliminar */
.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    padding: 8px 12px;
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Gráficas Container */
.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
    margin-top: 20px;
    min-width: 0;
}

/* Selectores pequeños en tablas */
td select {
    margin-bottom: 0;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    width: auto;
    cursor: pointer;
}
td select:focus {
    box-shadow: 0 0 0 2px var(--border-focus);
}

/* Modales */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(15, 23, 42, 0.6); 
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    box-shadow: var(--shadow-hover);
    animation: slideUp 0.3s ease-out;
    overflow: hidden;
}

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

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

/* Layouts Especiales (Dashboard, SaaS) */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

/* Pricing Cards */
.pricing-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}
.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}
.pricing-card.popular {
    border: 2px solid var(--primary);
    box-shadow: var(--shadow-md);
}
.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.pricing-card h3 {
    margin: 0 0 15px 0;
    font-size: 1.4rem;
    color: var(--text-main);
}
.pricing-card .price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 25px;
}
.pricing-card .price span {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}
.features-list {
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
    text-align: left;
    flex-grow: 1;
}
.features-list li {
    margin-bottom: 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-row {
    grid-template-columns: 2fr 1fr;
    margin-top: 30px;
}
.dashboard-card > div[style*="overflow-x"] {
    max-width: 100%;
    min-width: 0;
}

/* Responsividad Móvil */
@media (max-width: 768px) {
    #panel-admin {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        gap: 10px;
    }
    
    .sidebar-nav button {
        white-space: nowrap;
        padding: 8px 12px;
    }
    
    .main-header {
        padding: 15px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .admin-container {
        padding: 15px;
        min-width: 0;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    
    .chart-row {
        grid-template-columns: 1fr !important;
    }
    
    .flota-form-grid {
        grid-template-columns: 1fr !important;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Para que el modal de mantenimiento se apile */
    #modal-mantenimiento .modal-content > div:nth-child(2) {
        grid-template-columns: 1fr !important;
    }
}
