/* visor-pdf.css — solucionariosenpdf.com */

.pdf-viewer-section { margin: 2rem 0; }

#pdf-viewer-wrapper {
    background: #1E293B;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

#pdf-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #0F172A;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-wrap: wrap;
}

#pdf-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    color: #E2E8F0;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    min-height: 36px;
    white-space: nowrap;
    font-family: var(--font-body);
}

#pdf-toolbar button:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
}

#pdf-toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pdf-page-info {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: #94A3B8;
    font-size: 0.8125rem;
    white-space: nowrap;
}

#pdf-page-input {
    width: 48px;
    padding: 0.25rem 0.375rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: #fff;
    text-align: center;
    font-size: 0.8125rem;
    font-family: var(--font-body);
    outline: none;
}

#pdf-page-input:focus {
    border-color: var(--color-primary);
}

#pdf-zoom-level {
    color: #94A3B8;
    font-size: 0.8125rem;
    min-width: 42px;
    text-align: center;
}

.pdf-toolbar-spacer { flex: 1; }

/* Canvas contenedor */
#pdf-canvas-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    min-height: 700px;
    max-height: 85vh;
    padding: 1rem;
    background: #374151;
}

@media(max-width: 768px) {
    #pdf-canvas-container {
        min-height: 85vh;
        padding: 0.5rem;
    }
}

#pdf-canvas {
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: block;
    max-width: 100%;
}

/* Skeleton mientras carga */
#pdf-skeleton {
    min-height: 700px;
    background: linear-gradient(90deg, #1E293B 25%, #2D3748 50%, #1E293B 75%);
    background-size: 200% 100%;
    animation: pdfSkeletonShimmer 1.8s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    color: #64748B;
}

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

.pdf-loading-icon {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: pdfSpin 0.8s linear infinite;
}

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

#pdf-error {
    display: none;
    min-height: 400px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    color: #94A3B8;
}

.pdf-error-icon { font-size: 3rem; }

/* Botón descarga discreto */
.pdf-download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-decoration: underline;
    margin-top: 0.75rem;
    transition: color var(--transition-fast);
}
.pdf-download-link:hover { color: var(--color-primary); }

/* Modo pantalla completa */
.pdf-fullscreen #pdf-canvas-container {
    max-height: 100vh;
    min-height: 100vh;
    padding: 0;
}

/* ═══════════════════════════════════════════════════
   TEMAS — Layout sidebar sticky + visor
═══════════════════════════════════════════════════ */

/* Layout contenedor (desktop) */
.temas-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
    align-items: start;
}

/* Sidebar */
.temas-sidebar {
    position: sticky;
    top: 80px; /* Altura del header del sitio */
    background: var(--color-surface, #fff);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}

.temas-sidebar__titulo {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: 0.875rem 1rem 0.625rem;
    border-bottom: 1px solid var(--color-border);
    background: #F8FAFC;
    flex-shrink: 0;
}

.temas-sidebar nav {
    overflow-y: auto;
    flex: 1;
}

.temas-sidebar__item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--color-text);
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
    font-family: var(--font-body);
}

.temas-sidebar__item:last-child { border-bottom: none; }

.temas-sidebar__item:hover {
    background: #EEF2FF;
    color: var(--color-primary);
}

.temas-sidebar__item.active {
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    color: var(--color-primary);
    font-weight: 600;
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1rem - 3px);
}

.temas-sidebar__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    background: var(--color-border);
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-text-muted);
    flex-shrink: 0;
    margin-top: 1px;
    transition: background 0.15s, color 0.15s;
}

.temas-sidebar__item.active .temas-sidebar__num {
    background: var(--color-primary);
    color: #fff;
}

/* Visor */
.temas-visor {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.temas-visor__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #0F172A;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: #E2E8F0;
    flex-wrap: wrap;
}

.temas-visor__header .pdf-download-link {
    color: #94A3B8;
    margin-top: 0;
    font-size: 0.8rem;
}

.temas-visor #pdf-viewer-wrapper {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.temas-visor #pdf-toolbar {
    border-radius: 0;
}

/* ─── Mobile: tabs horizontales con scroll ─── */
.temas-tabs-mobile {
    display: none; /* Solo visible en móvil */
    overflow-x: auto;
    white-space: nowrap;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--color-surface, #fff);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    padding: 0.375rem;
    scroll-snap-type: x mandatory;
}

.temas-tabs-mobile::-webkit-scrollbar { display: none; }

.tema-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: var(--font-body);
    cursor: pointer;
    color: var(--color-text-muted);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    scroll-snap-align: start;
}

.tema-tab:hover {
    background: #EEF2FF;
    color: var(--color-primary);
}

.tema-tab.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .temas-layout {
        grid-template-columns: 1fr;
    }

    .temas-sidebar {
        display: none; /* Se oculta en móvil, se usa tabs en su lugar */
    }

    .temas-tabs-mobile {
        display: flex;
    }
}

@media (max-width: 600px) {
    .temas-visor__header {
        padding: 0.625rem 0.75rem;
    }

    .temas-visor__header h2 {
        font-size: 0.875rem !important;
    }
}
