/* styles.css - Indian Contract Act Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    /* Legal Theme Colors */
    --primary: #2c3e50;       /* Midnight Blue - Authority */
    --secondary: #d35400;     /* Burnt Orange - Emphasis */
    --accent: #f39c12;        /* Gold - Justice/Value */
    --teal: #16a085;          /* Teal - Success */
    
    --dark: #1e293b;          
    --light: #f8fafc;         
    --success: #27ae60;       
    --danger: #c0392b;        
    
    /* Glassmorphism Variables */
    --glass: rgba(255, 255, 255, 0.92);
    --glass-border: rgba(44, 62, 80, 0.2);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    
    /* Sophisticated Legal Gradient */
    background: linear-gradient(135deg, #2c3e50, #34495e, #2980b9);
    background-size: 300% 300%;
    background-attachment: fixed;
    animation: gradientBG 20s ease infinite;
    
    color: var(--dark);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    width: 100%;
    max-width: 850px;
    margin: 2rem 1rem;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- Header --- */
header {
    text-align: center;
    padding: 2.5rem 2rem;
    background: linear-gradient(to bottom, rgba(44, 62, 80, 0.05), transparent);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

h1 { 
    font-weight: 800; 
    color: var(--primary); 
    font-size: 2.4rem; 
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

h2 { color: var(--dark); margin-bottom: 1rem; }
p { color: #555; line-height: 1.6; }

/* --- Inputs & Buttons --- */
.control-panel {
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.hero-icon {
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.number-selector {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: 16px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.03);
}

input[type="number"] {
    width: 90px;
    text-align: center;
    border: 2px solid transparent;
    background: white;
    border-radius: 12px;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

input[type="number"]:focus { 
    outline: none; 
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.2);
}

.circle-btn {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    border: none;
    background: white;
    color: var(--primary);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.circle-btn:hover { 
    background: var(--primary); 
    color: white; 
    transform: translateY(-2px);
}

.btn {
    padding: 1rem 2.5rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.3);
}

.btn-primary:hover { 
    background: #34495e; 
    transform: translateY(-2px); 
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4); 
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover { 
    background: rgba(44, 62, 80, 0.05); 
}

/* --- Quiz UI & New Header --- */
.quiz-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2rem;
    font-weight: 600;
    background: white;
    border-bottom: 1px solid #eee;
}

.header-home-btn {
    background: #f1f5f9;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.header-home-btn:hover {
    background: var(--primary);
    color: white;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-timer {
    color: var(--secondary);
    font-family: monospace;
    font-size: 1.1rem;
    min-width: 65px;
    text-align: right;
}

.progress-container {
    height: 6px;
    background: #e2e8f0;
    width: 100%;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-card {
    padding: 2.5rem;
    touch-action: pan-y;
}

.question-text {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    color: var(--dark);
    line-height: 1.5;
}

.options-grid {
    display: grid;
    gap: 1.2rem;
}

.option {
    padding: 1.2rem 1.5rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start; /* Better for long text */
    font-weight: 500;
    color: #475569;
}

.option:hover { 
    border-color: var(--primary); 
    background: #f8fafc; 
    transform: translateX(5px);
}

.option.selected {
    background: #f0f9ff;
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.option-badge {
    background: #e2e8f0;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin-right: 15px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-top: 2px; /* Align with text top */
}

.option.selected .option-badge {
    background: var(--primary);
    color: white;
}

/* --- Results Dashboard --- */
.results-dashboard {
    padding: 3rem 2rem;
    text-align: center;
}

.score-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(var(--teal) var(--percent, 0%), #e2e8f0 0);
    margin: 0 auto 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 155px;
    height: 155px;
    background: white;
    border-radius: 50%;
}

.score-text {
    position: relative;
    z-index: 1;
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    border: 1px solid #f1f5f9;
}

.stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-label { font-size: 0.85rem; color: #64748b; text-transform: uppercase; letter-spacing: 1px; margin-top: 5px; }
.text-success { color: var(--teal); }
.text-danger { color: var(--danger); }

/* --- Review Section --- */
.review-item {
    background: white;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.review-item.correct { border-left: 6px solid var(--teal); }
.review-item.incorrect { border-left: 6px solid var(--danger); }
.review-item.skipped { border-left: 6px solid var(--accent); }

.review-header {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary);
    border-bottom: 1px solid #eee;
}

.review-body { padding: 1.5rem; }

.ans-row {
    display: flex;
    justify-content: space-between;
    margin-top: 0.8rem;
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.ans-row.your-ans { background: #fff1f2; color: var(--danger); }
.ans-row.your-ans.correct { background: #f0fdf4; color: var(--teal); }
.ans-row.correct-ans { background: #f0fdf4; color: var(--teal); font-weight: 700; border: 1px solid #bbf7d0; }


.screen { display: none; animation: fadeIn 0.4s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------------- */
/* --- MOBILE IMMERSIVE LAYOUT FIX (QUIZ + RESULTS + REVIEW) --- */
/* ------------------------------------------------------------------- */
@media (max-width: 600px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    .container { 
        margin: 0; 
        border-radius: 0; 
        height: 100dvh; 
        border: none; 
        background: #fff; 
        display: flex;
        flex-direction: column;
    }

    .screen.active {
        display: flex !important;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    /* --- 1. QUIZ SCREEN --- */
    .quiz-header-info {
        flex: 0 0 auto; 
        padding: 0.8rem 1rem;
        background: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
    }

    .question-card {
        flex: 1 1 auto; 
        overflow-y: auto; 
        padding: 1rem 1.2rem;
        margin: 0;
    }
    
    .quiz-footer {
        flex: 0 0 auto; 
        padding: 0.8rem 1rem !important;
        background: white;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.03);
        z-index: 10;
        display: flex;
        gap: 0.8rem;
    }

    /* --- 2. RESULT SCREEN (FIXED) --- */
    #resultScreen header {
        flex: 0 0 auto;
        padding: 1rem;
        border-bottom: 1px solid #e2e8f0;
    }

    /* Compact Result Header */
    #resultScreen header .result-icon { font-size: 2rem !important; margin-bottom: 0.5rem; }
    #resultScreen header h1 { font-size: 1.6rem; margin-bottom: 0.2rem; }
    #resultScreen header p { font-size: 0.85rem; margin-bottom: 0; }
    
    .results-dashboard {
        flex: 1 1 auto;
        overflow-y: auto; /* Allow scrolling for buttons */
        padding: 1.5rem;
        padding-bottom: 3rem; /* Extra buffer for scrolling */
    }

    /* Smaller Score Circle */
    .score-circle {
        width: 140px;
        height: 140px;
        margin: 0 auto 1.5rem;
    }
    .score-circle::before {
        width: 120px;
        height: 120px;
    }
    .score-text { font-size: 2.5rem; }

    /* Compact Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
        margin-bottom: 2rem;
    }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.4rem; }
    .stat-label { font-size: 0.75rem; }

    /* --- 3. REVIEW SCREEN --- */
    #reviewScreen header {
        flex: 0 0 auto;
        padding: 1rem;
        border-bottom: 1px solid #e2e8f0;
    }

    #reviewContainer {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 1rem !important;
        max-height: none !important;
    }

    /* --- GENERAL MOBILE TYPOGRAPHY --- */
    .header-title { font-size: 1rem; }
    .header-timer { font-size: 1rem; }

    .question-text {
        font-size: 1.15rem;
        margin-bottom: 1.2rem;
        line-height: 1.4;
    }
    
    .question-card > div:first-child {
        margin-bottom: 0.8rem !important;
        font-size: 0.8rem;
    }

    .options-grid {
        gap: 0.6rem;
        padding-bottom: 1rem;
    }

    .option {
        padding: 0.8rem 1rem;
        min-height: auto;
    }

    .quiz-footer .btn {
        flex: 1;
        padding: 0.8rem;
        font-size: 0.95rem;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}
