/* Mejoras sutiles inspiradas en interactivo.php */
.container {
    max-width: 1200px;
}

/* Breadcrumbs mejorados */
.breadcrumb {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e9ecef;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.breadcrumb-item a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-item a:hover {
    color: #0056b3;
}

/* Título del tema mejorado */
h2 {
    color: #000035;
    font-weight: 700;
    margin-bottom: 25px;
    position: relative;
    padding-bottom: 15px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, #ff00c7, #7c00ff);
    border-radius: 2px;
}

/* Sección de quiz mejorada */
#quiz-section.card {
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
    border: 1px solid #e3e7ff;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
}

#quiz-section .card-title {
    color: #000035;
    font-weight: 600;
}

/* Botones modernos */
.btn {
    border-radius: 12px;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #20c997);
    border: none;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    background: linear-gradient(135deg, #218838, #1ea085);
}

.btn-outline-success {
    border: 2px solid #28a745;
    color: #28a745;
    background: transparent;
}

.btn-outline-success:hover {
    background: linear-gradient(135deg, #28a745, #20c997);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
}



.btn-primary, .btn-lg.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.btn-primary:hover, .btn-lg.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
    background: linear-gradient(135deg, #0056b3, #004085);
}

/* Cards de contenido */
.content-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.content-item {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    background: #ffffff;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.content-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    border-color: #dee2e6;
}

.content-item.clickable {
    text-decoration: none;
    color: inherit;
    display: block;
}

.content-item.clickable:hover {
    text-decoration: none;
    color: inherit;
}




/* Layout mejorado para contenido */
.content-item-header {
    display: flex;
    align-items: center;
    width: 100%;
}

.content-item-info {
    flex: 1;
    min-width: 0;
}

.content-item-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.content-item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

/* Indicador de duración */
.content-duration {
    font-size: 0.8rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #e9ecef;
}

.content-item h5 a {
    color: #000035;
    text-decoration: none;
    transition: color 0.3s ease;
}

.content-item h5 a:hover {
    color: #007bff;
}



/* Badges */
.badge {
    border-radius: 6px;
    padding: 4px 10px;
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: capitalize;
    letter-spacing: 0.2px;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
    color: #6c757d;
    position: relative;
    overflow: hidden;
}

.badge.bg-secondary {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border: 1px solid #e9ecef !important;
    font-weight: 400;
}

/* Badges específicos por tipo de contenido */
.content-type-badge-video {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border: 1px solid #e9ecef !important;
}

.content-type-badge-texto {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border: 1px solid #e9ecef !important;
}


.content-type-badge-default {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border: 1px solid #e9ecef !important;
}

.content-type-badge-exam_exercise {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border: 1px solid #e9ecef !important;
}

.content-type-badge-practice_exercise {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border: 1px solid #e9ecef !important;
}

/* Alertas mejoradas */
.alert {
    border-radius: 15px;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left: 4px solid #ffc107;
}

/* Quiz summary mejorado */
.quiz-summary-card {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border: 1px solid #28a745;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.1);
}

.quiz-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.quiz-summary-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.quiz-summary-badge.success { background: #28a745; color: white; }
.quiz-summary-badge.warning { background: #ffc107; color: #000; }
.quiz-summary-badge.danger { background: #dc3545; color: white; }

.quiz-summary-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.quiz-summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.quiz-summary-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #155724;
}

.quiz-summary-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Indicador de completado */
.content-completion-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.2);
    font-size: 0.8rem;
}

.content-item.content-completed {
    border-color: #d4edda;
    background: #f8fff8;
}

.content-item.content-completed .content-item-title {
    color: #155724;
}

@keyframes completionBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .quiz-summary-stats {
        justify-content: center;
    }
    
    .content-item {
        margin-bottom: 10px;
    }
}

/* Enlaces clickeables */
.content-item.clickable:hover .content-item-title {
    color: #495057;
}

/* Remover padding de .content-item cuando es clickeable ya que el enlace maneja el padding */
a.content-item.clickable {
    padding: 18px;
    text-decoration: none;
    color: inherit;
    display: block;
}

a.content-item.clickable:hover {
    text-decoration: none;
    color: inherit;
}

/* Module Change Modal Styles */
#moduleChangeModal .modal-content {
    border: none;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

#moduleChangeModal .modal-header {
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
    border-bottom: 1px solid #e3e7ff;
}

#moduleChangeModal .modal-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f9ff 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(0, 123, 255, 0.1);
}

#moduleChangeModal .modal-title {
    font-weight: 600;
    color: #000035;
    margin: 0;
}

#moduleChangeModal .btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

#moduleChangeModal .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

#moduleChangeModal .btn-outline-secondary {
    border: 2px solid #e9ecef;
    color: #6c757d;
    background: transparent;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#moduleChangeModal .btn-outline-secondary:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #495057;
}

/* Quiz Chat Styles */
.btn-exaboti {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    border: none;
    color: white;
    font-size: 0.875rem;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(111, 66, 193, 0.3);
}

.btn-exaboti:hover {
    background: linear-gradient(135deg, #5a32a3, #4c2b85);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.4);
    color: white;
}

.btn-exaboti i {
    margin-right: 6px;
}

/* Quiz Modal Fullscreen */
.quiz-modal-fullscreen {
    max-width: 100vw !important;
    margin: 0 !important;
    height: 100vh;
}

.quiz-modal-fullscreen .modal-dialog {
    max-width: 100vw !important;
    margin: 0 !important;
    height: 100vh;
}

.quiz-modal-fullscreen .modal-content {
    height: 100vh;
    border-radius: 0;
    border: none;
    display: flex !important;
    flex-direction: column !important;
}

.quiz-modal-fullscreen .modal-body {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* Quiz Modal Header - Fixed at top */
.quiz-modal-header {
    flex-shrink: 0 !important;
    padding: 20px 20px 0 20px !important;
    background: white !important;
}

/* Quiz Content Area - Takes remaining space and splits into panels */
.quiz-content-area {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
    /* Ensure proper height constraints */
    height: 100%;
    max-height: 100%;
}

/* Additional safety for row container in quiz */
.quiz-content-area .row {
    height: 100% !important;
    overflow: hidden !important;
}

/* Ensure columns have proper height */
.quiz-content-area .col-12,
.quiz-content-area .col-6:not(.d-none) {
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.quiz-main-panel {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 5px 20px 20px 20px !important;
    overflow-y: auto !important;
    background: white !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

/* Ensure the quiz content inside main panel can scroll */
.quiz-main-panel #quiz {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Additional safety for quiz content */
.quiz-main-panel > div:first-child {
    /* flex: 1; */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Quiz Chat Panel - Desktop (using Bootstrap grid) */
.quiz-chat-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 1 !important;
    background: white !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    border-left: 1px solid #dee2e6 !important;
    position: relative !important;
    padding: 0 !important;
    margin: 0 !important;
    /* Enhanced space optimization for desktop */
    min-height: calc(100vh - 120px); /* Utilize full viewport height minus header */
    max-height: calc(100vh - 120px);
}

/* Chat Container - Floating (Mobile) */
.quiz-chat-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1060;
    display: none;
    flex-direction: column;
    border: 1px solid #dee2e6;
}

.quiz-chat-floating.active {
    display: flex;
}

/* Chat Header */
.quiz-chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    border-radius: 15px 15px 0 0;
    flex-shrink: 0;
}

.quiz-chat-panel .quiz-chat-header {
    border-radius: 0;
    padding: 18px 24px; /* Enhanced padding for better visual presence */
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Add subtle shadow */
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Chat Messages Area */
.quiz-chat-messages {
    flex: 1;
    padding: 15px 20px 50px 20px; /* Increased bottom padding for last message visibility */
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
    position: relative;
}

.quiz-chat-panel .quiz-chat-messages {
    flex: 1;
    padding: 20px 20px 60px 20px; /* Generous bottom padding for desktop */
    background: white;
    overflow-y: auto;
    scroll-behavior: smooth;
    /* Simple height calculation - let flexbox handle the rest */
    min-height: 300px;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

/* Chat Input Area */
.quiz-chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 15px 15px;
    flex-shrink: 0;
}

.quiz-chat-panel .quiz-chat-input-area {
    border-radius: 0;
    background: white;
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    /* Enhanced input area for better space utilization */
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05); /* Subtle shadow for separation */
    min-height: 80px; /* Ensure adequate input space */
}

.quiz-chat-input {
    min-height: 60px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 10px;
    resize: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: white;
    width: 100%;
    font-size: 14px;
    line-height: 1.4;
    /* Enhanced input styling for desktop */
    max-height: 120px; /* Prevent excessive height */
}

.quiz-chat-panel .quiz-chat-input {
    min-height: 70px; /* Slightly larger for desktop */
    font-size: 15px; /* Better readability on desktop */
    padding: 12px 14px; /* Enhanced padding for desktop */
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Subtle shadow */
}

.quiz-chat-input:focus {
    border-color: #6f42c1;
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.25);
    outline: none;
}

.quiz-chat-input[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #6c757d;
    font-style: italic;
}

/* Botón enviar - más pequeño en móvil */
#sendQuizChatBtn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
    font-weight: 500;
}

/* Enhanced send button for desktop chat panel */
.quiz-chat-panel #sendQuizChatBtn {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 8px;
    font-weight: 600;
    min-width: 80px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.quiz-chat-panel #sendQuizChatBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Chat message styling enhancements for desktop */
.quiz-chat-panel .chat-message {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.5;
}

.quiz-chat-panel .chat-message.user {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    margin-left: auto;
    text-align: right;
    border: 1px solid #e1f5fe;
}

.quiz-chat-panel .chat-message.bot {
    background: linear-gradient(135deg, #f8f9ff, #e8ecff);
    border: 1px solid #e0e7ff;
    margin-right: auto;
}

/* Chat message styling for mobile floating chat */
.quiz-chat-floating .chat-message {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

/* Ensure last message has extra spacing and add after pseudo element for guaranteed spacing */
.quiz-chat-floating .chat-message:last-child,
.quiz-chat-panel .chat-message:last-child {
    margin-bottom: 30px;
}

/* Add a pseudo element to guarantee space after last message */
.quiz-chat-messages::after {
    content: '';
    display: block;
    height: 10px;
    width: 100%;
    flex-shrink: 0;
}

.quiz-chat-floating .chat-message.user {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    margin-left: auto;
    text-align: right;
    border: 1px solid #e1f5fe;
}

.quiz-chat-floating .chat-message.bot {
    background: linear-gradient(135deg, #f8f9ff, #e8ecff);
    border: 1px solid #e0e7ff;
    margin-right: auto;
}

/* Loading and error message styles */
.chat-message.bot.loading-response {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 1px solid #ffcc02;
    font-style: italic;
}

.chat-message.bot.error {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border: 1px solid #f44336;
}

/* Enhanced scrollbar styling for desktop */
.quiz-chat-panel .quiz-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.quiz-chat-panel .quiz-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.quiz-chat-panel .quiz-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.quiz-chat-panel .quiz-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Mobile send buttons - control width strictly */
    #sendQuizChatBtn, #sendQuizChatBtnMobile {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 65px;
        max-width: 80px; /* Prevent from getting too wide */
        width: auto; /* Let content determine width within limits */
        height: 32px;
        white-space: nowrap;
        flex-shrink: 0; /* Prevent button from shrinking */
        flex-grow: 0; /* Prevent button from growing */
    }
    
    .quiz-chat-input-area {
        padding: 10px 12px !important;
    }
    
    .quiz-chat-input-area .d-flex {
        gap: 10px;
        align-items: center; /* Center align for better appearance */
        justify-content: space-between; /* Ensure proper spacing */
    }
    
    .quiz-chat-input-area small {
        font-size: 0.75rem;
        flex: 1;
        line-height: 1.3;
        margin-right: 8px; /* Add some space before button */
    }
    
    .quiz-chat-floating {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        /* Use more dynamic height with better viewport units */
        height: 55vh;
        min-height: 400px; /* Ensure minimum usable height */
        max-height: 70vh; /* Don't take up too much screen */
        border-radius: 15px 15px 0 0;
        z-index: 1070;
        transition: transform 0.3s ease, opacity 0.3s ease;
        display: flex;
        flex-direction: column;
        /* Ensure the chat doesn't go below viewport */
        box-sizing: border-box;
    }
    
    /* Enhanced mobile state when keyboard is active */
    /* .quiz-chat-floating.keyboard-active {
        height: 60vh;
        max-height: 75vh;
        transform: translateY(0);
    } */
    
    /* Enhanced keyboard-active state for input area */
    .quiz-chat-floating.keyboard-active .quiz-chat-input-area {
        min-height: 80px;
        /* Stronger positioning to prevent cutoff */
        position: sticky;
        z-index: 10;
        /* Enhanced visibility */
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    /* Enhanced keyboard-active state for messages */
    .quiz-chat-floating.keyboard-active .quiz-chat-messages {
        /* Adjust messages area when keyboard is active */
        flex: 1;
        min-height: 150px;
        padding-bottom: 30px !important;
    }
    
    /* Simplified mobile chat messages with flexible height calculations */
    .quiz-chat-floating .quiz-chat-messages {
        /* Use flexible calculation that adapts to content */
        flex: 1;
        min-height: 200px; /* Minimum readable height */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        /* Extra padding to ensure last message is fully visible */
        padding: 15px 20px 25px 20px !important; /* Generous bottom padding */
        /* Ensure proper scrolling on iOS */
        touch-action: pan-y;
    }
    
    /* Better input area handling in mobile floating mode */
    .quiz-chat-floating .quiz-chat-input-area {
        padding: 12px 15px !important;
        /* Add safe area insets for devices with notches/home indicators */
        padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
        background: white;
        border-top: 1px solid #dee2e6;
        min-height: 75px; /* Minimum height to ensure visibility */
        max-height: 120px; /* Prevent from getting too tall */
        flex-shrink: 0;
        /* Ensure it stays at bottom and visible */
        position: relative;
        bottom: 0;
        /* Better mobile spacing */
        box-sizing: border-box;
        /* Prevent any overflow issues */
        overflow: visible;
    }
    
    /* Enhanced send button container for mobile */
    .quiz-chat-floating .quiz-chat-input-area .d-flex {
        align-items: flex-end; /* Align button to bottom for better visibility */
        gap: 10px;
        min-height: 40px; /* Ensure minimum container height */
    }
    
    /* Enhanced send button positioning */
    .quiz-chat-floating #sendQuizChatBtnMobile {
        margin-bottom: 2px; /* Small margin to ensure full visibility */
        flex-shrink: 0;
        align-self: flex-end;
    }
    
    /* Simplified chat header with fixed height */
    .quiz-chat-floating .quiz-chat-header {
        height: 60px; /* Fixed height for consistent calculations */
        flex-shrink: 0;
        display: flex;
        align-items: center;
        padding: 15px 20px;
    }
    
    /* Perfect alignment for mobile chat header content */
    .quiz-chat-floating .quiz-chat-header .d-flex {
        width: 100%;
        flex-wrap: nowrap !important; /* Prevent wrapping */
        align-items: center !important;
        justify-content: space-between !important; /* Text left, button right */
    }
    
    /* Make the title aligned to the left */
    .quiz-chat-floating .quiz-chat-header h6 {
        flex: 1;
        white-space: nowrap; /* Prevent text wrapping */
        overflow: hidden;
        text-overflow: ellipsis; /* Add ellipsis if text is too long */
        margin: 0; /* Remove default margin */
        text-align: left; /* Explicitly align text to the left */
        display: flex;
        align-items: center; /* Only center vertically, not horizontally */
        justify-content: flex-start; /* Align content to the start (left) */
    }
    
    /* Perfect alignment for the close button */
    .quiz-chat-floating .quiz-chat-header .btn-close {
        flex-shrink: 0; /* Prevent the close button from shrinking */
        width: 24px; /* Fixed width for consistency */
        height: 24px; /* Fixed height for consistency */
        padding: 0; /* Remove padding for better visual alignment */
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px; /* Slightly rounded */
        transition: background-color 0.2s ease; /* Smooth hover effect */
    }
    
    /* Hover effect for close button */
    .quiz-chat-floating .quiz-chat-header .btn-close:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Special handling for quiz area when mobile chat is active */
    body:has(.quiz-chat-floating.active) {
        .quiz-main-panel,
        #quiz {
            height: calc(45vh - 20px) !important;
            max-height: calc(45vh - 20px) !important;
            overflow-y: auto !important;
            touch-action: pan-y !important;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain !important;
            scroll-behavior: smooth !important;
        }
    }
    
    /* Enhanced mobile viewport handling */
    @supports (height: 100svh) {
        /* Use small viewport height for better mobile support */
        body:has(.quiz-chat-floating.active) .quiz-main-panel,
        body:has(.quiz-chat-floating.active) #quiz {
            height: calc(45svh - 20px) !important;
            max-height: calc(45svh - 20px) !important;
        }
        
        .quiz-chat-floating {
            max-height: 55svh;
        }
        
        .quiz-chat-floating .quiz-chat-messages {
            max-height: calc(55svh - 140px);
            min-height: calc(55svh - 140px);
        }
    }
    
    /* Fallback for browsers without :has() support */
    @supports not (selector(:has(*))) {
        /* Use a more direct approach targeting active chat */
        .quiz-chat-floating.active {
            /* Mark that chat is active */
            z-index: 1070;
        }
        
        /* Apply styles when floating chat is active - universal selectors */
        .quiz-chat-floating.active ~ * .quiz-main-panel,
        .quiz-chat-floating.active ~ * #quiz,
        .quiz-chat-floating.active ~ .container .quiz-main-panel,
        .quiz-chat-floating.active ~ .container #quiz,
        .quiz-chat-floating.active ~ main .quiz-main-panel,
        .quiz-chat-floating.active ~ main #quiz {
            height: calc(45vh - 20px) !important;
            max-height: calc(45vh - 20px) !important;
            overflow-y: auto !important;
            touch-action: pan-y !important;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain !important;
            scroll-behavior: smooth !important;
        }
    }
    
    /* Additional robust targeting for quiz content */
    .quiz-modal-fullscreen:has(.quiz-chat-floating.active) .quiz-main-panel,
    .quiz-modal-fullscreen:has(.quiz-chat-floating.active) #quiz {
        height: calc(45vh - 20px) !important;
        max-height: calc(45vh - 20px) !important;
        overflow-y: auto !important;
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }
    
    /* Fallback using adjacent sibling combinator */
    .quiz-chat-floating.active ~ .quiz-modal-fullscreen .quiz-main-panel,
    .quiz-chat-floating.active ~ .quiz-modal-fullscreen #quiz {
        height: calc(45vh - 20px) !important;
        max-height: calc(45vh - 20px) !important;
        overflow-y: auto !important;
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }

    .quiz-modal-fullscreen {
        padding: 0;
    }

    .quiz-modal-fullscreen .modal-body {
        padding: 10px !important;
    }

    .quiz-modal-fullscreen .quiz-modal-header {
        padding: 10px !important;
    }

    .quiz-chat-panel {
        width: 100% !important;
        height: 50vh !important;
    }
}

/* Desktop optimization for larger screens */
@media (min-width: 1200px) {
    .quiz-chat-panel {
        min-height: calc(100vh - 100px); /* More space on larger screens */
    }
    
    .quiz-chat-panel .quiz-chat-messages {
        height: calc(100vh - 180px);
        min-height: 500px;
        padding: 24px; /* More padding on larger screens */
    }
    
    .quiz-chat-panel .quiz-chat-header {
        padding: 20px 28px; /* Enhanced padding for large screens */
    }
    
    .quiz-chat-panel .quiz-chat-input-area {
        padding: 20px 24px;
    }
}

/* Topic Questions Card Styles - MOVED TO questions.css */
/* 
Note: All topic-questions styles have been moved to questions.css for 
centralized management across aprender.php and resueltos.php views.
This ensures consistent design and avoids conflicts.
*/

/* Unlock Course Modal Styles for aprender.php */
.subscription-options-unlock {
    margin: 1.5rem 0;
}

.subscription-card-unlock {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    color: #333;
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}

.subscription-card-unlock:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.subscription-card-unlock.monthly-plan {
    position: relative;
    border: 2px solid #ffd700 !important;
}

.subscription-card-unlock.custom-plan {
    position: relative;
}

.popular-badge-unlock {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffd700;
    color: #333;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 700;
}

.subscription-card-unlock .plan-header {
    text-align: center;
    margin-bottom: 1rem;
    margin-top: 1rem;
}

/* .subscription-card-unlock .plan-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #333;
} */

.subscription-card-unlock .plan-subtitle {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0;
}

.subscription-card-unlock .plan-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.2rem;
    margin: 0.8rem 0;
}

.subscription-card-unlock .currency {
    font-size: 1rem;
    font-weight: 600;
    color: #667eea;
}

.subscription-card-unlock .amount {
    font-size: 1.8rem;
    font-weight: 800;
    color: #333;
}

.subscription-card-unlock .period {
    font-size: 0.9rem;
    color: #666;
}

.subscription-card-unlock .plan-features {
    margin-bottom: 1rem;
}

.subscription-card-unlock .plan-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.subscription-card-unlock .plan-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.subscription-card-unlock .plan-features .bi-check-circle-fill {
    color: #28a745;
    font-size: 0.9rem;
}

.btn-subscribe-unlock {
    width: 100%;
    border: none;
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-subscribe-unlock.monthly {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-subscribe-unlock.monthly:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    color: white;
}

.btn-subscribe-unlock.custom {
    background: linear-gradient(135deg, #ff9500 0%, #ff6b35 100%);
}

.btn-subscribe-unlock.custom:hover {
    background: linear-gradient(135deg, #e8850a 0%, #e55a2b 100%);
    transform: translateY(-2px);
    color: white;
}

.custom-plans-list {
    margin-bottom: 1rem;
}

.custom-plan-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.6rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.plan-duration {
    font-weight: 600;
    color: #333;
    font-size: 0.85rem;
}

.plan-price-custom {
    display: flex;
    align-items: baseline;
    gap: 0.1rem;
}

.plan-price-custom .currency {
    font-size: 0.8rem;
    font-weight: 600;
    color: #667eea;
}

.plan-price-custom .amount {
    font-size: 1.1rem;
    font-weight: 800;
    color: #333;
}


/* Estilos para contenido bloqueado clickeable */
.content-item.locked-content {
    position: relative;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.content-item.locked-content:hover {
    border-color: #4f46e5;
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.content-item.locked-content .content-item-title {
    position: relative;
}

.content-item.locked-content .access-indicator {
    color: #6b7280;
    margin-left: 8px;
    transition: color 0.3s ease;
}

.content-item.locked-content:hover .access-indicator {
    color: #4f46e5;
}

.access-type-badge {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-weight: 600;
    margin-left: 0.5rem;
}

.unlock-hint {
    color: #4f46e5;
    transition: all 0.3s ease;
}

.content-item.locked-content:hover .unlock-hint {
    transform: translateX(3px);
    color: #7c3aed;
}

/* Mejoras en la lista de contenido bloqueado */
.blocked-content-preview {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
}

.blocked-content-list {
    display: grid;
    gap: 0.75rem;
}

.blocked-content-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.blocked-content-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
}

.blocked-content-item i {
    font-size: 1.1rem;
    opacity: 0.8;
}

.blocked-content-item.more-content {
    font-style: italic;
    opacity: 0.8;
}