/* Quiz System Styles */

/* Base Quiz Container */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

/* Start Screen */
.start-screen {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
}

.start-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    padding: 1rem 3rem;
    border-radius: 9999px;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.start-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

/* Timer */
.timer-display {
    position: fixed;
    top: 100px;
    right: 2rem;
    background: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #2F5233;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid #8BC34A;
    z-index: 100;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 9999px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* Stabilize Navigation */
.question-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 2px solid #e2e8f0;
    animation: slideIn 0.4s ease;
    /* HCI Fix: Min height to prevent buttons from jumping */
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Push content up so if it's short, it stays top, but card remains tall */
.question-content-wrapper {
    flex-grow: 1;
}

/* New Premium Summary Styles */
.summary-header {
    font-size: 2.5rem;
    font-weight: 800;
    color: #2F5233;
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 2px 2px 0px rgba(139, 195, 74, 0.2);
}

.summary-info-box {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #bbf7d0;
    border-radius: 1.5rem;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 3rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.info-item {
    text-align: center;
    flex: 1;
}

.info-divider {
    width: 2px;
    height: 40px;
    background: #bbf7d0;
    margin: 0 1rem;
}

.info-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.info-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
}

.score-circle-wrapper {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 0 auto 3rem;
}

.score-circle-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 2;
    box-shadow: 0 10px 25px -5px rgba(34, 197, 94, 0.25);
    border: 8px solid #f0fdf4;
}

/* Gradient Ring */
.score-circle-wrapper::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(to bottom right, #4ade80, #22c55e);
    z-index: 1;
}

.score-circle-sub {
    font-size: 0.875rem;
    font-weight: 700;
    color: #8BC34A;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.score-circle-value {
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1;
    color: #2F5233;
    padding-bottom: 0.5rem;
}

.score-circle-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    padding: 0.25rem 1rem;
    background: #f1f5f9;
    border-radius: 9999px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: currentColor;
}

.stat-card.correct {
    color: #22c55e;
}

.stat-card.wrong {
    color: #f59e0b;
}

.stat-card.accuracy {
    color: #3b82f6;
}

.stat-card.average {
    color: #a855f7;
}

.stat-card.correct .stat-icon {
    background: #22c55e;
}

.stat-card.wrong .stat-icon {
    background: #f59e0b;
}

.stat-card.accuracy .stat-icon {
    background: #3b82f6;
}

.stat-card.average .stat-icon {
    background: #a855f7;
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    /* background: currentColor; REMOVED to fix white-on-white issue */
    color: white;
    opacity: 0.9;
}

.stat-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.stat-label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
}

.action-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.retry-btn-mini {
    background: #f1f5f9;
    color: #475569;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.retry-btn-mini:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.dashboard-btn {
    background: #2F5233;
    color: white;
    padding: 1rem 3rem;
    border-radius: 9999px;
    font-weight: 700;
    transition: all 0.2s;
    display: inline-block;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(47, 82, 51, 0.3);
}

.dashboard-btn:hover {
    background: #3d6b42;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(47, 82, 51, 0.4);
}

.question-number {
    font-size: 0.875rem;
    color: #8BC34A;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2F5233;
    margin-bottom: 2rem;
    line-height: 1.4;
}

/* MCQ Options */
.options-grid {
    display: grid;
    gap: 1rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.option-btn:hover:not(.disabled) {
    border-color: #8BC34A;
    background: #f0fdf4;
    transform: translateX(5px);
}

.option-btn.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

.option-btn.correct {
    border-color: #22c55e;
    background: #dcfce7;
    animation: pulse-correct 0.5s ease;
}

.option-btn.incorrect {
    border-color: #ef4444;
    background: #fee2e2;
    animation: shake 0.5s ease;
}

.option-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.option-label {
    width: 2.5rem;
    height: 2.5rem;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #64748b;
    flex-shrink: 0;
}

.option-btn.correct .option-label {
    background: #22c55e;
    color: white;
}

.option-btn.incorrect .option-label {
    background: #ef4444;
    color: white;
}

@keyframes pulse-correct {

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

    50% {
        transform: scale(1.02);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

/* Dropdown Question */
.dropdown-container {
    margin-top: 1rem;
}

.quiz-dropdown {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-dropdown:focus {
    outline: none;
    border-color: #8BC34A;
}

.quiz-dropdown.correct {
    border-color: #22c55e;
    background: #dcfce7;
}

.quiz-dropdown.incorrect {
    border-color: #ef4444;
    background: #fee2e2;
}

/* Drag and Drop */
.drag-drop-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.drag-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 1rem;
    min-height: 60px;
}

.drag-item {
    padding: 0.75rem 1.25rem;
    background: white;
    border: 2px solid #8BC34A;
    border-radius: 0.5rem;
    cursor: grab;
    font-weight: 500;
    transition: all 0.2s ease;
}

.drag-item:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.drag-item.dragging {
    opacity: 0.5;
}

.drop-zone {
    min-height: 80px;
    border: 2px dashed #cbd5e1;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem;
    transition: all 0.2s ease;
}

.drop-zone.drag-over {
    border-color: #8BC34A;
    background: #f0fdf4;
}

.drop-zone.correct {
    border-color: #22c55e;
    background: #dcfce7;
    border-style: solid;
}

.drop-zone.incorrect {
    border-color: #ef4444;
    background: #fee2e2;
    border-style: solid;
}

/* Matching Question */
.matching-container {
    display: flex;
    justify-content: space-between;
    gap: 4rem;
    position: relative;
}

.matching-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Reduced from 1rem */
}

.match-item {
    padding: 0.75rem 1rem; /* Reduced vertical padding */
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.9rem; /* Slightly smaller font */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.5rem; /* Ensure consistent minimum height */
    line-height: 1.3;
}

.match-item:hover {
    border-color: #8BC34A;
}

.match-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

.match-item.matched {
    border-color: #22c55e;
    background: #dcfce7;
}

.match-item.incorrect {
    border-color: #ef4444;
    background: #fee2e2;
}

/* SVG Lines for matching */
.lines-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.match-line {
    stroke: #8BC34A;
    stroke-width: 3;
    fill: none;
}

.match-line.correct {
    stroke: #22c55e;
}

.match-line.incorrect {
    stroke: #ef4444;
}

/* Main Horizontal Layout */
.quiz-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    padding: 0 1rem;
}

.quiz-center {
    flex: 1;
    max-width: 800px;
    position: relative;
}

.nav-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 80px;
    /* FIX PLACED: Sticky positioning to keep buttons visible while scrolling */
    position: sticky;
    top: 50vh;
    transform: translateY(-50%);
    z-index: 20;
    height: fit-content;
}

.nav-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.nav-btn.prev {
    background: white;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.nav-btn.prev:hover:not(:disabled) {
    border-color: #8BC34A;
    color: #2F5233;
    transform: translateX(-3px);
}

.nav-btn.next {
    background: #2F5233;
    color: white;
}

.nav-btn.next:hover {
    background: #3d6b42;
    transform: translateX(3px);
}





.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback Overlay */
.feedback-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 2rem 4rem;
    border-radius: 1rem;
    font-size: 2rem;
    font-weight: 700;
    z-index: 1000;
    animation: popIn 0.4s ease;
}

.feedback-overlay.correct {
    background: #22c55e;
    box-shadow: 0 10px 40px -5px rgba(34, 197, 94, 0.4);
}

.feedback-overlay.incorrect {
    background: #f59e0b;
    /* Amber-500: Softer, less punishing than red */
    box-shadow: 0 10px 40px -5px rgba(245, 158, 11, 0.4);
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Summary Screen */
.summary-screen {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.summary-card {
    background: white;
    border-radius: 2.5rem;
    padding: 3rem;
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
    max-width: 700px;
    width: 100%;
    border: 1px solid #f0fdf4;
    text-align: center;
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }

    .summary-card,
    .summary-card * {
        visibility: visible;
    }

    .summary-card {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-width: none;
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .action-buttons {
        display: none !important;
    }

    .bg-\[\#FDFEF8\] {
        background: white !important;
    }
}

.summary-score {
    font-size: 5rem;
    font-weight: 800;
    color: #2F5233;
    line-height: 1;
}

.summary-score span {
    font-size: 2rem;
    color: #64748b;
}

.summary-time {
    font-size: 1.25rem;
    color: #64748b;
    margin: 1rem 0 2rem;
}

.summary-breakdown {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
}

.breakdown-item {
    text-align: center;
}

.breakdown-number {
    font-size: 2.5rem;
    font-weight: 700;
}

.breakdown-number.correct-count {
    color: #22c55e;
}

.breakdown-number.incorrect-count {
    color: #ef4444;
}

.breakdown-label {
    font-size: 0.875rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.retry-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    padding: 1rem 3rem;
    border-radius: 9999px;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    margin-top: 2rem;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .quiz-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "content content"
            "prev next";
        gap: 1.5rem;
        padding: 0 1rem 6rem; /* Extra bottom padding for scroll */
        align-items: start;
    }

    .quiz-center {
        grid-area: content;
        width: 100%;
        max-width: 100%;
    }

    .nav-side {
        position: static;
        transform: none;
        height: auto;
        min-width: auto;
        flex-direction: row; /* Horizontal alignment for button + label */
        gap: 0.75rem;
    }

    .nav-side.left {
        grid-area: prev;
        justify-self: start;
    }

    .nav-side.right {
        grid-area: next;
        justify-self: end;
        flex-direction: row-reverse; /* Button on right, label on left */
    }

    .nav-btn {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .nav-label {
        font-size: 0.8rem;
        display: none; /* Hide labels on smallest screens to save collision space */
    }
    
    /* Reveal labels if screen is slightly larger but still mobile tablet */
    @media (min-width: 480px) {
        .nav-label {
            display: block;
        }
    }

    .question-card {
        padding: 1.5rem;
        min-height: auto;
    }

    .question-text {
        font-size: 1.15rem; /* Smaller text for mobile */
        margin-bottom: 1.5rem;
    }

    /* Adjust Timer to be less intrusive */
    .timer-display {
        position: absolute; /* Relative to container instead of fixed, or top right */
        top: -3.5rem;
        right: 0;
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
    
    .quiz-container {
        margin-top: 3rem; /* Space for timer */
    }

    /* Matching Question Mobile Fix */
    .matching-container {
        flex-direction: column;
        gap: 2rem;
    }
    
    .lines-svg {
        display: none; /* Hide drawn lines on mobile as they won't align with column stack */
    }
    
    /* Give visual cue for matching selected state since lines are gone */
    .match-item.selected {
        box-shadow: 0 0 0 3px #3b82f6;
    }
    
    .match-item.matched {
        opacity: 0.5;
    }
}