/**
 * Mejoras visuales personalizadas
 * Mantiene la esencia del diseño original con refinamientos sutiles
 */

/* ============================================
   0. VARIABLES DE TEMA - COLORES DEL GRADIENTE
   ============================================ */
:root {
    /* Colores principales del gradiente */
    --theme-primary: #00c6fb ;           /* Púrpura claro */
    --theme-secondary: #005bea ;         /* Púrpura oscuro */
    
    /* Versiones hover (más oscuras) */
    --theme-primary-hover: #039ac4;     /* Púrpura claro hover */
    --theme-secondary-hover: #0048bb;   /* Púrpura oscuro hover */
    
    /* Versiones con transparencia para efectos sutiles */
    --theme-primary-alpha-10: rgba(102, 126, 234, 0.1);
    --theme-primary-alpha-15: rgba(102, 126, 234, 0.15);
    --theme-primary-alpha-20: rgba(102, 126, 234, 0.2);
    --theme-primary-alpha-30: rgba(102, 126, 234, 0.3);
    --theme-primary-alpha-80: rgba(102, 126, 234, 0.8);
    --theme-primary-alpha-95: rgba(102, 126, 234, 0.95);
    
    --theme-secondary-alpha-10: rgba(118, 75, 162, 0.1);
    --theme-secondary-alpha-15: rgba(118, 75, 162, 0.15);
    --theme-secondary-alpha-20: rgba(118, 75, 162, 0.2);
    --theme-secondary-alpha-80: rgba(118, 75, 162, 0.8);
    --theme-secondary-alpha-95: rgba(118, 75, 162, 0.95);
    
    /* Gradientes predefinidos */
    --gradient-primary: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    --gradient-primary-hover: linear-gradient(135deg, var(--theme-primary-hover) 0%, var(--theme-secondary-hover) 100%);
    --gradient-primary-alpha: linear-gradient(135deg, var(--theme-primary-alpha-10) 0%, var(--theme-secondary-alpha-10) 100%);
    --gradient-primary-strong: linear-gradient(135deg, var(--theme-primary-alpha-95) 0%, var(--theme-secondary-alpha-95) 100%);
    
    /* Gradiente para scrollbar y elementos pequeños */
    --gradient-accent: linear-gradient(90deg, var(--theme-primary) 0%, var(--theme-secondary) 50%, var(--theme-primary) 100%);
    
    /* Color de acento rojo para notificaciones/errores */
    --accent-danger: #ff4444;
    --accent-danger-light: #ff6b6b;
}

/* Variables para Dark Mode */
[data-bs-theme="dark"] {
    --theme-primary-alpha-10: rgba(102, 126, 234, 0.15);
    --theme-secondary-alpha-10: rgba(118, 75, 162, 0.15);
}

/* ============================================
   1. FOOTER STICKY AL FONDO
   ============================================ */
html {
    height: 100%;
}

body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.main-wrapper {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.main-wrapper .main-content {
    flex: 1;
}

.page-footer {
    flex-shrink: 0;
    padding: 1.25rem 1.5rem;
    /*background: var(--gradient-primary);*/
    color: #3d3838;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    margin-top: auto;
}

.page-footer p {
    margin: 0;
    font-size: 0.875rem;
    text-align: center;
}

.page-footer a {
    color: #3d3838;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 1px;
}

.page-footer a:hover {
    border-bottom-color: #ffffff;
    opacity: 0.9;
}

/* ============================================
   2. CARDS MEJORADAS
   ============================================ */
.card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-2px);
}

.card-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background-color: rgba(0, 0, 0, 0.02);
    font-weight: 500;
}

/* ============================================
   3. BOTONES MEJORADOS
   ============================================ */
.btn {
    transition: all 0.3s ease;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
}

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

.btn-outline-secondary:hover {
    transform: translateY(-1px);
}

/* ============================================
   4. TABLES MEJORADAS
   ============================================ */
.table {
    border-radius: 8px;
    overflow: hidden;
}

.table thead {
    background: var(--gradient-primary);
}

.table-striped tbody tr:hover {
    background-color: var(--theme-primary-alpha-10);
    transition: background-color 0.2s ease;
}

.tabla_base tbody tr {
    transition: all 0.2s ease;
}

.tabla_base tbody tr:hover {
    background-color: var(--theme-primary-alpha-10);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ============================================
   5. ALERTAS MEJORADAS
   ============================================ */
.alert {
    border-radius: 8px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideInDown 0.4s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   6. FORMS MEJORADOS
   ============================================ */
.form-control, .form-select {
    transition: all 0.3s ease;
    border: 1px solid #dee2e6;
}

.form-control:focus, .form-select:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem var(--theme-primary-alpha-15);
}

.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

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

/* ============================================
   7. BREADCRUMBS MEJORADOS
   ============================================ */
.page-breadcrumb {
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, var(--theme-primary-alpha-10), transparent);
    border-radius: 8px;
    padding-left: 1rem;
}

.breadcrumb-title {
    color: var(--theme-primary);
    font-weight: 600;
}

/* ============================================
   8. BADGES MEJORADOS
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 6px;
}

/* ============================================
   9. DROPDOWN MEJORADO
   ============================================ */
.dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: none;
    animation: slideDown 0.3s ease-out;
    z-index: 1050;
}

/* Dropdown de notificaciones con z-index más alto */
.dropdown-notify {
    z-index: 1060 !important;
    min-width: 350px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    transition: all 0.2s ease;
    padding: 0.6rem 1rem;
}

.dropdown-item:hover {
    background-color: var(--theme-primary-alpha-10);
    color: var(--theme-primary);
    transform: translateX(5px);
}

/* ============================================
   10. NAVBAR MEJORADO
   ============================================ */
.top-header {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1040;
}

/* Asegurar que dropdowns del navbar aparezcan encima del contenido */
.navbar .dropdown {
    position: relative;
    z-index: 1050;
}

.navbar .dropdown-menu {
    z-index: 1055 !important;
}

/* Notificación vacía con estilo mejorado */
.notify-list .text-center {
    padding: 2rem 1rem;
}

.notify-list .text-muted {
    font-size: 0.9rem;
}

/* ============================================
   11. SCROLLBAR PERSONALIZADA
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gradient-primary-hover);
}

/* ============================================
   12. LOADING STATES
   ============================================ */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   13. TOOLTIPS Y POPOVERS MEJORADOS
   ============================================ */
.tooltip-inner {
    background-color: #2d3748;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

/* ============================================
   14. SELECT2 MEJORADO
   ============================================ */
.select2-container--bootstrap-5 .select2-selection {
    border-color: #dee2e6;
    transition: all 0.3s ease;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem var(--theme-primary-alpha-15);
}

/* ============================================
   15. RESPONSIVE IMPROVEMENTS
   ============================================ */
@media (max-width: 768px) {
    .page-footer {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* ============================================
   16. DARK MODE SUPPORT
   ============================================ */
[data-bs-theme="dark"] .page-footer {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--theme-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .table-striped tbody tr:hover {
    background-color: var(--theme-primary-alpha-15);
}

[data-bs-theme="dark"] .card {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background-color: rgba(255, 255, 255, 0.02);
}

/* ============================================
   17. ANIMACIONES SUTILES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.main-content {
    animation: fadeIn 0.4s ease-in;
}

/* ============================================
   18. MEJORAS DE ACCESIBILIDAD
   ============================================ */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* ============================================
   19. ICONOS MATERIAL MEJORADOS
   ============================================ */
.material-icons-outlined {
    vertical-align: middle;
    transition: transform 0.2s ease;
}

.sharelink:hover .material-icons-outlined,
.btn:hover .material-icons-outlined {
    transform: scale(1.1);
}

/* ============================================
   20. SEPARADORES VISUALES
   ============================================ */
hr {
    opacity: 0.1;
    margin: 1.5rem 0;
}

/* ============================================
   21. SIDEBAR/MENU MEJORADO CON GRADIENTES
   ============================================ */

/* Menu item activo */
.metismenu .mm-active > a,
.metismenu a.mm-active {
    background: var(--gradient-primary) !important;
    color: #ffffff !important;
    box-shadow: 0 3px 10px var(--theme-primary-alpha-30);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

/* Efecto shine en menu activo */
.metismenu .mm-active > a::before,
.metismenu a.mm-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.metismenu .mm-active > a:hover::before,
.metismenu a.mm-active:hover::before {
    left: 100%;
}

/* Menu items hover */
.metismenu a {
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 2px 0;
}

.metismenu a:hover {
    background: var(--gradient-primary-alpha);
    transform: translateX(5px);
    padding-left: 1.2rem;
}

/* Parent icon con gradiente cuando está activo */
.metismenu .mm-active > a .parent-icon,
.metismenu a.mm-active .parent-icon {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 5px;
}

/* Submenu items */
.metismenu ul a {
    padding-left: 3rem;
}

.metismenu ul .mm-active > a {
    background: linear-gradient(135deg, var(--theme-primary-alpha-80) 0%, var(--theme-secondary-alpha-80) 100%) !important;
}

/* Menu labels */
.menu-label {
    color: var(--theme-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin-top: 1rem;
}

/* Sidebar header con gradiente sutil */
.sidebar-header {
    /*background: linear-gradient(135deg, var(--theme-primary-alpha-10) 0%, var(--theme-secondary-alpha-10) 100%);
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--theme-primary), var(--theme-secondary)) 1;*/
}

/* Logo name con color del tema */
.sidebar-header .logo-name h5 {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* Icono de menú con hover effect */
.metismenu .parent-icon i {
    transition: all 0.3s ease;
}

.metismenu a:hover .parent-icon i {
    transform: scale(1.1) rotate(5deg);
}

.metismenu .mm-active > a .parent-icon i {
    transform: scale(1.1);
}

/* Arrow indicator mejorado */
.metismenu .has-arrow::after {
    transition: all 0.3s ease;
}

.metismenu .mm-active.has-arrow::after {
    color: #ffffff;
}

/* Sidebar scrollbar */
.sidebar-wrapper::-webkit-scrollbar {
    width: 6px;
}

.sidebar-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar-wrapper::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 10px;
}

/* ============================================
   22. BREADCRUMB CON GRADIENTE
   ============================================ */
.page-breadcrumb .breadcrumb-title {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* ============================================
   23. TOP HEADER REFINADO
   ============================================ */
.top-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--theme-primary-alpha-10);
}

/* Selector de sector mejorado */
.search-bar .form-select {
    border: 2px solid var(--theme-primary-alpha-20);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.search-bar .form-select:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem var(--theme-primary-alpha-15);
}

/* Badge de notificaciones con gradiente */
.badge-notify {
    background: linear-gradient(135deg, var(--accent-danger) 0%, var(--accent-danger-light) 100%);
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.3);
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* ============================================
   24. PAGINACIÓN MEJORADA
   ============================================ */
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--gradient-primary) !important;
    border: none !important;
    color: white !important;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--gradient-primary-alpha) !important;
    border: none !important;
    color: var(--theme-primary) !important;
    border-radius: 6px;
}

/* ============================================
   25. DARK MODE - SIDEBAR
   ============================================ */
[data-bs-theme="dark"] .sidebar-header {
    background: var(--gradient-primary-alpha);
}

[data-bs-theme="dark"] .top-header {
    background: rgba(26, 32, 44, 0.98);
    border-bottom-color: var(--theme-primary-alpha-20);
}

[data-bs-theme="dark"] .metismenu a:hover {
    background: linear-gradient(135deg, var(--theme-primary-alpha-20) 0%, var(--theme-secondary-alpha-20) 100%);
}

/* ============================================
   26. TRANSICIONES SUAVES ENTRE PÁGINAS
   ============================================ */

/* Prevenir flash de contenido sin estilo */
html {
    background-color: #f8f9fa;
}

/* Overlay de transición */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary-strong);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.page-transition-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.page-transition-overlay .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

/* Animación de entrada del contenido */
.main-content {
    animation: pageEnter 0.4s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Prevenir que el sidebar y header parpadeen */
.sidebar-wrapper,
.top-header {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimización de renderizado */
.metismenu a,
.btn,
.card {
    will-change: transform, box-shadow;
    backface-visibility: hidden;
}

/* ============================================
   27. LOADER DE PÁGINA MEJORADO
   ============================================ */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--theme-primary-alpha-20);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s;
}

#page-loader.loading {
    opacity: 1;
}

#page-loader .progress-bar {
    height: 100%;
    background: var(--gradient-accent);
    background-size: 200% 100%;
    animation: loadingBar 1.5s ease-in-out infinite;
    width: 0%;
    transition: width 0.3s ease;
}

@keyframes loadingBar {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 200% 0%;
    }
}

/* ============================================
   28. MEJORA DE RENDIMIENTO
   ============================================ */

/* GPU acceleration para elementos animados */
.card:hover,
.btn:hover,
.metismenu a:hover {
    transform: translateZ(0);
}

/* Optimización de fuentes */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Reducir repaints */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   29. SKELETON LOADING (OPCIONAL)
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

[data-bs-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #2d3748 25%, #1a202c 50%, #2d3748 75%);
    background-size: 200% 100%;
}

/* ============================================
   GUÍA DE USO - VARIABLES CSS
   ============================================

   Este archivo usa CSS Custom Properties (variables CSS) para el esquema de colores.
   Todos los gradientes y colores del tema se controlan desde las variables en :root.

   📌 CÓMO CAMBIAR EL ESQUEMA DE COLORES:
   
   1. Edita las variables en la sección ":root" al inicio del archivo (líneas 9-44)
   
   2. Variables principales a cambiar:
      --theme-primary:        Color principal del gradiente (púrpura claro)
      --theme-secondary:      Color secundario del gradiente (púrpura oscuro)
      --theme-primary-hover:  Versión más oscura para hover
      --theme-secondary-hover: Versión más oscura para hover
   
   3. Las versiones alpha se calculan automáticamente desde las variables principales
      usando var(--theme-primary) y var(--theme-secondary)
   
   4. Los gradientes predefinidos se actualizan automáticamente:
      --gradient-primary:       Gradiente principal (botones, footer, menú activo)
      --gradient-primary-hover: Gradiente para estados hover
      --gradient-primary-alpha: Gradiente semi-transparente (hover sutil)
      --gradient-primary-strong: Gradiente casi opaco (overlays)
      --gradient-accent:        Gradiente animado (scrollbars, loaders)

   📌 EJEMPLO DE CAMBIO DE TEMA:

   Para cambiar a un tema azul/verde:
   
   :root {
       --theme-primary: #3b82f6;           // Azul
       --theme-secondary: #10b981;         // Verde
       --theme-primary-hover: #2563eb;     // Azul oscuro
       --theme-secondary-hover: #059669;   // Verde oscuro
   }

   Para cambiar a un tema rojo/naranja:
   
   :root {
       --theme-primary: #ef4444;           // Rojo
       --theme-secondary: #f59e0b;         // Naranja
       --theme-primary-hover: #dc2626;     // Rojo oscuro
       --theme-secondary-hover: #d97706;   // Naranja oscuro
   }

   📌 ELEMENTOS QUE USAN ESTAS VARIABLES:

   - Footer (background)
   - Botones primarios (background)
   - Headers de tablas (background)
   - Menú lateral activo (background)
   - Paginación activa (background)
   - Scrollbars (background)
   - Breadcrumb titles (color de texto con gradiente)
   - Logo del sidebar (color de texto con gradiente)
   - Focus states de formularios (border y shadow)
   - Checkboxes marcados (background)
   - Hover de dropdowns (background)
   - Hover de tablas (background)
   - Y muchos más elementos...

   📌 NOTAS IMPORTANTES:

   - NO necesitas actualizar las versiones alpha manualmente
   - Los gradientes se regeneran automáticamente al cambiar las variables principales
   - El dark mode ajusta automáticamente las transparencias
   - Todos los colores hardcodeados han sido reemplazados por variables
   - Si ves algún color hardcodeado (#667eea o #764ba2), repórtalo

   ============================================ */
