/* --- GLOBAL VARIABLES & RESET --- */
:root {
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --border: #2a2a2a;
    --accent: #20C997;
    --accent-glow: rgba(32, 201, 151, 0.2);
    --blue: #19A4FF;
    --text-main: #eeeeee;
    --text-muted: #888888;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    margin: 0;
}

/* --- MAIN LAYOUT --- */
.trainer-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
}

@media (max-width: 900px) {
    .trainer-wrapper { grid-template-columns: 1fr; }
}

/* --- SIDEBAR --- */
.filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 16px;
    position: sticky;
    top: 40px;
}

.filter-header {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 24px;
    font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 700;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }

.filter-tag {
    background: #1f1f1f;
    border: 1px solid var(--border);
    color: #ccc;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}

.filter-tag:hover, .filter-tag.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

select {
    width: 100%;
    background: #1f1f1f;
    color: white;
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 6px;
    outline: none;
}

/* --- PROBLEM FEED --- */
/* --- PROBLEM LIST VIEW (USACO Guide Style) --- */

/* The container for the list */
.problem-list-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: #1e1e1e; /* Dark background */
    border-radius: 8px;
    border: 1px solid #333;
    overflow: hidden;
}

/* Common Grid Layout for Header and Rows */
.list-header, .problem-row {
    display: grid;
    /* Columns: Status | Source | Title (Flexible) | Difficulty */
    grid-template-columns: 60px 160px 1fr 120px; 
    align-items: center;
    padding: 12px 16px;
    gap: 15px;
}

/* --- HEADER ROW --- */
.list-header {
    background-color: #252526;
    border-bottom: 1px solid #333;
    font-size: 0.75rem;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- PROBLEM ROW ITEMS --- */
.problem-row {
    background-color: #1e1e1e; /* Transparent/Dark */
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
    transition: background-color 0.1s ease;
    text-decoration: none;
    color: inherit;
}

.problem-row:hover {
    background-color: #2d2d2d; /* Slight highlight on hover */
}

.problem-row:last-child {
    border-bottom: none;
}

/* --- COLUMN STYLES --- */

/* 1. Status Column (Circle) */
.col-status {
    display: flex;
    justify-content: center;
}
.status-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #3f3f46; /* Default gray (unsolved) */
}
.status-circle.solved {
    background-color: #20C997; /* Green if solved */
}

/* 2. Source Column (e.g. AMC 10A) */
.col-source {
    font-size: 0.9rem;
    color: #a1a1aa; /* Light gray */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3. Title Column (The main link) */
.col-title {
    font-size: 1rem;
    font-weight: 600;
    color: #60a5fa; /* Blue link color similar to reference */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 4. Difficulty Column (The Badge) */
.col-difficulty {
    display: flex;
    justify-content: flex-end; /* Align to right */
}

.difficulty-badge {
    padding: 4px 12px;
    border-radius: 12px; /* Pill shape */
    font-size: 0.8rem;
    font-weight: 700;
    color: #121212; /* Dark text for contrast against bright difficulty colors */
    text-align: center;
    min-width: 60px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .list-header, .problem-row {
        /* Hide source on small screens */
        grid-template-columns: 40px 1fr 80px; 
    }
    .col-source {
        display: none;
    }
}
/* =========================================
   --- DETAIL OVERLAY (THE REDESIGN) ---
========================================= */
.detail-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
    z-index: 2000;
    overflow-y: auto; /* Scroll lives here */
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}
.detail-overlay.hidden { display: none; }

.detail-container {
    background: #0d0d0d;
    width: 100%;
    max-width: 1000px; /* Wider for better layout */
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 0 50px rgba(0,0,0,0.7);
    margin: auto 0; /* Vertical center if content is short */
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Contains children */
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn { from { transform: scale(0.98); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- HEADER SECTION --- */
.detail-header-section {
    padding: 30px 40px;
    background: linear-gradient(to bottom, #1a1a1a, #0d0d0d);
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: flex-start;
}
.detail-title h1 { margin: 0; font-size: 2rem; color: white; }
.detail-meta { color: var(--text-muted); margin-top: 8px; font-size: 0.9rem; display: flex; gap: 10px; }
.close-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-muted); padding: 8px 16px; border-radius: 8px;
    cursor: pointer; transition: 0.2s;
}
.close-btn:hover { border-color: white; color: white; }

/* --- SCROLLABLE CONTENT AREA --- */
.detail-body {
    padding: 40px;
}

/* Question Styling */
/* Update your .question-box */
.question-box {
    font-family: 'Balthazar', serif;
    font-size: 1.25rem; /* Reduced from 1.4rem to prevent visual crowding */
    line-height: 1.6;
    color: #fff;
    margin-bottom: 40px;
    max-width: 100%;
    /* Ensure container handles overflow gracefully */
    position: relative;
}

/* Update your MathJax overrides */
mjx-container { 
    font-size: 105% !important; /* Reduced from 115% */
    margin: 0 2px !important;
    outline: none;
}

/* Better Scrolling for Long Equations */
mjx-container[display="true"] {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding-bottom: 12px; /* Adds space so the scrollbar doesn't cover text */
    
    /* Custom Scrollbar Styling */
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

/* Webkit Scrollbar Styling (Chrome/Safari/Edge) */
mjx-container[display="true"]::-webkit-scrollbar {
    height: 6px; /* Slimmer scrollbar */
}
mjx-container[display="true"]::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.02);
    border-radius: 4px;
}
mjx-container[display="true"]::-webkit-scrollbar-thumb {
    background: #444; /* Dark grey thumb */
    border-radius: 4px;
    transition: background 0.2s;
}
mjx-container[display="true"]::-webkit-scrollbar-thumb:hover {
    background: #666; /* Lighter on hover */
}

/* Options Grid */
.options-grid {
    display: grid;
    /* This ensures they never get squished. Minimum 140px width per box. */
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 60px;
}

.opt-box {
    background: #141414;
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    cursor: pointer; transition: 0.2s; font-size: 1.1rem;
    min-height: 64px;
}
.opt-label { 
    color: var(--text-muted); font-size: 0.9rem; font-weight: 700; 
}
.opt-box:hover:not(.disabled) { border-color: var(--blue); background: #1a1a1a; }
.opt-box.correct { border-color: var(--accent); background: rgba(32, 201, 151, 0.1); color: var(--accent); }
.opt-box.incorrect { border-color: #ef4444; background: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* --- ANALYSIS DASHBOARD (The part that was squished) --- */
.analysis-dashboard {
    display: grid;
    /* Two equal columns by default */
    grid-template-columns: 1fr 1fr; 
    gap: 30px;
    border-top: 1px solid var(--border);
    padding-top: 40px;
}

/* Stack columns on small screens */
@media (max-width: 768px) {
    .analysis-dashboard { grid-template-columns: 1fr; }
}

.analysis-col { display: flex; flex-direction: column; gap: 24px; }

.info-card {
    background: #111;
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 12px;
}

.info-card h4 {
    margin: 0 0 16px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex; align-items: center; gap: 8px;
}

/* Time Bars */
.time-stat { margin-bottom: 12px; }
.time-stat-row { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 6px; }
.progress-track { background: #222; height: 6px; border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 10px; }

/* Text Content */
.concept-tag {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--blue);
    margin: 0 6px 6px 0;
}

.text-content { line-height: 1.6; color: #ccc; font-size: 0.95rem; }

/* Trap Card */
.trap-card { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.05); }
.trap-card h4 { color: #ef4444; }
.back-btn {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.05); /* Subtle dark background */
    border: 1px solid #333;
    color: #888;
    padding: 10px 20px;
    border-radius: 30px; /* Pill shape */
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px; /* Space between arrow and text */
    margin-bottom: 25px;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: fit-content; /* Stops it from stretching full width */
}

.back-btn:hover {
    background: #eeeeee;
    color: #111;
    border-color: #eeeeee;
    transform: translateX(4px); /* Slide right animation */
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

/* Optional: Add an SVG arrow via CSS if you don't have one in HTML */
.back-btn::before {
    content: "←";
    font-family: monospace;
    font-weight: bold;
}
/* --- Dual Slider Styling --- */
.range-wrapper {
    position: relative;
    width: 100%;
    height: 30px; /* ample height for thumbs */
    margin-top: 10px;
}

/* The background line */
.slider-track {
    width: 100%;
    height: 5px;
    background-color: #444; /* Dark track background */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 5px;
    z-index: 0;
}

/* The actual inputs */
.range-wrapper input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    pointer-events: none; /* Allows clicking through the track area */
    z-index: 1;
    margin: 0;
}

/* --- The Thumbs (Handles) --- */
/* Webkit (Chrome, Safari, Edge) */
.range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: #00BFFF; /* Match your "Light Blue" theme */
    cursor: pointer;
    pointer-events: auto; /* Re-enable clicking on the thumb itself */
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    margin-top: -7px; /* minor alignment fix */
    position: relative;
    z-index: 10;
}

/* Firefox */
.range-wrapper input[type="range"]::-moz-range-thumb {
    height: 18px;
    width: 18px;
    border: none;
    border-radius: 50%;
    background: #00BFFF;
    cursor: pointer;
    pointer-events: auto;
    z-index: 10;
}
.status-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #444; /* Default Unsolved */
    transition: all 0.3s ease;
}

.status-circle.solved {
    background-color: #20C997; /* Green for solved */
    box-shadow: 0 0 5px #20C997;
}
.difficulty-label {
    display: inline-flex;
    align-items: center;
    background: #1a1f2e;
    padding: 6px 14px;
    border-radius: 14px;
    font-weight: 600;
    gap: 8px;
    border: 1px solid #2b3245;
}

.diff-text {
    color: #9aa4c1;
    letter-spacing: 1px;
    font-size: 0.75rem;
}

.diff-value {
    background: #2663ff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: white;
    font-weight: 700;
}
