/**
 * Sistema de Diseño Visual de Auto Intelligence AI.
 * Inspirado en la estética minimalista de Vercel y Filament.
 * Soporta variables CSS para alternar entre Tema Claro y Tema Oscuro.
 */

/* ========================================================
   VARIABLES DE DISEÑO (TEMA CLARO POR DEFECTO)
   ======================================================== */
:root {
    --bg-main: #f8fafc;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-light: rgba(14, 165, 233, 0.1);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    
    --sidebar-width: 260px;
    --transition-speed: 0.25s;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
}

/* ========================================================
   SOBREESCRITURA DE VARIABLES PARA TEMA OSCURO
   ======================================================== */
[data-theme="dark"] {
    --bg-main: #090d16;
    --bg-sidebar: #0d121f;
    --bg-card: #111827;
    --border: #1f2937;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --primary-light: rgba(56, 189, 248, 0.15);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

/* ========================================================
   ESTILOS GENERALES Y ESTRUCTURA DE PÁGINA
   ======================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

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

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

/* ========================================================
   CONTENEDOR DE DISEÑO (SIDEBAR + MAIN CONTENT)
   ======================================================== */
.app-wrapper {
    display: flex;
    width: 100%;
}

/* Barra Lateral (Sidebar) */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: #f8fafc;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: 1px solid var(--border);
    transition: transform var(--transition-speed) ease;
}

.sidebar-brand {
    padding: 24px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.04em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-menu {
    list-style: none;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition-speed);
}

.sidebar-link:hover, .sidebar-link.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Contenido Principal (Main Area) */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    transition: margin var(--transition-speed) ease, width var(--transition-speed) ease;
}

/* Barra superior (Navbar) */
.navbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ========================================================
   COMPONENTES COMUNES DEL CONTENIDO
   ======================================================== */
.content-wrapper {
    padding: 30px;
    flex-grow: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

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

.page-title h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Tarjetas (Cards) */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 25px;
}

/* Grilla de Estadísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-info .stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 4px;
}

/* ========================================================
   FORMULARIOS Y ENTRADAS (FORMS)
   ======================================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    background-color: rgba(0,0,0,0.01);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-speed);
}

[data-theme="dark"] .form-control {
    background-color: rgba(255, 255, 255, 0.02);
}

select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

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

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--primary);
    color: #0b0f19;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    height: 42px;
}

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

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-danger {
    background-color: var(--error);
    color: #ffffff;
}

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

/* ========================================================
   ALERTAS Y AVISOS
   ======================================================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 25px;
    border: 1px solid transparent;
}

.alert-success {
    background-color: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.alert-error {
    background-color: var(--error-light);
    border-color: var(--error);
    color: var(--error);
}

/* ========================================================
   TABLAS Y SELECTORES
   ======================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.table th, .table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: rgba(0,0,0,0.01);
}

[data-theme="dark"] .table th {
    background-color: rgba(255,255,255,0.01);
}

/* Selector de Idiomas y Temas */
.lang-selector, .theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

/* ========================================================
   DISEÑO MÓVIL Y RESPONSIVO
   ======================================================== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .menu-toggle {
        display: block;
    }
}
