/* =========================================
   EXERCISE PAGE STYLES
   ========================================= */

:root {
    --ex-primary: #7B1FA2;       
    --ex-primary-light: #9C27B0; 
    --ex-primary-fade: #F3E5F5;  
    --ex-bg-gradient: linear-gradient(180deg, #FDFBFD 0%, #F3E5F5 100%);
    --ex-success: #2E7D32;       
    --ex-radius: 12px;
    --ex-shadow: 0 4px 20px rgba(123, 31, 162, 0.08);
    --ex-container-width: 1200px;
}

body {
    background: var(--ex-bg-gradient);
}

/* --- BREADCRUMB --- */
.breadcrumb { 
    max-width: var(--ex-container-width);
    width: 95%;
    margin: 1.5rem auto 0; 
    padding: 0 15px; 
    font-size: 0.9rem; 
    color: #666; 
}
.breadcrumb span { color: var(--ex-primary); font-weight: 600; }

/* --- PAGE HEADER --- */
.exercise-header { text-align: center; margin-bottom: 3rem; margin-top: 1rem; }
.exercise-header h1 { font-size: 2.2rem; margin-bottom: 0.5rem; color: var(--ex-primary); font-family: 'Poppins', sans-serif; }
.exercise-header p { font-size: 1.1rem; color: #666; }

/* --- MAIN CONTAINER --- */
main.exercise-main { 
    max-width: var(--ex-container-width); 
    width: 95%;
    margin: 1rem auto; 
    padding: 0 15px; 
    flex: 1; 
}

/* --- QUESTION CARDS --- */
.question-card {
    background: #ffffff;
    border-radius: var(--ex-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--ex-shadow);
    border: 1px solid rgba(123, 31, 162, 0.05);
    transition: transform 0.2s, border-color 0.3s;
    position: relative;
    scroll-margin-top: 100px;
}
.question-card.active-card {
    border: 2px solid var(--ex-primary);
    box-shadow: 0 8px 30px rgba(123, 31, 162, 0.15);
}

.q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 10px;
}

.q-badge { 
    background: var(--ex-primary-fade); 
    color: var(--ex-primary); 
    padding: 6px 12px; 
    border-radius: 20px; 
    font-size: 0.8rem; 
    font-weight: 700; 
}

.question-text { font-weight: 600; font-size: 1.1rem; margin-bottom: 1.5rem; color: #333; }

/* --- TIMER --- */
.timer-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f0f0;
    padding: 5px 12px;
    border-radius: 20px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
    transition: 0.3s;
}
.timer-box.running {
    background: #e8f5e9;
    color: var(--ex-success);
    border: 1px solid var(--ex-success);
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.timer-box.running i { animation: pulse 1s infinite; }

/* --- SOLUTION TOGGLE --- */
.solution-btn {
    background: transparent;
    border: 2px solid var(--ex-primary);
    color: var(--ex-primary);
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
}
.solution-btn:hover { background: var(--ex-primary); color: white; }
.solution-content {
    display: none;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #fafafa;
    border-radius: 12px;
    border-left: 4px solid var(--ex-success);
}

.step { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed #eee; }
.step:last-child { border-bottom: none; }
.final-ans { background: #e8f5e9; color: #1b5e20; padding: 1rem; border-radius: 8px; font-weight: 700; text-align: center; margin-top: 1rem; }

/* --- NAVIGATION BUTTONS --- */
.nav-buttons-container { display: flex; justify-content: space-between; gap: 20px; margin: 4rem 0 2rem; padding-top: 2rem; border-top: 1px solid #eee; flex-wrap: wrap; }
.nav-btn { display: flex; align-items: center; gap: 10px; padding: 15px 30px; border-radius: 12px; font-weight: 700; transition: all 0.3s; flex: 1; justify-content: center; text-align: center; min-width: 200px; }
.btn-prev { background: #f5f5f5; color: #555; border: 1px solid #ddd; }
.btn-prev:hover { background: #eee; transform: translateX(-5px); }
.btn-next { background: var(--ex-primary); color: white; box-shadow: 0 5px 15px rgba(123, 31, 162, 0.3); }
.btn-next:hover { background: var(--ex-primary-light); transform: translateX(5px); }

/* --- IMPORTANT MARKING --- */
.mark-important-btn { background: none; border: none; color: #ccc; font-size: 1.2rem; cursor: pointer; transition: color 0.3s, transform 0.2s; padding: 5px; }
.mark-important-btn:hover { transform: scale(1.1); }
.mark-important-btn.active { color: #ffc107; }
.question-card.important { border: 2px solid #ffc107; box-shadow: 0 8px 30px rgba(255, 193, 7, 0.15); }

@media (max-width: 768px) {
    .nav-buttons-container { flex-direction: column; align-items: center; }
    .nav-btn { width: 100%; max-width: 100%; }
    .q-header { align-items: flex-start; }
    .timer-box { font-size: 0.8rem; padding: 4px 8px; }
}

/* --- FOCUS MODE --- */
body.focus-mode::before {
    content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.92); z-index: 999; pointer-events: none; transition: opacity 0.3s ease;
}
body.focus-mode .question-card { opacity: 0.15; transition: opacity 0.3s, transform 0.3s, filter 0.3s; filter: blur(3px); }
body.focus-mode .question-card.active-card { opacity: 1; z-index: 1000; transform: scale(1.02); filter: none; box-shadow: 0 0 50px rgba(0, 0, 0, 0.8); border-color: var(--ex-primary); }
body.focus-mode header, body.focus-mode footer, body.focus-mode .breadcrumb, body.focus-mode .exercise-header, body.focus-mode .nav-buttons-container { opacity: 0.05; filter: blur(5px); pointer-events: none; }

.focus-mode-btn {
    position: fixed; bottom: 30px; left: 30px; background: #ffffff; color: #333;
    border: 1px solid rgba(0,0,0,0.1); padding: 12px 24px; border-radius: 50px;
    font-weight: 600; cursor: pointer; z-index: 1001; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 10px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Poppins', sans-serif;
}
.focus-mode-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.2); color: var(--ex-primary); }
.focus-mode-btn.active { background: var(--ex-primary); color: white; border-color: var(--ex-primary); box-shadow: 0 0 20px rgba(123, 31, 162, 0.4); }

/* --- MATHJAX DARK MODE OVERRIDES --- */
body.dark-mode mjx-container { color: #e0e0e0 !important; font-size: 110%; }
body.dark-mode mjx-container path, body.dark-mode mjx-container rect { fill: currentColor; stroke: currentColor; }
body.dark-mode .focus-mode-btn { background: #2d2d2d; color: #e0e0e0; border-color: #444; }
body.dark-mode .focus-mode-btn.active { background: var(--ex-primary); color: white; }

/* --- FORMULA SHEET MODAL --- */
.formula-btn {
    position: fixed; bottom: 90px; left: 30px; background: #ffffff; color: #333;
    border: 1px solid rgba(0,0,0,0.1); padding: 12px 24px; border-radius: 50px;
    font-weight: 600; cursor: pointer; z-index: 1001; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 10px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Poppins', sans-serif;
}
.formula-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.2); color: var(--ex-primary); }

.formula-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 2000;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(5px); opacity: 0; transition: opacity 0.3s ease;
}
.formula-modal-overlay.active { display: flex; opacity: 1; }

.formula-modal {
    background: #fff; width: 90%; max-width: 800px; max-height: 85vh;
    border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; overflow: hidden;
    transform: translateY(20px); transition: transform 0.3s ease;
}
.formula-modal-overlay.active .formula-modal { transform: translateY(0); }

.fm-header { padding: 1.5rem; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; }
.fm-header h2 { font-size: 1.5rem; margin: 0; color: var(--ex-primary); }
.fm-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; transition: 0.2s; }
.fm-close:hover { color: #d32f2f; transform: rotate(90deg); }

.fm-body { padding: 2rem; overflow-y: auto; }
.fm-section { margin-bottom: 2rem; }
.fm-section h3 { font-size: 1.1rem; margin-bottom: 1rem; color: #333; border-left: 4px solid var(--ex-primary); padding-left: 10px; }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.5rem; }
.formula-item { background: #f8f9fa; padding: 1rem; border-radius: 8px; border: 1px solid #eee; }

@media (max-width: 768px) {
    .formula-btn { bottom: 80px; left: 20px; padding: 10px 16px; font-size: 0.9rem; }
    .formula-btn span { display: none; }
}

/* Dark Mode for Modal */
body.dark-mode .formula-btn { background: #2d2d2d; color: #e0e0e0; border-color: #444; }
body.dark-mode .formula-modal { background: #1e1e1e; color: #e0e0e0; }
body.dark-mode .fm-header { background: #252525; border-color: #333; }
body.dark-mode .formula-item { background: #2d2d2d; border-color: #444; }
body.dark-mode .fm-section h3 { color: #e0e0e0; }