/* =========================================
   IMPORTACIÓN DE FUENTES
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =========================================
   VARIABLES DE COLOR (MODO CLARO)
   ========================================= */
:root {
    --bg-color: #f3f4f6;
    --container-bg: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --border-color: #e5e7eb;
    --input-bg: #f9fafb;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
}

/* =========================================
   VARIABLES DE COLOR (MODO OSCURO)
   ========================================= */
[data-theme="dark"] {
    --bg-color: #111827;
    --container-bg: #1f2937;
    --text-color: #f9fafb;
    --text-muted: #9ca3af;
    --primary-color: #6366f1;
    --primary-hover: #818cf8;
    --border-color: #374151;
    --input-bg: #374151;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* =========================================
   ESTILOS GENERALES Y RESET
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =========================================
   ESTILOS DEL LOGIN / AUTH
   ========================================= */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    background-color: var(--container-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =========================================
   FORMULARIOS
   ========================================= */
.form-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* =========================================
   BOTONES
   ========================================= */
.btn {
    display: inline-block;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-info { background-color: #3b82f6; color: white; }
.btn-info:hover { background-color: #2563eb; }

.btn-danger { background-color: #ef4444; color: white; }
.btn-danger:hover { background-color: #dc2626; }

.btn-secondary { background-color: var(--text-muted); color: white; margin-top: 0.5rem; }
.btn-secondary:hover { background-color: #4b5563; }

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    width: auto;
}

/* Botón flotante para el Tema (Solo Login) */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    font-size: 1.2rem;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* =========================================
   ESTILOS DEL DASHBOARD (PANEL ADMIN)
   ========================================= */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* Overlay oscuro para móviles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Sidebar (Menú Lateral) */
.sidebar {
    width: 260px;
    background-color: var(--container-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.03);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-sidebar-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-menu {
    list-style: none;
    padding: 1.5rem 0;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    gap: 1rem;
    margin: 0 1rem 0.5rem 1rem;
    border-radius: 0.5rem;
}

.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    transform: translateX(5px);
}

/* Contenido Principal */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    min-width: 0;
}

/* Topbar */
.topbar {
    height: 70px;
    background-color: var(--container-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.menu-toggle:hover {
    color: var(--primary-color);
}

.topbar .theme-toggle {
    position: relative;
    top: auto;
    right: auto;
    width: 40px;
    height: 40px;
}

.user-info {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
}

.content {
    padding: 2rem;
}

.content-header {
    margin-bottom: 2.5rem;
}

/* Tarjetas de Estadísticas (Premium) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--container-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.05));
    transform: skewX(-15deg) translateX(50px);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px -5px rgba(0, 0, 0, 0.1);
}

.stat-card i {
    font-size: 2.2rem;
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.stat-card p {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
}

/* =========================================
   DISEÑO INTERIOR: TARJETAS, TABLAS Y GRID
   ========================================= */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--container-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
}

.dashboard-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.8rem;
}

/* Cabecera de Tabla y Buscador Vivo Premium */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 350px;
}

.search-box i {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: var(--transition);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3.2rem;
    border: 2px solid transparent;
    border-radius: 2rem;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    outline: none;
}

.search-box:focus-within input {
    border-color: var(--primary-color);
    background-color: var(--container-bg);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.search-box:focus-within i {
    color: var(--primary-color);
}

/* Tabla de Datos */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.data-table th {
    background-color: rgba(79, 70, 229, 0.05);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.data-table tr:hover td {
    background-color: rgba(79, 70, 229, 0.02);
}

/* =========================================
   MEDIA QUERIES (RESPONSIVE)
   ========================================= */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        height: 100vh;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }
    
    .close-sidebar-btn {
        display: block;
    }

    .content {
        padding: 1.5rem;
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
    }
}