/* =====================================
   HELP CENTER - Estilos Completos
   Centro de Ayuda Interactivo con Efecto Libro 3D
   ===================================== */

/* =====================================
   VARIABLES CSS - Integradas con el sistema de temas
   ===================================== */
:root {
    /* Colores usando variables del tema existente */
    --help-primary: #0066cc;
    --help-primary-hover: #0052a3;
    --help-secondary: #f39c12;
    --help-success: #27ae60;
    --help-danger: #e74c3c;

    /* Colores de texto y fondo usando variables del sistema */
    --help-text-primary: var(--text-primary);
    --help-text-secondary: var(--text-secondary);
    --help-text-muted: var(--text-muted);
    --help-bg-primary: var(--bg-primary);
    --help-bg-secondary: var(--bg-secondary);

    /* Efectos de cristal */
    --help-glass: var(--glass);
    --help-glass-dark: var(--glass-dark);

    /* Sombras usando variables del sistema */
    --help-shadow-sm: 0 2px 8px var(--shadow-light);
    --help-shadow-md: 0 4px 16px var(--shadow-medium);
    --help-shadow-lg: 0 8px 32px var(--shadow-medium);
    --help-shadow-xl: 0 16px 48px var(--shadow-medium);

    /* Overlay y bordes */
    --help-overlay-bg: rgba(0, 0, 0, 0.6);
    --help-border-color: rgba(0, 0, 0, 0.1);
    --help-border-color-light: rgba(0, 0, 0, 0.05);

    /* Colores para elementos específicos (libro, etc) */
    --help-book-bg: linear-gradient(135deg, #fefefe 0%, #f8f9fa 100%);
    --help-book-border: #e0e0e0;
    --help-book-shadow: rgba(0, 0, 0, 0.2);
    --help-tip-bg: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    --help-tip-text: #856404;
    --help-tip-text-strong: #664d03;

    /* Transiciones */
    --help-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --help-transition-fast: all 0.15s ease;
    --help-border-radius: 12px;
    --help-border-radius-sm: 8px;
}

/* Tema oscuro - usando el selector correcto del sitio */
[data-bs-theme="oscuro"] {
    /* Ajustes para el botón en tema oscuro */
    --help-primary: #60A5FA;
    --help-primary-hover: #3B82F6;

    /* Overlay más oscuro */
    --help-overlay-bg: rgba(0, 0, 0, 0.85);

    /* Bordes más claros para dark mode */
    --help-border-color: rgba(255, 255, 255, 0.15);
    --help-border-color-light: rgba(255, 255, 255, 0.08);

    /* Libro con fondo oscuro adaptado al tema del sitio */
    --help-book-bg: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    --help-book-border: rgba(255, 255, 255, 0.1);
    --help-book-shadow: rgba(0, 0, 0, 0.6);

    /* Tip con colores adaptados al tema oscuro */
    --help-tip-bg: linear-gradient(135deg, rgba(252, 211, 77, 0.15) 0%, rgba(251, 191, 36, 0.15) 100%);
    --help-tip-text: #FCD34D;
    --help-tip-text-strong: #FEF08A;
}

/* =====================================
   BOTÓN FLOTANTE DE AYUDA
   ===================================== */

.help-button-container {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 2147483646;
    pointer-events: auto;
    isolation: isolate;
}

.help-button {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--help-primary) 0%, var(--help-primary-hover) 100%);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--help-shadow-lg);
    transition: var(--help-transition);
    overflow: hidden;
}

.help-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--help-shadow-xl);
    background: linear-gradient(135deg, var(--help-primary-hover) 0%, var(--help-primary) 100%);
}

.help-button:active {
    transform: translateY(-1px) scale(1.02);
}

.help-button:focus-visible {
    outline: 3px solid var(--help-secondary);
    outline-offset: 4px;
}

.help-icon {
    width: 32px;
    height: 32px;
    position: relative;
    z-index: 2;
    transition: var(--help-transition);
}

.help-button:hover .help-icon {
    transform: rotate(15deg) scale(1.1);
}

/* Efecto Pulse para llamar la atención */
.help-button-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--help-primary);
    opacity: 0;
    animation: help-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
}

@keyframes help-pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Responsive - Ajuste en móviles pequeños */
@media (max-width: 576px) {
    .help-button-container {
        bottom: 20px;
        left: 20px;
    }

    .help-button {
        width: 56px;
        height: 56px;
    }

    .help-icon {
        width: 28px;
        height: 28px;
    }
}

/* =====================================
   MODAL - OVERLAY Y CONTAINER
   ===================================== */

.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--help-overlay-bg);
    backdrop-filter: blur(4px);
    z-index: 2147483645;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.help-modal-overlay[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

.help-modal-container {
    background: var(--help-bg-primary);
    border-radius: var(--help-border-radius);
    box-shadow: var(--help-shadow-xl);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

.help-modal-overlay[aria-hidden="false"] .help-modal-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* =====================================
   MODAL - HEADER
   ===================================== */

.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 2px solid var(--help-border-color);
    background: linear-gradient(135deg, var(--help-primary) 0%, var(--help-primary-hover) 100%);
    border-radius: var(--help-border-radius) var(--help-border-radius) 0 0;
}

.help-modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-modal-title-icon {
    width: 28px;
    height: 28px;
}

.help-modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--help-transition-fast);
    flex-shrink: 0;
}

.help-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.help-modal-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.help-modal-close svg {
    width: 24px;
    height: 24px;
}

/* =====================================
   MODAL - NAVEGACIÓN (TABS)
   ===================================== */

.help-modal-nav {
    display: flex;
    gap: 0;
    padding: 0;
    background: var(--help-bg-secondary);
    border-bottom: 1px solid var(--help-border-color);
}

.help-tab {
    flex: 1;
    padding: 16px 24px;
    border: none;
    background: transparent;
    color: var(--help-text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--help-transition-fast);
    border-bottom: 3px solid transparent;
    position: relative;
}

.help-tab:hover {
    background: var(--help-glass-dark);
    color: var(--help-primary);
}

.help-tab:focus-visible {
    outline: 2px solid var(--help-primary);
    outline-offset: -2px;
    z-index: 1;
}

.help-tab-active {
    color: var(--help-primary);
    border-bottom-color: var(--help-primary);
    background: var(--help-bg-primary);
}

.help-tab-icon {
    width: 20px;
    height: 20px;
    transition: var(--help-transition-fast);
}

.help-tab:hover .help-tab-icon,
.help-tab-active .help-tab-icon {
    transform: scale(1.1);
}

/* =====================================
   MODAL - CONTENIDO
   ===================================== */

.help-modal-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.help-tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.help-tab-panel-active {
    display: block;
}

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

.help-content-section {
    padding: 32px;
}

.help-section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--help-text-primary);
    margin: 0 0 24px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-section-title::before {
    content: '';
    width: 4px;
    height: 28px;
    background: var(--help-primary);
    border-radius: 2px;
}

/* =====================================
   INFO CARDS (Panel Requisitos)
   ===================================== */

.help-info-card {
    background: var(--help-bg-primary);
    border: 2px solid var(--help-border-color);
    border-radius: var(--help-border-radius-sm);
    padding: 20px;
    margin-bottom: 16px;
    transition: var(--help-transition-fast);
}

.help-info-card:hover {
    border-color: var(--help-primary);
    box-shadow: var(--help-shadow-sm);
    transform: translateY(-2px);
}

.help-info-card h4 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--help-primary);
}

.help-list {
    margin: 0;
    padding-left: 24px;
    color: var(--help-text-secondary);
}

.help-list li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.help-tip {
    background: var(--help-tip-bg);
    border-left: 4px solid var(--help-secondary);
    padding: 16px 20px;
    border-radius: var(--help-border-radius-sm);
    margin-top: 24px;
    color: var(--help-tip-text);
}

.help-tip strong {
    color: var(--help-tip-text-strong);
}

/* =====================================
   GLOSARIO - CONTROLES
   ===================================== */

.glossary-controls {
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glossary-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--help-text-primary);
}

.glossary-select {
    padding: 12px 16px;
    border: 2px solid var(--help-border-color);
    border-radius: var(--help-border-radius-sm);
    font-size: 15px;
    color: var(--help-text-primary);
    background: var(--help-bg-primary);
    cursor: pointer;
    transition: var(--help-transition-fast);
}

.glossary-select:hover {
    border-color: var(--help-primary);
}

.glossary-select:focus {
    outline: none;
    border-color: var(--help-primary);
    box-shadow: 0 0 0 3px var(--help-glass-dark);
}

/* =====================================
   EFECTO LIBRO 3D - LA MAGIA
   ===================================== */

.glossary-book-wrapper {
    perspective: 1500px;
    perspective-origin: center;
    margin: 0 auto 32px;
    max-width: 700px;
    position: relative;
}

.glossary-book {
    position: relative;
    width: 100%;
    min-height: 450px;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Páginas del libro */
.book-page {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 450px;
    background: var(--help-book-bg);
    border-radius: var(--help-border-radius-sm);
    box-shadow: var(--help-shadow-md);
    backface-visibility: hidden;
    transform-style: preserve-3d;
    overflow: hidden;
    border: 1px solid var(--help-book-border);
}

/* Página actual (frente) */
.book-page-current {
    position: relative;
    transform: rotateY(0deg);
    z-index: 2;
}

/* Página siguiente (reverso - inicialmente oculta) */
.book-page-next {
    transform: rotateY(180deg);
    z-index: 1;
    opacity: 0;
}

/* Cuando se activa la animación de flip */
.glossary-book.flipping .book-page-current {
    animation: flipPageOut 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.glossary-book.flipping .book-page-next {
    animation: flipPageIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes flipPageOut {
    0% {
        transform: rotateY(0deg);
        z-index: 2;
        opacity: 1;
    }
    49% {
        z-index: 2;
    }
    50% {
        z-index: 1;
        opacity: 0.5;
    }
    100% {
        transform: rotateY(-180deg);
        z-index: 1;
        opacity: 0;
    }
}

@keyframes flipPageIn {
    0% {
        transform: rotateY(180deg);
        z-index: 1;
        opacity: 0;
    }
    49% {
        z-index: 1;
    }
    50% {
        z-index: 2;
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg);
        z-index: 2;
        opacity: 1;
    }
}

/* Contenido de la página */
.book-page-content {
    padding: 32px;
    height: 100%;
    overflow-y: auto;
    background: transparent;
}

/* Efecto de papel envejecido (opcional - skeuomorfismo) */
.book-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(90deg,
            var(--help-border-color-light) 0%,
            transparent 5%,
            transparent 95%,
            var(--help-border-color-light) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Sombra del libro */
.book-shadow {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: 20px;
    background: radial-gradient(ellipse at center,
        var(--help-book-shadow) 0%,
        transparent 70%);
    border-radius: 50%;
    filter: blur(10px);
    z-index: 0;
}

/* =====================================
   GLOSARIO - CONTENIDO
   ===================================== */

.glossary-item {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--help-border-color);
}

.glossary-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.glossary-acronym {
    font-size: 20px;
    font-weight: 700;
    color: var(--help-primary);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.glossary-acronym::before {
    content: '►';
    font-size: 14px;
}

.glossary-full-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--help-text-primary);
    margin: 0 0 8px 0;
}

.glossary-description {
    font-size: 14px;
    color: var(--help-text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Loading state */
.glossary-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: 16px;
}

.spinner {
    animation: rotate 2s linear infinite;
    width: 50px;
    height: 50px;
}

.spinner-path {
    stroke: var(--help-primary);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* =====================================
   INDICADOR DE PÁGINA
   ===================================== */

.glossary-page-indicator {
    text-align: center;
    padding: 16px;
    font-size: 14px;
    color: var(--help-text-muted);
    font-weight: 500;
}

/* =====================================
   RESPONSIVE - TABLETS
   ===================================== */

@media (max-width: 768px) {
    .help-modal-container {
        max-width: 100%;
        max-height: 95vh;
        margin: 10px;
        border-radius: var(--help-border-radius-sm);
    }

    .help-modal-header {
        padding: 20px 24px;
    }

    .help-modal-title {
        font-size: 20px;
    }

    .help-modal-title-icon {
        width: 24px;
        height: 24px;
    }

    .help-tab {
        font-size: 14px;
        padding: 14px 16px;
        flex-direction: column;
        gap: 4px;
    }

    .help-tab-icon {
        width: 18px;
        height: 18px;
    }

    .help-content-section {
        padding: 24px;
    }

    .glossary-book {
        min-height: 400px;
    }

    .book-page {
        min-height: 400px;
    }
}

/* =====================================
   RESPONSIVE - MÓVILES
   ===================================== */

@media (max-width: 576px) {
    .help-modal-overlay {
        padding: 10px;
    }

    .help-modal-container {
        border-radius: 8px;
    }

    .help-modal-header {
        padding: 16px 20px;
    }

    .help-modal-title {
        font-size: 18px;
        gap: 8px;
    }

    .help-modal-title-icon {
        width: 20px;
        height: 20px;
    }

    .help-modal-close {
        width: 36px;
        height: 36px;
    }

    .help-modal-close svg {
        width: 20px;
        height: 20px;
    }

    .help-tab {
        padding: 12px 12px;
        font-size: 13px;
    }

    .help-tab-icon {
        width: 16px;
        height: 16px;
    }

    .help-content-section {
        padding: 20px;
    }

    .help-section-title {
        font-size: 20px;
    }

    .help-info-card {
        padding: 16px;
    }

    .help-info-card h4 {
        font-size: 16px;
    }

    .glossary-book {
        min-height: 350px;
    }

    .book-page {
        min-height: 350px;
    }

    .book-page-content {
        padding: 24px;
    }

    .glossary-acronym {
        font-size: 18px;
    }

    .glossary-full-name {
        font-size: 15px;
    }

    .glossary-description {
        font-size: 13px;
    }
}

/* =====================================
   ACCESIBILIDAD - PREFERS REDUCED MOTION
   ===================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .help-button-pulse {
        display: none;
    }

    .glossary-book.flipping .book-page-current,
    .glossary-book.flipping .book-page-next {
        animation: none;
    }

    .glossary-book.flipping .book-page-current {
        opacity: 0;
        z-index: 1;
    }

    .glossary-book.flipping .book-page-next {
        opacity: 1;
        z-index: 2;
        transform: rotateY(0deg);
    }
}

/* =====================================
   SCROLLBAR PERSONALIZADA
   ===================================== */

.help-modal-content::-webkit-scrollbar,
.book-page-content::-webkit-scrollbar {
    width: 8px;
}

.help-modal-content::-webkit-scrollbar-track,
.book-page-content::-webkit-scrollbar-track {
    background: var(--help-bg-secondary);
}

.help-modal-content::-webkit-scrollbar-thumb,
.book-page-content::-webkit-scrollbar-thumb {
    background: var(--help-border-color);
    border-radius: 4px;
}

.help-modal-content::-webkit-scrollbar-thumb:hover,
.book-page-content::-webkit-scrollbar-thumb:hover {
    background: var(--help-text-muted);
}

/* =====================================
   VIDEO DE NAVEGACIÓN
   ===================================== */

.navigation-video-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 24px;
    border-radius: var(--help-border-radius);
    overflow: hidden;
    background: var(--help-bg-secondary);
    box-shadow: var(--help-shadow-md);
    border: 1px solid var(--help-border-color);
}

.navigation-video {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
}

/* Estilos para el video en tema oscuro */
[data-bs-theme="oscuro"] .navigation-video-container {
    border-color: var(--help-border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Responsive para el video */
@media (max-width: 768px) {
    .navigation-video-container {
        max-width: 100%;
        border-radius: var(--help-border-radius-sm);
    }
}

@media (max-width: 576px) {
    .navigation-video-container {
        border-radius: 8px;
    }
}
