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

:root {
    /* Paleta de Colores */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --dark: #0f172a;
    --light: #f8fafc;
    
    /* Efectos Glass */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --radius: 20px;
    
    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    /* Configuración Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f4f8;
    background-image: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%), 
                      radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--dark);
    overflow-x: hidden;
}

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

/* --- SIDEBAR (Configuración Final) --- */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px);
    color: #94a3b8;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    transition: transform 0.3s ease, width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    border-right: 1px solid rgba(255,255,255,0.05);
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

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

    /* Elementos a ocultar al contraer */
    .sidebar.collapsed .logo-text, 
    .sidebar.collapsed .nav-link span, 
    .sidebar.collapsed .badge,
    .sidebar.collapsed .section-title,
    .sidebar.collapsed .user-info {
        display: none !important;
        opacity: 0;
        pointer-events: none;
    }

    /* Ajuste de iconos al contraer */
    .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: 0;
    }
    .sidebar.collapsed #sidebarToggle {
        margin: 0 auto;
    }
}

/* Links del Menú */
.nav-link {
    color: #cbd5e1;
    white-space: nowrap; /* Evita saltos de línea */
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    transition: all 0.2s;
    margin-bottom: 4px;
}
.nav-link i {
    font-size: 1.25rem;
    margin-right: 12px;
    min-width: 24px; /* Para alinear bien */
}
.nav-link:hover, .nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: #64748b;
    margin: 1.5rem 0 0.5rem 1rem;
    display: block;
}

/* --- CONTENIDO PRINCIPAL --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}
.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* --- COMPONENTES UI --- */

/* Cards Modernas */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0,0,0,0.06); }

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 1.5rem;
    font-weight: 700;
}

/* Botones */
.btn-primary {
    background: var(--gradient-primary);
    border: none;
    border-radius: 50px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
    color: white;
}
.btn-primary:hover { 
    background: var(--primary-dark);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.5); 
    transform: translateY(-1px); 
    color: white;
}

/* Badges Soft */
.badge-soft { padding: 0.5em 1em; border-radius: 30px; font-weight: 600; letter-spacing: 0.5px; }
.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; }

/* Chat Widget */
.chat-widget {
    position: fixed; bottom: 30px; right: 30px;
    z-index: 2000;
}
.chat-btn {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s;
    border: none;
}
.chat-btn:hover { transform: scale(1.1); }

/* 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; 
    letter-spacing: 0.05em; 
    color: #64748b; 
}

/* --- RESPONSIVE --- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
    .sidebar.show { transform: translateX(0); }
    
    /* En móvil, el contenido siempre ocupa todo */
    .main-content, .main-content.expanded { margin-left: 0; padding: 1rem; }
    
    /* Mostrar toggle móvil */
    .mobile-toggle { display: block !important; }
    
    /* Ocultar toggle desktop */
    #sidebarToggle { display: none !important; }
}

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

/* Fondo oscuro cuando abres el menú en móvil */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999; /* Justo debajo del sidebar */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

@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;
}
