/**
 * Score Entry Form - iPad/Touch Optimized Styles
 * Target: Students aged 11-16 using iPad browsers
 */

/* ===== CORE LAYOUT ===== */

.exam-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.progress-header {
    background: white;
    padding: 16px 20px;
    border-bottom: 2px solid #e0e0e0;
    margin: -20px -20px 20px -20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.question-indicator {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

#currentQ {
    color: #007AFF;
    font-weight: bold;
}

/* ===== QUESTION SCREENS ===== */

.question-screen {
    display: none;
    animation: fadeIn 0.2s ease-in;
}

.question-screen[data-visible="true"] {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-question-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 3px solid #007AFF;
}

/* ===== SUB-QUESTION CARDS ===== */

.sub-question {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #f0f0f0;
    transition: border-color 0.2s ease;
}

.sub-question:hover {
    border-color: #007AFF;
}

.sub-question-label {
    display: block;
    margin-bottom: 12px;
    line-height: 1.5;
}

.q-number {
    display: inline-block;
    font-size: 16px;
    font-weight: bold;
    color: #007AFF;
    margin-right: 8px;
}

.q-topic {
    font-size: 16px;
    color: #333;
}

.q-marks {
    display: inline-block;
    font-size: 14px;
    color: #666;
    margin-left: 8px;
    font-style: italic;
}

/* ===== SCORE BUTTONS ===== */

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.button-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

/* For large button groups (6-7 buttons), use two rows */
.button-group-large .button-row {
    width: 100%;
    justify-content: flex-start;
}

.score-btn {
    /* Touch-friendly sizing */
    min-width: 52px;
    min-height: 52px;
    padding: 12px;

    /* Typography */
    font-size: 20px;
    font-weight: 600;

    /* Styling - Unselected state */
    background: #f5f5f7;
    border: 3px solid #d1d1d6;
    border-radius: 10px;
    color: #333;

    /* Interaction */
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;

    /* Prevent text selection on double-tap */
    user-select: none;
    -webkit-user-select: none;
}

/* Touch feedback */
.score-btn:active {
    transform: scale(0.95);
}

/* Selected state */
.score-btn[data-selected="true"] {
    background: #007AFF;
    border-color: #007AFF;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

/* Hover state (for desktop/iPad with pointer) */
@media (hover: hover) {
    .score-btn:hover:not([data-selected="true"]) {
        border-color: #007AFF;
        background: #e8f4ff;
    }
}

/* Small buttons for inline display (1-4 buttons) */
.button-group:not(.button-group-large) .score-btn {
    flex: 0 0 auto;
}

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

.nav-buttons {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 16px 20px;
    margin: 24px -20px -20px -20px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    z-index: 100;
}

.nav-btn {
    /* Sizing */
    flex: 1;
    min-height: 52px;
    padding: 14px 24px;

    /* Typography */
    font-size: 18px;
    font-weight: 600;

    /* Styling */
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;

    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
}

#prevBtn {
    background: white;
    border: 3px solid #007AFF;
    color: #007AFF;
}

#prevBtn:active {
    background: #f0f8ff;
}

#nextBtn,
#submitBtn {
    background: #007AFF;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

#nextBtn:active,
#submitBtn:active {
    background: #0056b3;
}

/* Hide buttons when needed */
.nav-btn[style*="display: none"] {
    display: none !important;
}

/* ===== SUMMARY SCREEN ===== */

.summary-screen {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.summary-screen[data-visible="true"] {
    display: block;
}

.summary-title {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    text-align: center;
    margin-bottom: 24px;
}

/* Total score card */
.total-score-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 32px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.score-display {
    font-size: 56px;
    font-weight: bold;
    margin-bottom: 8px;
    line-height: 1;
}

.score-number {
    color: #fff;
}

.score-separator {
    margin: 0 8px;
    opacity: 0.7;
}

.score-max {
    opacity: 0.9;
}

.percentage {
    font-size: 36px;
    font-weight: 600;
    margin-bottom: 8px;
}

.grade-estimate {
    font-size: 20px;
    opacity: 0.95;
    font-weight: 500;
}

/* Question grid */
.question-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.question-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 3px solid transparent;
    transition: transform 0.2s ease;
}

/* Status-based styling */
.question-card[data-status="good"] {
    border-color: #34C759;
    background: linear-gradient(to bottom, white, #f0fdf4);
}

.question-card[data-status="medium"] {
    border-color: #FF9500;
    background: linear-gradient(to bottom, white, #fffbeb);
}

.question-card[data-status="weak"] {
    border-color: #FF3B30;
    background: linear-gradient(to bottom, white, #fef2f2);
}

.card-header {
    font-size: 20px;
    font-weight: bold;
    color: #666;
    margin-bottom: 4px;
}

.card-topic {
    font-size: 14px;
    color: #999;
    margin-bottom: 12px;
}

.card-score {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.card-icon {
    font-size: 32px;
    line-height: 1;
}

.question-card[data-status="good"] .card-icon {
    color: #34C759;
}

.question-card[data-status="medium"] .card-icon {
    color: #FF9500;
}

.question-card[data-status="weak"] .card-icon {
    color: #FF3B30;
}

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

/* Portrait iPad (768px) */
@media (max-width: 768px) {
    .exam-container {
        padding: 16px;
    }

    .score-btn {
        min-width: 48px;
        min-height: 48px;
        font-size: 18px;
    }

    .question-grid {
        gap: 12px;
    }
}

/* Landscape iPad (1024px) */
@media (min-width: 769px) and (orientation: landscape) {
    .question-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Small screens (iPhone size) */
@media (max-width: 480px) {
    .main-question-title {
        font-size: 20px;
    }

    .sub-question {
        padding: 16px;
    }

    .score-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 16px;
    }

    .total-score-card {
        padding: 24px;
    }

    .score-display {
        font-size: 42px;
    }

    .percentage {
        font-size: 28px;
    }
}

/* ===== UTILITY CLASSES ===== */

.hidden {
    display: none !important;
}

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

/* Prevent zoom on focus (iOS) while maintaining accessibility */
@media screen and (max-width: 768px) {
    select,
    textarea,
    input[type="text"],
    input[type="number"] {
        font-size: 16px !important;
    }
}
