/* Detalle de Recurso - Iberoteca Refinado */

.detail-page-bg {
    background-color: #f8fafc;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 30px 30px;
    min-height: 100vh;
    padding-top: 40px;
    padding-bottom: 80px;
    margin-top: 0;
}

.detail-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 5%;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    padding: 15px 25px;
    background: #eef2f6;
    border-radius: 4px;
    font-weight: 500;
}

.breadcrumb a {
    color: var(--primary-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Detail Header Section (Sin tarjeta de fondo general) */
.detail-header {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 60px;
    align-items: flex-start;
    margin-bottom: 60px;
}

/* Book Cover (Con borde blanco y sombra suave) */
.detail-cover-wrapper {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    position: relative;
}

.detail-cover {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* Right Column (Info) */
.detail-info {
    display: flex;
    flex-direction: column;
    padding-top: 10px;
}

.info-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.resource-type-badge {
    display: inline-block;
    padding: 6px 18px;
    background: #e5edff;
    color: var(--primary-light);
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-favorite-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ef4444;
    /* Rojo suave */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-favorite-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.btn-favorite-circle svg {
    width: 18px;
    height: 18px;
    fill: none;
}

.detail-title {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.15;
    color: #1a1a2e;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: -0.5px;
}

.detail-author {
    font-size: 1.5rem;
    color: #64748b;
    font-weight: 400;
    margin-bottom: 30px;
}

/* Metadata Chips (Exactamente como la imagen) */
.metadata-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 40px;
}

.meta-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    font-size: 0.8rem;
    color: #334155;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.01);
}

.meta-chip.author-chip {
    padding-left: 12px;
}

.meta-chip svg {
    color: var(--primary-light);
    width: 14px;
    height: 14px;
}

.meta-label {
    font-weight: 800;
    color: var(--primary-light);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Action Buttons */
.detail-actions {
    display: flex;
    gap: 12px;
    margin: 30px 0;
    /* Margen simétrico arriba y abajo */
}

.btn-action-primary {
    background: var(--primary);
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(85, 62, 214, 0.2);
}

.btn-action-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(85, 62, 214, 0.3);
    color: white;
}

.btn-action-secondary {
    background: white;
    color: #1e293b;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    border: 1px solid #e2e8f0;
}

.btn-action-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

.btn-action-primary svg,
.btn-action-secondary svg {
    width: 16px;
    height: 16px;
}

/* Summary and Video Row */
.summary-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.summary-title-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.summary-title-group h3 {
    font-size: 1.25rem;
    color: #1e293b;
    font-weight: 800;
}

.btn-tts-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--primary-light);
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-tts-circle:hover {
    background: #e2e8f0;
}

.btn-tts-circle svg {
    width: 16px;
    height: 16px;
}

.btn-tts-circle.speaking {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    animation: pulse-tts 2s infinite;
}

.btn-tts-circle.paused {
    background: #f59e0b;
    color: white;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

@keyframes pulse-tts {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.btn-video-resumen {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #ff4d4f, #ff6b6b);
    /* Gradiente rojo más suave */
    color: white;
    padding: 12px 28px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 20px rgba(255, 77, 79, 0.3);
    border: none;
    transition: var(--transition);
}

.btn-video-resumen:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(255, 77, 79, 0.4);
}

.btn-video-resumen svg {
    fill: white;
}

/* Summary Text */
.summary-text {
    color: #64748b;
    line-height: 1.8;
    font-size: 0.95rem;
    text-align: justify;
    margin-bottom: 15px;
}

.btn-read-more {
    background: none;
    border: none;
    color: var(--primary-light);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    margin-bottom: 40px;
}

/* Divider & Share */
.detail-divider {
    height: 1px;
    background: #e2e8f0;
    width: 100%;
    margin-bottom: 25px;
}

.share-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
}

.share-label {
    font-size: 0.85rem;
    color: #475569;
    font-weight: 600;
}

.social-icons-share {
    display: flex;
    gap: 15px;
}

.social-icon-share {
    color: #64748b;
    /* Color base gris suave */
    transition: var(--transition);
    display: flex;
    align-items: center;
    text-decoration: none;
}

.social-icon-share svg {
    width: 20px;
    height: 20px;
}

/* Colores de marca en hover */
.social-icon-share.facebook:hover {
    color: #1877F2;
    transform: translateY(-4px) scale(1.08);
}

.social-icon-share.twitter-x:hover {
    color: #0F1419;
    transform: translateY(-4px) scale(1.08);
}

.social-icon-share.linkedin:hover {
    color: #0A66C2;
    transform: translateY(-4px) scale(1.08);
}

.social-icon-share.whatsapp:hover {
    color: #25D366;
    transform: translateY(-4px) scale(1.08);
}

.social-icon-share.copy {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.social-icon-share.copy:hover,
.social-icon-share.copy.copied {
    color: #4F46E5;
    transform: translateY(-4px) scale(1.08);
}

/* Comments Section (Adaptado al nuevo estilo plano) */
.comments-section {
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
}

.comments-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.comments-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
}

.comments-sort {
    padding: 8px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    color: #64748b;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    outline: none;
}

.comment-form {
    display: flex;
    gap: 20px;
    margin-bottom: 50px;
    align-items: flex-start;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #4f46e5;
    /* Color del logo de ejemplo (morado/azul) */
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.comment-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    gap: 15px;
    align-items: center;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    padding: 5px 5px 5px 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.comment-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    color: #334155;
    background: transparent;
}

.comment-input-wrapper input::placeholder {
    color: #94a3b8;
}

.btn-publish {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-publish:hover {
    background: #4338ca;
}

/* Comment List */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 35px;
}

.comment-item {
    display: flex;
    gap: 20px;
}

.comment-body {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.comment-user-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
}

.comment-user-role {
    font-size: 0.7rem;
    color: #64748b;
}

.comment-date {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: auto;
}

.comment-text {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
}

.comment-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.btn-comment-action {
    font-size: 0.8rem;
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
    padding: 0;
}

.btn-comment-action:hover {
    color: #4f46e5;
}

.btn-comment-action.delete:hover {
    color: #ef4444;
}

/* Responsive */
@media (max-width: 992px) {
    .detail-header {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .detail-cover-wrapper {
        max-width: 350px;
        margin: 0 auto;
    }

    .detail-title {
        font-size: 2.2rem;
    }

    .summary-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .btn-video-resumen {
        align-self: flex-start;
    }

    /* Comentarios Responsive */
    .comments-section {
        padding: 25px 20px;
        border-radius: 16px;
    }

    .comments-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .comment-form {
        flex-direction: column;
        gap: 15px;
    }

    .comment-input-wrapper {
        width: 100%;
        border-radius: 15px;
        padding: 5px 5px 5px 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .comment-input-wrapper input {
        padding: 10px 0;
    }

    .btn-publish {
        width: 100%;
        border-radius: 10px;
    }

    .share-row {
        justify-content: center;
        flex-direction: column;
        gap: 10px;
    }

    .social-icons-share {
        justify-content: center;
    }
}

/* --- VIDEO MODAL PREMIUM --- */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    /* Slate 900 con transparencia */
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.video-modal-container {
    width: 95%;
    max-width: 1100px;
    background: #0f172a;
    /* Slate 900 */
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.video-modal-header {
    background: #1e293b;
    /* Slate 800 */
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-brand img {
    height: 24px;
    filter: brightness(0) invert(1);
}

.modal-brand span {
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.video-modal-title {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: auto;
    margin-left: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

.video-aspect-ratio {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    height: 0;
    background: #000;
}

/* Loader institucional */
.video-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 1;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(79, 70, 229, 0.2);
    border-top: 3px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.video-loader span {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.video-aspect-ratio iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.video-aspect-ratio iframe.loaded {
    opacity: 1;
}

.btn-close-modal-header {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close-modal-header:hover {
    background: #ef4444;
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    .video-modal-title {
        display: none;
    }

    .video-modal-header {
        padding: 12px 15px;
    }
}

/* --- CUSTOM MODALS & TOASTS --- */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 11000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.custom-modal {
    background: white;
    padding: 35px;
    border-radius: 24px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-modal-overlay.active .custom-modal {
    transform: scale(1);
}

.modal-icon-warning {
    width: 64px;
    height: 64px;
    background: #fef2f2;
    color: #ef4444;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
}

.modal-icon-warning svg {
    width: 32px;
    height: 32px;
}

.custom-modal h3 {
    font-size: 1.4rem;
    color: #1e293b;
    margin-bottom: 12px;
    font-weight: 800;
}

.custom-modal p {
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 30px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-modal-cancel {
    flex: 1;
    padding: 12px;
    background: #f1f5f9;
    border: none;
    border-radius: 12px;
    color: #475569;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal-confirm {
    flex: 1;
    padding: 12px;
    background: #ef4444;
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-modal-cancel:hover {
    background: #e2e8f0;
}

.btn-modal-confirm:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Custom Toast */
.custom-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 12px 25px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 12000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
}

.custom-toast.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.custom-toast.success {
    background: #059669;
}

.custom-toast.error {
    background: #ef4444;
}

/* Comment fade-out animation */
.comment-item {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- PDF MODAL PREMIUM --- */
.pdf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    /* Slate 900 con transparencia */
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.pdf-modal-overlay.active .pdf-modal-container {
    transform: scale(1);
}

.pdf-modal-container {
    width: 98%;
    max-width: 1600px;
    height: 96vh;
    background: #0f172a;
    /* Slate 900 */
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.pdf-modal-header {
    background: #1e293b;
    /* Slate 800 */
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 60px;
    box-sizing: border-box;
}

.pdf-modal-title {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: auto;
    margin-left: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.pdf-modal-actions-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-header-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    /* Slate 300 */
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
}

.btn-header-action:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.btn-header-action svg,
.btn-header-action i {
    width: 14px;
    height: 14px;
}

@media (max-width: 640px) {
    .btn-header-action span {
        display: none;
    }

    .btn-header-action {
        padding: 6px;
    }
}

.pdf-container {
    position: relative;
    flex: 1;
    background: #000;
    height: calc(100% - 60px);
}

/* Loader institucional */
.pdf-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 1;
}

.pdf-loader span {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pdf-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    z-index: 2;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.pdf-container iframe.loaded {
    opacity: 1;
}

@media (max-width: 768px) {
    .pdf-modal-title {
        display: none;
    }

    .pdf-modal-header {
        padding: 12px 15px;
    }
}