/**
 * E-Learning Module Player CSS
 * File: /wp-content/plugins/elearning-system/public/css/module-player.css
 *
 * Fixes:
 *  - Audio controls visibility
 *  - Whitespace above questions (slides container hidden properly)
 *  - Question feedback and button states
 */

/* ================================================================
   BASE PLAYER STYLES
   ================================================================ */

.elearning-module-player {
    max-width: 1200px;
    margin: 20px auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 2px solid #dc3545;
}

/* ================================================================
   HEADER
   ================================================================ */

.elearning-header {
    background: linear-gradient(135deg, #000, #333);
    color: #fff;
    padding: 2rem;
    text-align: center;
}

.module-title {
    font-size: 1.75rem;
    margin: 0 0 0.5rem;
    font-weight: 700;
}

.module-description {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0 0 1rem;
}

.progress-indicator {
    margin-top: 1rem;
}

.progress-bar {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc3545, #c82333);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    opacity: 0.9;
}

/* ================================================================
   NAVIGATION
   ================================================================ */

.elearning-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.slide-counter {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    padding: 0.5rem 1rem;
    background: #fff;
    border-radius: 20px;
    border: 1px solid #dee2e6;
}

.nav-button {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-button:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220,53,69,0.3);
}

.nav-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.nav-prev {
    background: #000;
}

.nav-prev:hover:not(:disabled) {
    background: #333;
}

/* ================================================================
   SLIDES CONTAINER - CRITICAL WHITESPACE FIX
   ================================================================ */

.elearning-slides-container {
    /* No min-height - collapses when hidden */
    min-height: 0 !important;
    height: auto !important;
}

.elearning-slides-container[style*="display: none"],
.elearning-slides-container[style*="display:none"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

/* ================================================================
   SLIDES
   ================================================================ */

.elearning-slide {
    padding: 2rem;
    min-height: 0;
    height: auto;
}

.elearning-slide[style*="display: none"],
.elearning-slide[style*="display:none"] {
    display: none !important;
    padding: 0 !important;
    height: 0 !important;
}

.slide-content {
    min-height: 0;
    height: auto;
}

.slide-title {
    font-size: 1.75rem;
    color: #000;
    margin: 0 0 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.slide-text {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #333;
    margin-bottom: 1.5rem;
}

.slide-text p:last-child {
    margin-bottom: 0;
}

.slide-text img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 1rem 0;
}

/* ================================================================
   AUDIO - CRITICAL FIX FOR CONTROLS
   ================================================================ */

.slide-audio {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Force audio element to be visible with controls */
.slide-audio audio {
    display: block !important;
    width: 100% !important;
    max-width: 500px !important;
    height: 40px !important;
    margin: 10px 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure controls attribute works */
.slide-audio audio::-webkit-media-controls-panel {
    display: flex !important;
}

.slide-audio audio::-webkit-media-controls {
    display: flex !important;
}

/* Play prompt for autoplay blocked */
.audio-play-prompt {
    display: none;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
    align-items: center;
    gap: 12px;
}

.audio-play-prompt.visible,
.audio-play-prompt[style*="display: block"],
.audio-play-prompt[style*="display: flex"] {
    display: flex !important;
}

.audio-play-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
}

.audio-play-btn:hover {
    background: #c82333;
}

.audio-prompt-text {
    color: #856404;
    font-size: 0.9rem;
}

.slide-no-audio {
    display: none;
}

/* ================================================================
   BREADCRUMB
   ================================================================ */

.elearning-back-to-modules {
    padding: 0.75rem 2rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.875rem;
}

.elearning-back-to-modules a {
    color: #dc3545;
    text-decoration: none;
    font-weight: 500;
}

.elearning-back-to-modules a:hover {
    text-decoration: underline;
}

.elearning-back-to-modules .sep {
    margin: 0 0.5rem;
    color: #999;
}

.elearning-back-to-modules .current {
    color: #666;
}

/* ================================================================
   QUESTIONS SECTION
   ================================================================ */

.elearning-module-questions {
    padding: 2rem;
    background: #fff;
}

.elearning-module-questions[style*="display: none"] {
    display: none !important;
}

.questions-header {
    margin-bottom: 2rem;
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid #dc3545;
}

.questions-header h3 {
    font-size: 1.5rem;
    color: #000;
    margin: 0 0 0.5rem;
    font-weight: 700;
}

.questions-header p {
    color: #666;
    margin: 0;
    font-size: 1rem;
}

.question-block {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.question-options {
    margin-bottom: 1rem;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-label:hover {
    border-color: #dc3545;
    background: #fff5f5;
}

.option-label.selected {
    border-color: #dc3545;
    background: rgba(220,53,69,0.05);
}

.option-label.incorrect {
    border-color: #dc3545;
    background: rgba(220,53,69,0.1);
}

.option-label.answered {
    border-color: #28a745;
    background: rgba(40,167,69,0.05);
}

.option-label input[type="radio"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.option-text {
    flex: 1;
    font-size: 1rem;
}

.question-feedback {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.question-feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.question-feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.submit-answer {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.submit-answer:hover:not(:disabled) {
    background: #c82333;
}

.submit-answer:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ================================================================
   MODULE COMPLETION BUTTON
   ================================================================ */

.module-completion {
    text-align: center;
    padding: 2rem 0 1rem;
    border-top: 1px solid #dee2e6;
    margin-top: 1.5rem;
}

#complete-module {
    background: #6c757d;
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: not-allowed;
    opacity: 0.6;
    transition: all 0.3s ease;
}

#complete-module:not(:disabled) {
    background: #28a745;
    cursor: pointer;
    opacity: 1;
}

#complete-module:not(:disabled):hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40,167,69,0.3);
}

#complete-module.ready {
    background: #28a745 !important;
    cursor: pointer !important;
    opacity: 1 !important;
}

/* ================================================================
   COMPLETION SCREEN
   ================================================================ */

.elearning-completion {
    padding: 3rem 2rem;
    text-align: center;
}

.completion-message {
    max-width: 500px;
    margin: 0 auto;
}

.completion-icon {
    width: 80px;
    height: 80px;
    background: #28a745;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem;
}

.completion-message h3 {
    font-size: 1.75rem;
    color: #28a745;
    margin: 0 0 0.75rem;
}

.completion-message p {
    color: #666;
    font-size: 1.1rem;
    margin: 0 0 2rem;
}

.completion-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.completion-actions .button {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
}

.completion-actions .button-primary {
    background: #dc3545;
    color: #fff;
    border: none;
}

.completion-actions .button-primary:hover {
    background: #c82333;
    color: #fff;
}

.completion-actions .return-home {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.completion-actions .return-home:hover {
    background: #e9ecef;
}

/* ================================================================
   LOGIN NOTICE
   ================================================================ */

.elearning-login-notice {
    background: #d1ecf1;
    color: #0c5460;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 2rem;
    text-align: center;
    font-size: 0.9rem;
    border-left: 4px solid #17a2b8;
}

.elearning-login-notice a {
    color: #0c5460;
    font-weight: 600;
}

/* ================================================================
   ERROR STYLES
   ================================================================ */

.elearning-error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 1rem 0;
    font-weight: 500;
    border-left: 4px solid #dc3545;
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */

.elearning-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    z-index: 99999;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
    .elearning-slide {
        padding: 1.5rem;
    }
    
    .elearning-navigation {
        padding: 0.75rem 1rem;
    }
    
    .nav-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .elearning-module-questions {
        padding: 1.5rem;
    }
    
    .slide-audio audio {
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    .elearning-module-player {
        margin: 10px;
        border-radius: 4px;
    }
    
    .elearning-slide {
        padding: 1rem;
    }
    
    .slide-title {
        font-size: 1.25rem;
    }
    
    .module-title {
        font-size: 1.25rem;
    }
    
    .nav-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .elearning-header {
        padding: 1.5rem 1rem;
    }
}

/* ================================================================
   PRINT
   ================================================================ */

@media print {
    .elearning-navigation,
    .elearning-back-to-modules,
    .slide-audio,
    .audio-play-prompt {
        display: none !important;
    }
    
    .elearning-module-player {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Round 60: make frontend question text visible */
.elearning-module-player .elearning-module-questions,
.elearning-module-player .elearning-module-questions *,
.elearning-player .elearning-module-questions,
.elearning-player .elearning-module-questions *,
.elearning-question-container,
.elearning-question-container *,
.question-block,
.question-block *,
.question-options,
.question-options *,
.option-label,
.option-label * {
    color: #1d2327 !important;
}
.elearning-module-player .questions-header h3,
.elearning-module-player .question-text,
.elearning-module-player .option-text,
.elearning-question-title,
.elearning-question-text {
    color: #1d2327 !important;
}
.elearning-module-player .option-label,
.question-block .option-label,
.elearning-answer-option {
    background: #ffffff !important;
}


/* eLearn 1.0.107: keep answer option text the same size as the question instruction text. */
.elearning-module-player .questions-header p,
.elearning-module-player .option-text,
.elearning-player .questions-header p,
.elearning-player .option-text {
    font-family: Lato, Arial, sans-serif !important;
    font-size: 1.45rem !important;
    line-height: 1.4 !important;
}
