/**
 * IELTS Frontend CSS - Enhanced Version
 * File: public/css/frontend.css
 */

/* ============================================
   GLOBAL & RESET
============================================ */
.ielts-take-test-wrapper {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

.ielts-take-test-wrapper * {
    box-sizing: border-box;
}

/* ============================================
   STICKY HEADER
============================================ */
.ielts-test-header.sticky-header {
    position: sticky;
    top: 32px; /* WordPress admin bar */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media screen and (max-width: 782px) {
    .ielts-test-header.sticky-header {
        top: 46px; /* Mobile admin bar */
    }
}

.header-left {
    flex: 1;
}

.test-title {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

.test-meta {
    display: flex;
    gap: 12px;
    align-items: center;
}

.current-section-badge,
.progress-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
}

.header-right {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* ============================================
   TIMER
============================================ */
.ielts-timer {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.15);
    padding: 12px 20px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.timer-icon {
    font-size: 28px;
}

.timer-display {
    display: flex;
    flex-direction: column;
}

.timer-time {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

.timer-label {
    font-size: 11px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ielts-timer.timer-warning {
    background: rgba(255,193,7,0.3);
    animation: pulse-warning 1s infinite;
}

.ielts-timer.timer-danger {
    background: rgba(244,67,54,0.3);
    animation: pulse-danger 0.5s infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================
   HEADER ACTIONS
============================================ */
.header-actions {
    display: flex;
    gap: 10px;
}

/* ============================================
   BUTTONS
============================================ */
.ielts-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.ielts-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ielts-btn-primary {
    background: #4CAF50;
    color: #fff;
}

.ielts-btn-primary:hover {
    background: #45a049;
}

.ielts-btn-secondary {
    background: rgba(255,255,255,0.9);
    color: #667eea;
}

.ielts-btn-secondary:hover {
    background: #fff;
}

.ielts-btn-large {
    padding: 14px 28px;
    font-size: 16px;
}

.ielts-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ============================================
   PROGRESS BAR
============================================ */
.ielts-progress-container {
    background: #fff;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
}

.progress-bar-wrapper {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
}

.progress-text {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 14px;
    color: #666;
}

.progress-info strong {
    color: #667eea;
    font-weight: 700;
}

/* ============================================
   SECTION NAVIGATION
============================================ */
.ielts-section-navigation {
    background: #f9f9f9;
    padding: 15px 30px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.section-nav-title {
    font-weight: 600;
    color: #333;
}

.section-nav-items {
    display: flex;
    gap: 10px;
}

.section-nav-item {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-decoration: none;
    color: #666;
    font-weight: 600;
    transition: all 0.3s;
}

.section-nav-item:hover {
    border-color: #667eea;
    color: #667eea;
}

.section-nav-item.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
}

/* ============================================
   MAIN LAYOUT
============================================ */
.ielts-test-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================
   QUESTIONS AREA
============================================ */
.questions-area {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.question-part {
    margin-bottom: 40px;
}

.part-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 20px 25px;
    border-radius: 12px 12px 0 0;
    margin-bottom: 20px;
}

.part-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.part-title h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.part-questions-count {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

/* ============================================
   AUDIO PLAYER
============================================ */
.audio-player-wrapper {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
}

.ielts-audio-player {
    width: 100%;
    height: 40px;
}

/* ============================================
   QUESTION ITEMS
============================================ */
.part-questions-list {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.question-item {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 0;
    transition: all 0.3s;
    overflow: hidden;
}

.question-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102,126,234,0.1);
}

.question-item.answered {
    border-color: #4CAF50;
    background: #f1f8f4;
}

.question-header-bar {
    background: linear-gradient(90deg, #f5f5f5, #fafafa);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.question-number-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
}

.question-label {
    font-size: 12px;
    opacity: 0.9;
}

.question-num {
    font-size: 18px;
}

.question-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #666;
}

.question-type {
    background: #e3f2fd;
    padding: 4px 10px;
    border-radius: 12px;
    color: #1976d2;
    font-weight: 600;
}

.question-points {
    background: #fff3e0;
    padding: 4px 10px;
    border-radius: 12px;
    color: #f57c00;
    font-weight: 600;
}

.question-status {
    font-size: 13px;
    font-weight: 600;
}

.status-answered {
    color: #4CAF50;
}

.status-unanswered {
    color: #999;
}

/* ============================================
   QUESTION CONTENT
============================================ */
.question-content-area {
    padding: 25px;
}

.question-text-content {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    margin-bottom: 20px;
}

.question-text-content h3,
.question-text-content h4 {
    color: #667eea;
    margin-top: 20px;
    margin-bottom: 12px;
}

.question-text-content p {
    margin-bottom: 12px;
}

.question-text-content ul,
.question-text-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.question-text-content strong {
    color: #333;
    font-weight: 700;
}

.question-image-wrapper {
    margin: 20px 0;
    text-align: center;
}

.question-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ============================================
   ANSWER INPUTS
============================================ */
.answer-input-area {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 2px dashed #e0e0e0;
}

/* Multiple Choice */
.answer-multiple-choice {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.choice-option:hover {
    background: #f0f4ff;
    border-color: #667eea;
}

.choice-option.selected {
    background: #e8f5e9;
    border-color: #4CAF50;
}

.choice-option input[type="radio"] {
    display: none;
}

.choice-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 50%;
    font-weight: 700;
    color: #666;
    flex-shrink: 0;
}

.choice-option.selected .choice-marker {
    background: #4CAF50;
    border-color: #4CAF50;
    color: #fff;
}

.choice-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
}

.choice-checkmark {
    display: none;
    font-size: 24px;
    color: #4CAF50;
}

.choice-option.selected .choice-checkmark {
    display: block;
}

/* True/False/Not Given */
.answer-true-false {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.tf-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tf-option:hover {
    background: #f0f4ff;
    border-color: #667eea;
    transform: translateY(-2px);
}

.tf-option.selected {
    background: #e8f5e9;
    border-color: #4CAF50;
}

.tf-option input[type="radio"] {
    display: none;
}

.tf-text {
    font-size: 16px;
    font-weight: 700;
    color: #666;
}

.tf-option.selected .tf-text {
    color: #4CAF50;
}

.tf-checkmark {
    display: none;
    font-size: 20px;
    color: #4CAF50;
    margin-top: 8px;
}

.tf-option.selected .tf-checkmark {
    display: block;
}

/* Essay */
.answer-essay {
    width: 100%;
}

.essay-textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.8;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

.essay-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.essay-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 13px;
}

.word-count,
.char-count {
    display: flex;
    align-items: center;
    gap: 8px;
}

.word-count strong,
.char-count strong {
    font-size: 18px;
    color: #667eea;
    font-weight: 700;
}

.min-words {
    color: #999;
    font-size: 12px;
}

/* Speaking */
.answer-speaking {
    width: 100%;
}

.speaking-instructions {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.speaking-instructions p {
    margin: 8px 0;
    font-size: 14px;
    color: #1976d2;
}

.cue-card {
    background: #fff9c4;
    border: 2px solid #fbc02d;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.cue-card-header {
    font-size: 16px;
    font-weight: 700;
    color: #f57f17;
    margin-bottom: 12px;
}

.cue-card-content {
    font-size: 15px;
    line-height: 1.8;
    color: #333;
    white-space: pre-line;
}

.speaking-note label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.speaking-textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    resize: vertical;
}

.speaking-textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Matching */
.answer-matching {
    width: 100%;
}

.matching-options {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.matching-options strong {
    display: block;
    margin-bottom: 12px;
    color: #667eea;
}

.options-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.options-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.options-list li:last-child {
    border-bottom: none;
}

.matching-input {
    width: 150px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
}

.matching-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Text Input */
.answer-text-input {
    width: 100%;
}

.text-answer-input,
.answer-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.text-answer-input:focus,
.answer-input:focus {
    outline: none;
    border-color: #667eea;
}

/* ============================================
   BOTTOM ACTIONS
============================================ */
.test-bottom-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 40px 0 20px 0;
    border-top: 2px solid #e0e0e0;
    margin-top: 40px;
}

/* ============================================
   QUESTION NAVIGATOR (SIDEBAR)
============================================ */
.question-navigator-sidebar {
    position: relative;
}

.navigator-sticky {
    position: sticky;
    top: 180px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.navigator-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.navigator-header h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.navigator-stats {
    font-size: 14px;
    color: #666;
}

.navigator-stats .answered-count {
    color: #4CAF50;
    font-weight: 700;
}

.navigator-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.nav-question-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #666;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s;
}

.nav-question-btn:hover {
    background: #f0f4ff;
    border-color: #667eea;
    color: #667eea;
    transform: scale(1.1);
}

.nav-question-btn.answered {
    background: #e8f5e9;
    border-color: #4CAF50;
    color: #4CAF50;
}

.navigator-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #666;
}

.legend-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #e0e0e0;
}

.legend-box.answered {
    background: #e8f5e9;
    border-color: #4CAF50;
}

.legend-box.unanswered {
    background: #f5f5f5;
}

/* ============================================
   MODALS
============================================ */
.ielts-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Review Modal */
.review-summary {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.review-summary h3 {
    margin-top: 0;
    color: #667eea;
}

.review-summary p {
    margin: 8px 0;
    font-size: 15px;
}

.review-questions h3 {
    color: #667eea;
}

.warning-text {
    color: #f57c00;
    font-weight: 600;
}

.success-text {
    color: #4CAF50;
    font-weight: 600;
}

.unanswered-list {
    background: #fff3e0;
    padding: 15px;
    border-left: 4px solid #ff9800;
    border-radius: 4px;
    font-weight: 700;
    color: #e65100;
}

/* Submit Modal */
.submit-summary {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.submit-summary p {
    margin: 10px 0;
    font-size: 16px;
}

/* ============================================
   LOADING OVERLAY
============================================ */
.ielts-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.ielts-loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ielts-loading-overlay p {
    color: #fff;
    font-size: 18px;
    margin-top: 20px;
}

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

/* ============================================
   NOTICES
============================================ */
.ielts-notice {
    padding: 20px 25px;
    border-radius: 8px;
    margin: 20px 0;
}

.ielts-notice h3 {
    margin-top: 0;
}

.ielts-notice-warning {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    color: #e65100;
}

.ielts-notice-error {
    background: #ffebee;
    border-left: 4px solid #f44336;
    color: #c62828;
}

.ielts-notice-success {
    background: #e8f5e9;
    border-left: 4px solid #4CAF50;
    color: #2e7d32;
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 1200px) {
    .ielts-test-layout {
        grid-template-columns: 1fr;
    }
    
    .question-navigator-sidebar {
        order: -1;
        margin-bottom: 30px;
    }
    
    .navigator-sticky {
        position: static;
    }
}

@media (max-width: 768px) {
    .ielts-test-header.sticky-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
    
    .header-right {
        width: 100%;
        flex-direction: column;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .test-title {
        font-size: 18px;
    }
    
    .timer-time {
        font-size: 20px;
    }
    
    .ielts-test-layout {
        padding: 15px;
        gap: 20px;
    }
    
    .questions-area {
        padding: 20px 15px;
    }
    
    .question-header-bar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .answer-true-false {
        grid-template-columns: 1fr;
    }
    
    .navigator-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .test-bottom-actions {
        flex-direction: column;
    }
    
    .ielts-btn-large {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .part-title {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .navigator-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
