/* =========================================
   1. CONFIGURACIÓN Y VARIABLES
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* Paleta de Colores (Indigo & Slate Theme) */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Fondos y Textos */
    --dark: #0f172a;          /* Sidebar BG */
    --light: #f8fafc;         /* Body BG */
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* Dimensiones */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --radius: 16px;
    
    /* Efectos Glass & Sombras */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* =========================================
   2. ESTILOS BASE Y RESET
   ========================================= */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--light);
    /* Fondo sutil y moderno */
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%), 
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .navbar-brand, .brand-text {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

a { text-decoration: none; color: inherit; transition: color 0.2s; }

/* Scrollbar Personalizado */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* =========================================
   3. SIDEBAR (Barra Lateral)
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: #94a3b8;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
    border-right: 1px solid rgba(255,255,255,0.05);
}

/* Header del Sidebar */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo-text img { width: 32px; height: 32px; object-fit: contain; }
.logo-text span { font-size: 1.25rem; font-weight: 600; color: white; margin-left: 10px; }

/* Links de Navegación */
.nav-link {
    color: #cbd5e1;
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    margin-bottom: 4px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link i {
    font-size: 1.25rem;
    margin-right: 12px;
    min-width: 24px;
    text-align: center;
    transition: transform 0.2s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(4px);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-link:hover i, .nav-link.active i { transform: scale(1.1); }

/* Títulos de Sección */
.section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: #475569;
    margin: 1.5rem 0 0.5rem 1rem;
    display: block;
}

/* Info Usuario (Abajo) */
.user-info {
    background: rgba(255,255,255,0.03);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

/* Estado Sidebar Contraído (Solo Desktop) */
@media (min-width: 992px) { 
    .sidebar.collapsed { width: var(--sidebar-collapsed-width); }

    .sidebar.collapsed .logo-text span, 
    .sidebar.collapsed .nav-link span, 
    .sidebar.collapsed .badge,
    .sidebar.collapsed .section-title,
    .sidebar.collapsed .user-info div {
        display: none !important;
        opacity: 0;
        pointer-events: none;
    }

    .sidebar.collapsed .nav-link { justify-content: center; padding: 1rem 0; }
    .sidebar.collapsed .nav-link i { margin-right: 0; font-size: 1.5rem; }
    .sidebar.collapsed .sidebar-header { justify-content: center; padding-left: 0; padding-right: 0; }
    .sidebar.collapsed #sidebarToggle { margin: 0 auto; }
}

/* =========================================
   4. HEADER SUPERIOR & BARRA IMPERSONACIÓN
   ========================================= */

/* Barra de Impersonación (Admin viendo como User) */
.impersonation-bar {
    background: #18181b; color: white;
    padding: 0.5rem 1rem;
    border-bottom: 2px solid var(--warning);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(245, 158, 11, 0.1) 10px, rgba(245, 158, 11, 0.1) 20px);
    z-index: 1060;
    position: sticky; top: 0;
}

/* Header Glassmorphism */
.header-glass {
    background: rgba(248, 250, 252, 0.85); /* Semi-transparente */
    backdrop-filter: blur(12px);            /* Efecto cristal */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-top: 1.5rem !important;
    padding-bottom: 1rem !important;
    margin-top: -1rem; /* Ajuste negativo para pegar al borde superior */
    transition: all 0.3s ease;
}

/* Botón Móvil Moderno */
.btn-icon {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--dark);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    cursor: pointer;
}
.btn-icon:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.btn-icon:active { transform: scale(0.96); }

/* =========================================
   5. BUSCADOR MODERNO (Spotlight Style)
   ========================================= */
.modern-search-wrapper {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 6px 16px;
    display: flex; align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    transition: all 0.2s ease;
    cursor: text;
    width: 100%;
}
.modern-search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.modern-search-input {
    border: none; background: transparent;
    padding: 6px 0;
    font-size: 0.95rem; font-weight: 500;
    color: var(--dark);
    width: 100%; outline: none;
}
.modern-search-input:focus { box-shadow: none !important; background: transparent; }
.modern-search-input::placeholder { color: #94a3b8; font-weight: 400; }

.search-icon { color: #94a3b8; font-size: 1.1rem; margin-right: 12px; transition: color 0.2s; }
.modern-search-wrapper:focus-within .search-icon { color: var(--primary); }

/* Badge CTRL+K */
.shortcut-badge {
    display: flex; gap: 4px; align-items: center; margin-left: 10px;
}
.shortcut-badge span {
    background: #f1f5f9; border: 1px solid #cbd5e1;
    border-bottom-width: 2px; /* Efecto 3D */
    color: #64748b; border-radius: 5px;
    padding: 2px 6px; font-size: 0.7rem; font-weight: 700;
    min-width: 20px; text-align: center;
}

/* Resultados Dropdown Moderno */
#actionResults {
    margin-top: 8px !important;
    border: 1px solid rgba(0,0,0,0.05);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 16px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1) !important;
}
#actionResults .list-group-item {
    padding: 12px 16px;
    border: none; border-bottom: 1px solid #f1f5f9;
    background: transparent;
    transition: background 0.1s;
    display: flex; align-items: center; gap: 12px;
}
#actionResults .list-group-item:hover { background: #f8fafc; color: var(--primary); }
#actionResults .list-group-item i { color: #94a3b8; font-size: 1.1rem; }
#actionResults .list-group-item:hover i { color: var(--primary); }
#actionResults .list-group-item:last-child { border-bottom: none; }

/* =========================================
   6. CONTENIDO PRINCIPAL & COMPONENTES
   ========================================= */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

/* Cards */
.card {
    background: white;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover, .hover-lift:hover { 
    transform: translateY(-3px); 
    box-shadow: var(--shadow-lg); 
}
.card-header {
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

/* Botones */
.btn { border-radius: 50px; font-weight: 600; letter-spacing: 0.01em; }

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { 
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4); 
}

/* Tablas */
.table>:not(caption)>*>* { 
    background-color: transparent; 
    border-bottom-color: rgba(0,0,0,0.05); 
    padding: 1rem; 
    vertical-align: middle; 
}
.table thead th { 
    font-weight: 600; 
    text-transform: uppercase; 
    font-size: 0.75rem; 
    color: #64748b; 
    background-color: #f8fafc;
}

/* Badges Soft */
.badge { padding: 0.5em 0.8em; font-weight: 600; letter-spacing: 0.02em; }
.bg-soft-success { background: #dcfce7; color: #166534; }
.bg-soft-warning { background: #fef3c7; color: #92400e; }
.bg-soft-danger { background: #fee2e2; color: #991b1b; }
.bg-soft-primary { background: #e0e7ff; color: #3730a3; }

/* Login Page */
.login-logo { transition: transform 0.3s ease; }
.login-logo:hover { transform: scale(1.05); }

/* Animaciones */
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}
.animate-pulse { animation: pulse-red 2s infinite; }

/* =========================================
   7. RESPONSIVE (Móvil)
   ========================================= */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
    .sidebar.show { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,0.2); }
    
    .main-content, .main-content.expanded { margin-left: 0; padding: 1rem; }
    
    #sidebarToggle { display: none !important; }
    
    /* Backdrop oscuro */
    .sidebar-backdrop {
        position: fixed;
        top: 0; left: 0; width: 100vw; height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1999;
        opacity: 0; visibility: hidden;
        transition: opacity 0.3s ease;
    }
    .sidebar-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }
}
