/* ==========================================================================
   1. VARIABLES & RESET (Modern Color Palette)
   ========================================================================== */
:root {
    /* Brand Colors */
    --primary: #2271b1;        /* WordPress Blue */
    --primary-dark: #135e96;
    --accent: #72aee6;
    
    /* Status Colors */
    --success: #00a32a;        /* Crisp Green */
    --success-bg: #edfaef;
    --danger: #d63638;         /* Alert Red */
    --danger-bg: #fbeaea;
    --warning: #f0b849;        /* Star Yellow */
    --warning-text: #996800;
    
    /* Grays & Layout */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #1d2327;
    --text-light: #646970;
    --border: #dcdcde;
    
    /* UI Properties */
    --radius: 12px;            /* Softer corners */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body, html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    font-size: 16px; /* Prevents zooming on iOS inputs */
}

/* ==========================================================================
   2. MAIN LAYOUT & CARDS
   ========================================================================== */
.quiz-dashboard, #csv-quiz-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
}

/* Admin/System Messages */
.admin-message {
    padding: 16px;
    margin: 0 0 20px 0;
    border-radius: 8px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}
.start-message { background: #f0f6fc; border-left: 4px solid var(--primary); color: var(--text-main); }
.end-message { background: var(--success-bg); border-left: 4px solid var(--success); color: #005c15; }

/* ==========================================================================
   3. FORMS & SELECTION (Mobile Optimized)
   ========================================================================== */
.user-form-card, .hierarchy-selection {
    padding: 30px 20px;
    text-align: center;
}

.user-form-card h2, .hierarchy-selection h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 700;
}

/* Logout Badge */
.logout-link {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 4px 10px;
    border-radius: 20px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
    transition: var(--transition);
}
.logout-link:hover { background: var(--danger); color: #fff; }

/* Dropdowns */
.selection-step {
    margin-bottom: 20px;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.selection-step label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.selection-dropdown {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: #fff;
    appearance: none; /* Removes default arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    transition: var(--transition);
}
.selection-dropdown:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.15);
    outline: none;
}

/* ==========================================================================
   4. BUTTONS (High Visibility & Touch Targets)
   ========================================================================== */
.button, button.button, a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%; /* Full width on mobile */
    min-height: 48px; /* Fat finger friendly */
    padding: 10px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    color: #fff !important; /* Force readable text */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.button:active { transform: translateY(0); }

/* Variants */
.button-primary { background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }

.quiz-start-btn, #btn-submit, #btn-next, .btn-new { background: var(--success); }
.quiz-start-btn:hover, #btn-submit:hover, #btn-next:hover, .btn-new:hover { background: #008a20; }

#btn-prev, .btn-review { background: var(--text-light); }
#btn-prev:hover, .btn-review:hover { background: var(--text-main); }

#btn-mark { background: var(--warning); color: var(--text-main) !important; }
#btn-mark:hover { background: #e0a800; }

.btn-dashboard { background: var(--primary); }
.btn-share { background: #00a0d2; } /* Cyan/Blue for share */

/* Desktop overrides for buttons */
@media (min-width: 768px) {
    .button, button.button, a.button { width: auto; margin: 0 5px; }
    .selection-actions, .result-actions, .dashboard-actions { display: flex; justify-content: center; flex-wrap: wrap; }
}

/* ==========================================================================
   5. QUIZ INTERFACE (The Core)
   ========================================================================== */
.quiz-layout {
    display: flex;
    flex-direction: column; /* Stack on mobile */
}

/* Main Area */
.quiz-main-area {
    padding: 20px;
    order: 1;
}

/* Header Bar */
#quiz-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border-left: 5px solid var(--primary);
}
#timer { font-weight: 700; font-size: 1.1rem; color: var(--primary); font-variant-numeric: tabular-nums; }
#progress { font-size: 0.9rem; color: var(--text-light); font-weight: 600; }

/* Question Card */
.question-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid #eee;
}
.question-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-light);
    margin: 0 0 10px 0;
    letter-spacing: 1px;
}
.question-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 25px;
}

/* Custom Radio Options (Beautiful Hover Effects) */
.question-options { display: flex; flex-direction: column; gap: 12px; }

.quiz-option {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.quiz-option:hover {
    border-color: var(--primary);
    background-color: #f8fbff;
}

/* Hide default radio, style the container */
.quiz-option input[type="radio"] {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--text-light);
    border-radius: 50%;
    margin-right: 15px;
    flex-shrink: 0;
    transition: all 0.2s;
    position: relative;
}

.quiz-option input[type="radio"]:checked {
    border-color: var(--primary);
    background-color: var(--primary);
    box-shadow: inset 0 0 0 4px #fff;
}

/* Active State for Option */
.quiz-option:has(input:checked) {
    border-color: var(--primary);
    background-color: #eef5fa;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.15);
    font-weight: 500;
}

/* Controls Bar */
#quiz-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid #eee;
}
#quiz-controls button {
    flex: 1; /* Equal width on mobile */
    min-width: 100px;
    margin-bottom: 0;
}

/* Sidebar / Palette (Collapsible on Mobile) */
.quiz-sidebar {
    background: #f8f9fa;
    border-top: 1px solid var(--border);
    padding: 20px;
    order: 2; /* Below questions on mobile */
}

@media (min-width: 900px) {
    .quiz-layout { flex-direction: row; }
    .quiz-sidebar {
        order: 2;
        width: 280px;
        border-top: none;
        border-left: 1px solid var(--border);
        position: sticky;
        top: 0;
    }
    .quiz-main-area { flex: 1; order: 1; }
}

.sidebar-header {
    font-weight: 700;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    color: var(--text-main);
}

#palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
}

.review-circle {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.review-circle:hover { transform: scale(1.15); z-index: 2; border-color: var(--primary); }
.review-circle.green { background: var(--success); color: #fff; border-color: var(--success); }
.review-circle.red { background: var(--danger); color: #fff; border-color: var(--danger); }
.review-circle.blue { background: #fff; color: var(--primary); border: 2px solid var(--primary); font-weight: 800; }

/* ==========================================================================
   6. DASHBOARD & RESULTS (Cards & Tables)
   ========================================================================== */
.dashboard, .result-screen { padding: 20px; }

/* Stat Cards */
.dashboard-stats, .result-summary {
    display: grid;
    grid-template-columns: 1fr; /* Stack on mobile */
    gap: 15px;
    margin: 20px 0;
}

.stat-box, .result-box {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #eee;
    box-shadow: var(--shadow-sm);
}

.stat-box h3, .result-box h3 {
    font-size: 2rem;
    margin: 0;
    color: var(--primary);
}
.stat-box p, .result-box p {
    margin: 5px 0 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 1px;
}

/* Leaderboard Table */
.dashboard-section { margin-top: 30px; }
.dashboard-section h3 {
    font-size: 1.2rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.leaderboard, .attempts-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 0.9rem;
}

.leaderboard thead, .attempts-table thead {
    background: #f0f0f1;
}

.leaderboard th, .attempts-table th {
    padding: 12px;
    text-align: left;
    font-weight: 700;
    color: var(--text-main);
}

.leaderboard td, .attempts-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.leaderboard tr:last-child td { border-bottom: none; }

/* Mobile Table Scroll */
@media (max-width: 600px) {
    .leaderboard, .attempts-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .dashboard-stats, .result-summary {
        grid-template-columns: 1fr 1fr; /* 2x2 on small screens */
    }
}

/* ==========================================================================
   7. REVIEW MODE (Analysis)
   ========================================================================== */
.review-mode { padding: 20px; }
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.review-question {
    background: #fff;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 5px solid #ccc;
}

.review-question.correct { border-left-color: var(--success); }
.review-question.incorrect { border-left-color: var(--danger); }

.review-question h3 { margin: 0 0 10px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }

.review-option {
    padding: 10px 15px;
    margin-bottom: 5px;
    background: #f9f9f9;
    border-radius: 6px;
    font-size: 0.95rem;
}

.review-option.correct-option {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: #005c15;
    font-weight: 600;
}

.review-option.wrong-option {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: #b30000;
    text-decoration: line-through;
}

.explanation {
    margin-top: 15px;
    background: #fff8e1;
    padding: 15px;
    border-left: 4px solid var(--warning);
    border-radius: 4px;
    font-size: 0.9rem;
    color: #5c4b1e;
}

/* ==========================================================================
   8. MODAL & OVERLAYS
   ========================================================================== */
#share-overlay {
    backdrop-filter: blur(2px);
    background: rgba(0,0,0,0.5);
}

#share-popup {
    text-align: center;
    animation: popupFade 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popupFade {
    from { opacity: 0; transform: translate(-50%, -45%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}
/* ============================================================
   MOBILE TABLE SCROLL FIX
   (Paste this at the very bottom of assets/style.css)
   ============================================================ */

@media screen and (max-width: 768px) {

    /* 1. Force the Container to Allow Scrolling */
    .table-responsive {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important; /* CRITICAL: Adds horizontal scrollbar */
        -webkit-overflow-scrolling: touch; /* Smooth scroll for iPhones */
        border: 1px solid #eee;
        margin-bottom: 20px;
    }

    /* 2. Force the Table to be Wide */
    /* This forces the table to be wider than the phone screen, 
       which triggers the scrollbar on the container above */
    .pretty-table {
        min-width: 700px !important; 
        width: 100% !important;
        border-collapse: collapse;
    }

    /* 3. Keep Text on One Line */
    .pretty-table th, 
    .pretty-table td {
        white-space: nowrap !important; /* Prevents text from wrapping */
        padding: 10px 15px !important;
        font-size: 13px !important;
    }

    /* 4. Fix Button Width */
    .action-btn {
        width: auto !important;
        padding: 5px 10px !important;
        white-space: nowrap !important;
    }
}