/* ECSE Simulator Elite - Modern UI Styles */
:root {
    --ecse-primary: #0073aa;
    --ecse-primary-hover: #005177;
    --ecse-secondary: #646970;
    --ecse-danger: #d63638;
    --ecse-success: #46b450;
    --ecse-bg-light: #f6f7f7;
    --ecse-border: #dcdcde;
    --ecse-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --ecse-radius: 8px;
}

.ecse-builder-container, 
.ecse-dashboard-container, 
.ecse-portal-container, 
.ecse-result-container {
    max-width: 1000px;
    margin: 30px auto;
    padding: 30px;
    background: #fff;
    border: 1px solid var(--ecse-border);
    border-radius: var(--ecse-radius);
    box-shadow: var(--ecse-shadow);
    color: #3c434a;
    line-height: 1.5;
}

/* Typography */
.ecse-builder-container h2, 
.ecse-dashboard-container h2, 
.ecse-portal-container h2 {
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--ecse-bg-light);
    color: #1d2327;
}

.ecse-step {
    margin-bottom: 40px;
    padding: 20px;
    background: var(--ecse-bg-light);
    border-radius: var(--ecse-radius);
}

.ecse-step h3 {
    margin-top: 0;
    font-size: 1.2em;
    color: var(--ecse-primary);
    border-left: 4px solid var(--ecse-primary);
    padding-left: 10px;
    margin-bottom: 20px;
}

/* Fields */
.ecse-field { margin-bottom: 20px; }
.ecse-field label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 600; 
    font-size: 0.95em;
}

.ecse-field input[type="text"], 
.ecse-field input[type="number"], 
.ecse-field textarea, 
.ecse-field select {
    width: 100%; 
    padding: 14px 16px; 
    border: 1px solid var(--ecse-border); 
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
    transition: border-color 0.2s;
    min-height: 48px;
    font-size: 1em;
    line-height: 1.4;
}

.ecse-field input:focus {
    border-color: var(--ecse-primary);
    outline: none;
    box-shadow: 0 0 0 1px var(--ecse-primary);
}

.ecse-field small {
    display: block;
    color: #646970;
    margin-top: 5px;
}

/* Buttons */
.ecse-btn-primary { 
    background: var(--ecse-primary); 
    color: #fff !important; 
    border: none; 
    padding: 12px 24px; 
    border-radius: 4px; 
    cursor: pointer; 
    text-decoration: none; 
    display: inline-block; 
    font-weight: 600;
    transition: background 0.2s;
}
.ecse-btn-primary:hover { background: var(--ecse-primary-hover); }

.ecse-btn-secondary { 
    background: var(--ecse-secondary); 
    color: #fff !important; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 4px; 
    cursor: pointer;
    font-weight: 600;
}

.ecse-btn-danger { 
    background: var(--ecse-danger); 
    color: #fff !important; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 4px; 
    cursor: pointer;
    font-weight: 600;
}

/* Tabs in Builder */
.ecse-tabs { 
    display: flex; 
    margin-bottom: 0; 
    background: #e0e0e0;
    border-radius: 4px 4px 0 0;
}
.ecse-tab-btn { 
    background: none; 
    border: none; 
    padding: 12px 25px; 
    cursor: pointer; 
    font-weight: 600;
    color: #50575e;
    border-radius: 4px 4px 0 0;
}
.ecse-tab-btn.active { 
    background: #fff; 
    color: var(--ecse-primary);
}

.ecse-tab-content { 
    display: none; 
    padding: 20px; 
    background: #fff; 
    border: 1px solid var(--ecse-border);
    border-top: none;
    border-radius: 0 0 4px 4px;
}
.ecse-tab-content.active { display: block; }

/* Grid for Settings */
.ecse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.ecse-checkboxes {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ecse-checkboxes label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.ecse-pricing-info {
    font-size: 0.8em;
    color: #646970;
    margin-top: 8px;
    padding: 8px;
    background: #fff;
    border-radius: 4px;
    border-left: 3px solid var(--ecse-primary);
}

/* Summary Box */
.ecse-summary {
    margin-top: 30px;
    padding: 25px;
    background: #f0f6fb;
    border: 1px solid #d8e3ed;
    border-radius: var(--ecse-radius);
    text-align: center;
}

.ecse-cost-display {
    font-size: 1.4em;
    font-weight: bold;
    color: #1d2327;
    margin-bottom: 10px;
}

#ecse-estimated-cost { color: var(--ecse-primary); }

#ecse-balance-info {
    color: #646970;
    margin-bottom: 20px;
}

/* Dashboard */
.ecse-dashboard-actions {
    margin-bottom: 30px;
}

.ecse-sim-card { 
    border: 1px solid var(--ecse-border); 
    border-radius: var(--ecse-radius); 
    margin-bottom: 30px; 
    padding: 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ecse-sim-header { 
    background: var(--ecse-bg-light);
    padding: 15px 20px;
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--ecse-border);
}

.ecse-sim-header h3 { margin: 0; font-size: 1.2em; }

.ecse-badge { 
    padding: 5px 12px; 
    border-radius: 20px; 
    font-size: 0.85em; 
    font-weight: 600;
}
.ecse-badge.available { background: #dcfce7; color: #166534; }
.ecse-badge.full { background: #fee2e2; color: #991b1b; }

.ecse-sim-body { padding: 20px; }

.ecse-info-row { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 15px; 
    color: #646970;
    font-size: 0.9em;
}

.ecse-link-box { 
    display: flex; 
    gap: 10px; 
    background: #f0f0f1;
    padding: 10px;
    border-radius: 4px;
}
.ecse-link-box input { 
    flex: 1; 
    border: 1px solid #c3c4c7; 
    padding: 8px; 
    font-family: monospace;
    font-size: 0.85em;
}

.ecse-sim-reports { 
    padding: 20px; 
    background: #fff; 
    border-top: 1px solid var(--ecse-bg-light);
}

.ecse-report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.ecse-report-table th, .ecse-report-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--ecse-bg-light);
    font-size: 0.9em;
}

.ecse-report-table th { background: var(--ecse-bg-light); font-weight: 600; }

/* Portal & Exam */
.ecse-portal-view { display: none; }
.ecse-portal-view.active { display: block; }

.ecse-exam-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--ecse-bg-light);
}

.ecse-timer-box { 
    background: #1d2327; 
    color: #fff; 
    padding: 12px 20px; 
    border-radius: var(--ecse-radius); 
    font-family: 'Courier New', monospace; 
    font-size: 1.4em; 
    font-weight: bold;
}

.ecse-exam-layout { display: flex; gap: 30px; }
.ecse-exam-main { flex: 3; }
.ecse-exam-sidebar { 
    flex: 1; 
    background: var(--ecse-bg-light); 
    padding: 20px; 
    border-radius: var(--ecse-radius);
    border: 1px solid var(--ecse-border);
}

.ecse-q-text {
    font-size: 1.15em;
    font-weight: 500;
    margin-bottom: 25px;
    line-height: 1.6;
}

.ecse-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.ecse-options label {
    padding: 15px;
    border: 1px solid var(--ecse-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.ecse-options label:hover {
    background: #f0f6fb;
    border-color: var(--ecse-primary);
}

.ecse-options input[type="radio"] {
    width: 20px;
    height: 20px;
}

.ecse-exam-nav-btns {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--ecse-border);
}

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

.ecse-nav-grid button.ecse-nav-btn { 
    aspect-ratio: 1;
    border: 2px solid #1a1a1a !important; 
    background: #ffffff !important; 
    color: #000000 !important;
    cursor: pointer; 
    font-weight: 900 !important;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    font-size: 1.1em !important;
    opacity: 1 !important;
    width: 100%;
}

.ecse-nav-grid button.ecse-nav-btn:hover {
    border-color: var(--ecse-primary) !important;
    background: #f0f6fb !important;
    color: var(--ecse-primary) !important;
}

.ecse-nav-grid button.ecse-nav-btn.answered { 
    background: #e0f2fe !important; 
    border-color: #0369a1 !important; 
    color: #0369a1 !important; 
}

.ecse-nav-grid button.ecse-nav-btn.current { 
    background: var(--ecse-primary) !important; 
    color: #ffffff !important; 
    border-color: #003d5b !important; 
}

.ecse-nav-grid button.ecse-nav-btn.flagged { 
    border: 3px solid #f59e0b !important; 
    background: #fffbeb !important; 
    position: relative;
}

.ecse-nav-btn.flagged::after { 
    content: '🚩'; 
    position: absolute; 
    top: -10px; 
    right: -8px; 
    font-size: 12px; 
}

/* Review Later Section */
.ecse-flag-container {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.ecse-flag-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #d97706;
    cursor: pointer;
    background: #fffbeb;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #fef3c7;
}

.ecse-flag-label input { width: 18px; height: 18px; }

.ecse-review-grid-title {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--ecse-border);
    font-size: 0.9em;
    color: #d97706;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Results */
.ecse-result-header { 
    text-align: center; 
    padding: 40px; 
    border-radius: var(--ecse-radius); 
    margin-bottom: 40px; 
}
.ecse-result-header.passed { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.ecse-result-header.failed { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.ecse-score-circle { 
    margin: 20px auto;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 8px solid currentColor;
    display: flex; 
    flex-direction: column; 
    justify-content: center;
    align-items: center;
}
.ecse-score-circle .score-num { font-size: 2.5em; font-weight: 800; }

.ecse-tag-breakdown { margin-bottom: 40px; }
.ecse-tag-row { display: flex; align-items: center; gap: 15px; margin-bottom: 12px; }
.tag-name { width: 150px; font-weight: 600; font-size: 0.9em; }
.tag-progress-bg { flex: 1; height: 12px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.tag-progress-fill { height: 100%; background: var(--ecse-primary); }

.ecse-review-item {
    border: 1px solid var(--ecse-border);
    border-radius: var(--ecse-radius);
    padding: 20px;
    margin-bottom: 20px;
}
.ecse-review-item.correct { border-left: 5px solid var(--ecse-success); }
.ecse-review-item.incorrect { border-left: 5px solid var(--ecse-danger); }

.review-explanation {
    margin-top: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 4px;
    font-size: 0.95em;
    color: #475569;
}

.ecse-exam-title-results {
    text-align: center;
    color: var(--ecse-primary);
    margin-bottom: 10px;
    font-size: 2em;
    border-bottom: 2px solid var(--ecse-bg-light);
    padding-bottom: 15px;
}

.ecse-choice-result { 
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 700 !important;
    margin: 5px 0;
}
.ecse-choice-result.status-correct { 
    color: #064e3b !important; 
    background: #dcfce7 !important; 
    border: 1px solid #059669;
}
.ecse-choice-result.status-incorrect { 
    color: #7f1d1d !important; 
    background: #fee2e2 !important; 
    border: 1px solid #dc2626;
}

/* Success/Error Msgs */
#ecse-msg p, #ecse-verify-msg p {
    padding: 12px;
    border-radius: 4px;
    margin-top: 15px;
    font-weight: 500;
}
#ecse-msg p.success, #ecse-verify-msg p.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
#ecse-msg p.error, #ecse-verify-msg p.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
#ecse-msg p.info, #ecse-verify-msg p.info { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }

/* ==========================================================================
   MATCHING & ORDERING QUESTION TYPES (v18)
   ========================================================================== */

/* Matching Container */
.ecse-matching-container {
    display: flex;
    gap: 20px;
    margin-top: 15px;
}

.ecse-matching-left,
.ecse-matching-right {
    flex: 1;
}

.ecse-drop-zone {
    padding: 12px;
    margin-bottom: 8px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    min-height: 45px;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s, background-color 0.2s;
}

.ecse-drop-area {
    flex: 1;
    margin-left: 10px;
    padding: 8px;
    min-height: 30px;
    border: 1px dashed #999;
    border-radius: 4px;
    background: #fff;
    text-align: center;
    color: #666;
    transition: all 0.2s;
}

.ecse-drop-area.has-match {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #333;
    font-weight: bold;
}

.ecse-draggable {
    padding: 12px;
    margin-bottom: 8px;
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 6px;
    cursor: grab;
    text-align: center;
    transition: all 0.2s;
    user-select: none;
}

.ecse-draggable:hover {
    background: #bbdefb;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.ecse-draggable.used {
    background: #e0e0e0;
    border-color: #999;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Ordering Container */
.ecse-order-list {
    margin-top: 15px;
    border: 2px solid #009688;
    border-radius: 8px;
    padding: 10px;
    background: #e0f2f1;
}

.ecse-order-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #009688;
    border-radius: 6px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    user-select: none;
}

.ecse-order-item:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 150, 136, 0.3);
}

.ecse-order-item:last-child {
    margin-bottom: 0;
}

.ecse-order-num {
    background: #009688;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

/* Mobile responsiveness for Matching */
@media (max-width: 768px) {
    .ecse-matching-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .ecse-drop-zone {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .ecse-drop-area {
        margin-left: 0;
    }
}

/* ==========================================================================
   TIMER WARNINGS (v18.1)
   ========================================================================== */

#ecse-timer.timer-warning {
    background: #f59e0b !important;
    color: #fff !important;
    animation: timerPulse 1s ease-in-out infinite;
}

#ecse-timer.timer-danger {
    background: #dc2626 !important;
    color: #fff !important;
    animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ecse-time-warning-popup {
    animation: warningPopIn 0.3s ease-out;
}

@keyframes warningPopIn {
    0% { transform: translateX(-50%) scale(0.8); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ==========================================================================
   PROGRESS INDICATOR (v18.1)
   ========================================================================== */

.ecse-progress-container {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.ecse-progress-text {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95em;
    color: #475569;
}

.ecse-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.ecse-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0073aa, #00a0d2);
    border-radius: 4px;
    transition: width 0.3s ease;
}
