/**
 * Estilos Globales de la Aplicación
 * 
 * Este archivo contiene todos los estilos base de la aplicacion:
 * - Variables CSS (custom properties) para el tema de colores
 * - Reset y estilos base
 * - Layout principal (sidebar + contenido)
 * - Componentes reutilizables (cards, botones, badges, etc.)
 * - Animaciones y transiciones
 * - Responsividad (mobile-first)
 */

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

/* 
   VARIABLES CSS (Custom Properties)
*/
:root {
    /* --- Colores Primarios --- */
    --primary: #4F46E5;           /* Índigo profundo - color principal */
    --primary-hover: #6366F1;     /* Índigo más claro - hover */
    --primary-light: #818CF8;     /* Índigo suave - acentos */
    --primary-dark: #3730A3;      /* Índigo oscuro - bordes activos */
    --primary-rgb: 79, 70, 229;   /* RGB para opacidades dinámicas */
    --primary-glow: rgba(79, 70, 229, 0.4); /* Resplandor para sombras */

    /* --- Colores Semánticos --- */
    --success: #10B981;           /* Esmeralda - éxito, confirmación */
    --success-hover: #059669;
    --success-light: #D1FAE5;
    --warning: #F59E0B;           /* Ámbar - advertencia */
    --warning-hover: #D97706;
    --warning-light: #FEF3C7;
    --danger: #EF4444;            /* Rojo rosado - error, eliminar */
    --danger-hover: #DC2626;
    --danger-light: #FEE2E2;
    --info: #3B82F6;              /* Azul - información */
    --info-hover: #2563EB;
    --info-light: #DBEAFE;

    /* --- Fondos (Tema Oscuro) --- */
    --bg-body: #0B1120;           /* Fondo principal más oscuro */
    --bg-sidebar: #111827;        /* Fondo del sidebar */
    --bg-card: #1E293B;           /* Fondo de cards */
    --bg-card-hover: #263548;     /* Card al hacer hover */
    --bg-input: #0F172A;          /* Fondo de inputs */
    --bg-input-focus: #1E293B;    /* Input enfocado */
    --bg-dropdown: #1E293B;       /* Fondos de menús desplegables */
    --bg-modal: #1E293B;          /* Fondo de modales */
    --bg-glass: rgba(30, 41, 59, 0.7); /* Glassmorphism */

    /* --- Textos --- */
    --text-primary: #F1F5F9;      /* Texto principal (claro sobre oscuro) */
    --text-secondary: #94A3B8;    /* Texto secundario / muted */
    --text-muted: #64748B;        /* Texto muy tenue */
    --text-inverse: #0F172A;      /* Texto sobre fondo claro */

    /* --- Bordes --- */
    --border-color: #334155;      /* Borde estándar */
    --border-light: #475569;      /* Borde más visible */
    --border-focus: var(--primary); /* Borde en foco */

    /* --- Espaciado --- */
    --sidebar-width: 260px;       /* Ancho del sidebar expandido */
    --sidebar-collapsed: 72px;    /* Ancho del sidebar colapsado */
    --navbar-height: 64px;        /* Altura de la barra superior */
    --content-padding: 24px;      /* Padding del área de contenido */

    /* --- Bordes redondeados --- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;        /* Completamente redondo (pills) */

    /* --- Sombras --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--primary-glow);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);

    /* --- Transiciones --- */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* --- Z-Index --- */
    --z-sidebar: 1000;
    --z-navbar: 1001;
    --z-dropdown: 1050;
    --z-modal: 1060;
    --z-toast: 1090;
}

/* RESET Y ESTILOS BASE */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Links --- */
a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

/* --- Imágenes --- */
img {
    max-width: 100%;
    height: auto;
}

/* --- Listas --- */
ul, ol {
    list-style: none;
}

/* --- Scrollbar personalizada (tema oscuro) --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}


/* --- Contenedor principal de la app --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/*SIDEBAR*/
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: width var(--transition-slow);
    overflow: hidden;
}

/* --- Logo y marca en la parte superior del sidebar --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--navbar-height);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-brand:hover {
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand .brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .brand-text span {
    color: var(--primary-light);
}

/* --- Navegación del sidebar --- */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav .nav-section {
    margin-bottom: 24px;
}

.sidebar-nav .nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
    white-space: nowrap;
}

.sidebar-nav .nav-item {
    margin-bottom: 2px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.sidebar-nav .nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.sidebar-nav .nav-link:hover i {
    color: var(--primary-light);
}

/* --- Link activo (página actual) --- */
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(99, 102, 241, 0.1));
    color: var(--primary-light);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

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

/* Indicador lateral del link activo */
.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

/* --- Badge en los items del menú (ej: contadores) --- */
.sidebar-nav .nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

/* --- Pie del sidebar (usuario, cerrar sesión) --- */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--info));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-user .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* CONTENIDO PRINCIPAL*/
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-slow);
}

/*NAVBAR (Barra superior)*/
.navbar {
    position: sticky;
    top: 0;
    height: var(--navbar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--content-padding);
    z-index: var(--z-navbar);
}

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

/* Botón hamburguesa para mobile y colapsar sidebar */
.navbar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: none; /* Visible solo en mobile */
}

.navbar-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-title .page-subtitle {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 8px;
}

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

/* Botones de acción en la navbar */
.navbar-action {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.navbar-action:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* Punto de notificación */
.navbar-action .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-sidebar);
}

/* AREA DE CONTENIDO DE PÁGINA */
.page-content {
    flex: 1;
    padding: var(--content-padding);
}

/* Cabecera de página (título + acciones) */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header h1 small {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 8px;
}

/* CARDS (Tarjetas) */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-card);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Card con efecto glassmorphism --- */
.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Card de estadística (dashboard) --- */
.stat-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card .stat-icon.icon-primary {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-light);
}

.stat-card .stat-icon.icon-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-card .stat-icon.icon-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-card .stat-icon.icon-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-card .stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.stat-card .stat-change.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-card .stat-change.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Decoración de fondo en stat cards */
.stat-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-full);
    opacity: 0.05;
    transition: opacity var(--transition-base);
}

.stat-card:hover::after {
    opacity: 0.1;
}

.stat-card .stat-icon.icon-primary ~ .stat-value ~ .stat-label ~ .stat-change,
.stat-card:has(.icon-primary)::after {
    background: var(--primary);
}

/* BOTONES */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

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

/* Efecto ripple al hacer click */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
    opacity: 0;
}

.btn:active::after {
    width: 200px;
    height: 200px;
    opacity: 1;
    transition: 0s;
}

/* --- Variantes de botón --- */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-light));
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), var(--warning-hover));
    color: var(--text-inverse);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
    color: var(--text-inverse);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), var(--danger-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
    color: #fff;
}

/* Botón outline (borde sin fondo) */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary-light);
}

.btn-outline-primary:hover {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-light);
}

/* Botón ghost (sin borde ni fondo) */
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* Tamaños de botón */
.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    padding: 8px;
    width: 40px;
    height: 40px;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
    padding: 6px;
}

/* FORMULARIOS (Inputs, selects, etc.)*/
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.invalid-feedback {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.form-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Select personalizado */
.form-select {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-input) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394A3B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") no-repeat right 12px center / 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
    transition: all var(--transition-fast);
    padding-right: 36px;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Checkbox y Radio personalizados */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    position: relative;
}

.form-check-input[type="radio"] {
    border-radius: var(--radius-full);
}

.form-check-input:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.form-check-input:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.form-check-input[type="checkbox"]:checked::after {
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.form-check-input[type="radio"]:checked::after {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: #fff;
}

.form-check-label {
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Switch toggle */
.form-switch .form-check-input {
    width: 40px;
    height: 22px;
    border-radius: var(--radius-full);
    position: relative;
}

.form-switch .form-check-input::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    transition: all var(--transition-fast);
}

.form-switch .form-check-input:checked::after {
    background: #fff;
    left: calc(100% - 16px);
    transform: none;
    width: 14px;
    height: 14px;
    border: none;
}

/* TABLAS */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* BADGES (Etiquetas de estado) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-light);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.badge-muted {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* Badge con punto de color */
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
}

/* ALERTAS (Mensajes flash) */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
    border: 1px solid transparent;
}

.alert i {
    font-size: 18px;
    margin-top: 1px;
    flex-shrink: 0;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.2);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: opacity var(--transition-fast);
}

.alert-close:hover {
    opacity: 1;
}

/* MODALES */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: var(--bg-modal);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal-dialog {
    transform: scale(1) translateY(0);
}

/* DROPDOWNs */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-dropdown);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    padding: 6px;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.dropdown-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.dropdown-item.text-danger {
    color: var(--danger);
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* EMPTY STATE (cuando no hay datos) */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state .empty-icon {
    font-size: 56px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto 20px;
}

/* LOADING SPINNER */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid currentColor;
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 17, 32, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 9999;
}

.loading-overlay .spinner {
    color: var(--primary-light);
}

.loading-overlay span {
    color: var(--text-secondary);
    font-size: 14px;
}

/* TOOLTIP */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    z-index: var(--z-toast);
}

[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* AVATAR */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }

/* Gradientes aleatorios para avatares */
.avatar-1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.avatar-2 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.avatar-3 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.avatar-4 { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.avatar-5 { background: linear-gradient(135deg, #fa709a, #fee140); }
.avatar-6 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }

/* GRID HELPERS */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* UTILIDADES */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary-light) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mb-4 { margin-bottom: 32px !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.d-none { display: none; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }
.overflow-hidden { overflow: hidden; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }

/* ANIMACIONES */

/* Entrada desde arriba */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Entrada desde abajo */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade in */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Pulse suave (para notificaciones) */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Rotación (para spinners) */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Shake (para errores de validación) */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Scale bounce (para elementos que aparecen) */
@keyframes scaleBounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

/* Clases de animación reutilizables */
.animate-slide-down { animation: slideDown 0.3s ease; }
.animate-slide-up { animation: slideUp 0.3s ease; }
.animate-fade-in { animation: fadeIn 0.4s ease; }
.animate-scale { animation: scaleBounce 0.4s ease; }
.animate-shake { animation: shake 0.5s ease; }

/* Animación escalonada para listas */
.stagger-item {
    opacity: 0;
    animation: slideUp 0.4s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.4s; }

/* PÁGINA DE LOGIN */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-body);
    position: relative;
    overflow: hidden;
}

/* Fondo decorativo para la página de login */
.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        ellipse at 30% 20%,
        rgba(79, 70, 229, 0.08) 0%,
        transparent 50%
    ),
    radial-gradient(
        ellipse at 70% 80%,
        rgba(99, 102, 241, 0.06) 0%,
        transparent 50%
    );
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, -2%) rotate(1deg); }
    66% { transform: translate(-1%, 1%) rotate(-0.5deg); }
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
    animation: scaleBounce 0.5s ease;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: var(--shadow-glow);
}

.auth-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-logo p {
    font-size: 14px;
    color: var(--text-muted);
}

/* RESPONSIVIDAD */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (menos de 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
        --content-padding: 16px;
    }

    /* Sidebar se oculta y se muestra como overlay */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    /* Overlay cuando el sidebar está abierto en mobile */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-sidebar) - 1);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .main-content {
        margin-left: 0;
    }

    .navbar-toggle {
        display: flex;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .auth-card {
        padding: 28px 20px;
    }

    /* Tablas responsivas: scroll horizontal */
    .table-container {
        margin: 0 calc(var(--content-padding) * -1);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* Pantallas pequeñas (menos de 480px) */
@media (max-width: 480px) {
    .page-header h1 {
        font-size: 20px;
    }

    .stat-card .stat-value {
        font-size: 26px;
    }
}

/* PERSONALIZACIÓN DE SWEETALERT2 (tema oscuro) */
.swal2-popup {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
}

.swal2-title {
    color: var(--text-primary) !important;
}

.swal2-html-container {
    color: var(--text-secondary) !important;
}

.swal2-confirm {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
}

.swal2-cancel {
    background: transparent !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    border-radius: var(--radius-md) !important;
}

.swal2-cancel:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* PERSONALIZACIÓN DE DATATABLES (tema oscuro) */
.dataTables_wrapper {
    color: var(--text-secondary);
    font-size: 13px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    outline: none;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    background: transparent !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-light) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_info {
    color: var(--text-muted);
}
