/* SPCS NSL Exercise Platform - shared stylesheet (ported from doc/demo_20260612) */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    display: flex;
    min-height: 100vh;
}

/* ============ LOGIN ============ */

body.login-page {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    align-items: center;
    justify-content: center;
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.main-logo { width: 100px; height: auto; margin: 0 auto 1rem; display: block; }
.platform-title { color: #555; font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }

.school-logo {
    width: 80px;
    height: 80px;
    background: #4a90e2;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: bold;
}

.login-container h1 { color: #333; margin-bottom: 2rem; font-size: 1.8rem; }
.login-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 1.2rem;
    font-size: 0.95rem;
    display: none;
}
.login-error.show { display: block; }

/* ============ LAYOUT / SIDEBAR ============ */

.sidebar {
    width: 260px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
    border-bottom: 1px solid #e1e5e9;
    text-align: center;
}

.sidebar-logo { width: 100px; height: auto; margin: 0 auto 1rem auto; display: block; }
.user-info { color: #333; font-weight: 600; }

.nav-menu { list-style: none; padding: 1rem 0; }
.nav-item { margin: 0.5rem 0; }

.nav-link {
    display: block;
    padding: 12px 1.5rem;
    color: #555;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.nav-link:hover { background: #4a90e2; color: white; }

.nav-link.active {
    background: #4a90e2;
    color: white;
    border-right: 4px solid #357abd;
}

.main-content {
    margin-left: 260px;
    padding: 2rem;
    width: calc(100% - 260px);
}

.content-header { margin-bottom: 2rem; }
.content-header h1 { color: #333; font-size: 2rem; margin-bottom: 0.5rem; }
.content-header p { color: #666; }

.content-section { display: none; }
.content-section.active { display: block; }

/* ============ DOMAIN GRID / CARDS ============ */

.domains-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.domain-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.domain-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.15);
    border-color: #4a90e2;
}

.domain-card .icon { font-size: 2.5rem; margin-bottom: 1rem; color: #4a90e2; }
.domain-card h3 { color: #333; font-size: 1.1rem; margin-bottom: 0.5rem; font-weight: 600; }
.domain-card p { color: #666; font-size: 0.9rem; line-height: 1.5; }
.domain-card .q-count { color: #4a90e2; font-size: 0.8rem; margin-top: 0.6rem; font-weight: 600; }

/* ============ EXERCISE ============ */

.exercise-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    overflow: hidden;
}

.exercise-header {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    padding: 2rem;
    text-align: center;
}

.exercise-header h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.exercise-header p { color: rgba(255,255,255,0.9); }

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e1e5e9;
    border-left: 4px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.question-container { padding: 2rem; }

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e1e5e9;
}

.question-number { font-size: 1.1rem; color: #4a90e2; font-weight: 600; }

.question-source-badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.source-ai { background: #e8f4fd; color: #0275d8; border: 1px solid #b8daff; }
.source-bank { background: #fdf4e8; color: #d97706; border: 1px solid #fde6d8; }
.source-user { background: #f3e8fd; color: #6b21a8; border: 1px solid #e9d5ff; }

.question-text { font-size: 1.2rem; color: #333; margin-bottom: 2rem; line-height: 1.6; }

.options-list { list-style: none; margin-bottom: 1.5rem; }
.option-item { margin-bottom: 1rem; }

.option-button {
    width: 100%;
    padding: 1rem;
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 1rem;
}

.option-button:hover { border-color: #4a90e2; background: #f0f7ff; }
.option-button.selected { background: #4a90e2; color: white; border-color: #357abd; }

/* Reference & video boxes - shown after answering */
.question-extra { margin-bottom: 2rem; }

.reference-box {
    background: #fff8e1;
    border-left: 4px solid #f0ad4e;
    padding: 1rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.reference-box strong { color: #d97706; display: block; margin-bottom: 0.4rem; }
.reference-box p { color: #555; white-space: pre-wrap; }
.reference-box a { color: #4a90e2; }

.video-box {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #000;
}

.video-box iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* ============ BUTTONS ============ */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-primary { background: #4a90e2; color: white; }
.btn-primary:hover { background: #357abd; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #545b62; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #218838; }
.btn-excel { background: #1d6f42; color: white; }
.btn-excel:hover { background: #155433; }
.btn-warning { background: #f0ad4e; color: white; }
.btn-warning:hover { background: #ec971f; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* ============ COMPLETION ============ */

.completion-container { text-align: center; padding: 3rem 2rem; }
.completion-icon { font-size: 4rem; color: #28a745; margin-bottom: 1rem; }
.completion-score { font-size: 3rem; font-weight: bold; color: #4a90e2; margin-bottom: 1rem; }
.completion-message { font-size: 1.2rem; color: #666; margin-bottom: 2rem; }

/* ============ HISTORY ============ */

.history-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    overflow: hidden;
}

.history-header {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 2rem;
    text-align: center;
    position: relative;
}

.history-header h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.history-header p { color: rgba(255,255,255,0.9); }
.history-controls { position: absolute; right: 2rem; top: 50%; transform: translateY(-50%); }

.history-table { padding: 2rem; }
.history-table table { width: 100%; border-collapse: collapse; }

.history-table th {
    background: #f8f9fa;
    color: #333;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e1e5e9;
}

.history-table td { padding: 1rem; border-bottom: 1px solid #e1e5e9; }
.history-table tr { cursor: pointer; transition: background 0.2s; }
.history-table tr:hover { background: #f0f7ff; }

.empty-history { text-align: center; padding: 3rem 1rem; color: #666; }
.empty-history-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-history h3 { margin-bottom: 0.5rem; color: #333; }

.score-badge, .status-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

.score-excellent { background: #28a745; color: white; }
.score-good { background: #ffc107; color: #333; }
.score-average { background: #17a2b8; color: white; }
.score-needs-improvement { background: #dc3545; color: white; }

.status-completed { background: #d4edda; color: #155724; }
.status-incomplete { background: #fff3cd; color: #856404; }
.answered-info { color: #999; font-size: 0.85rem; }

/* ============ FORMS ============ */

.form-group { margin-bottom: 1.5rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: #333; }

.form-control {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.form-control:focus { outline: none; border-color: #4a90e2; }

.option-input-group { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.option-input-group input[type="radio"] { width: 20px; height: 20px; cursor: pointer; flex-shrink: 0; }

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.create-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* ============ ALERTS ============ */

.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1rem; display: none; }
.alert.show { display: block; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #e8f4fd; color: #0275d8; border: 1px solid #b8daff; }

/* ============ QUESTION EDIT LIST ============ */

.edit-q-list-item {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.edit-q-list-item:hover { border-color: #4a90e2; box-shadow: 0 4px 12px rgba(74,144,226,0.1); }
.edit-q-list-item .q-content { flex: 1; min-width: 0; }
.edit-q-list-item .q-domain-tag { display: inline-flex; margin-bottom: 0.5rem; font-size: 0.75rem; }
.edit-q-list-item .q-text-preview { color: #333; line-height: 1.5; overflow-wrap: anywhere; }
.edit-q-list-item .q-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.edit-q-list-item .q-actions .btn { padding: 0.5rem 1rem; font-size: 0.9rem; }

.empty-edit-msg {
    text-align: center;
    color: #666;
    padding: 2.5rem 1rem;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px dashed #ccc;
}

.edit-divider { margin: 2rem 0; border: none; border-top: 2px dashed #e1e5e9; }

/* ============ MODALS ============ */

.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show { display: flex; }

.modal {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.modal-header, .modal-header-review {
    background: #4a90e2;
    color: white;
    padding: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body { padding: 2rem; }

/* Review question styles */
.review-q-item, .review-question-item { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid #eee; }
.review-q-text, .review-question-text { font-weight: 600; font-size: 1.1rem; margin-bottom: 1rem; color: #333; }

.review-options { list-style: none; display: grid; gap: 0.5rem; }

.review-opt, .review-option {
    padding: 0.8rem 1rem;
    margin: 0.25rem 0;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    position: relative;
}

.review-opt.correct-answer, .review-option.correct {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.review-opt.wrong-selection, .review-option.incorrect {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.review-opt.correct-answer::after, .review-option.correct::after {
    content: '✓ Correct Answer';
    position: absolute;
    right: 1rem;
    font-size: 0.8rem;
    font-weight: bold;
}

.review-opt.wrong-selection::after, .review-option.incorrect::after {
    content: '✕ Your Choice';
    position: absolute;
    right: 1rem;
    font-size: 0.8rem;
    font-weight: bold;
}

/* ============ IMPORT MODAL ============ */

.template-box {
    background: #2d2d2d;
    color: #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    overflow-x: auto;
    white-space: pre;
    margin: 1rem 0;
    line-height: 1.5;
}

textarea.import-area {
    width: 100%;
    min-height: 160px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: vertical;
}

.import-help {
    background: #e8f4fd;
    border: 1px solid #b8daff;
    border-radius: 8px;
    padding: 1rem;
    color: #0c5460;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* ============ REPORTS ============ */

.reports-grid, .classes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.report-card, .class-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.report-card::before, .class-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(45deg, #4a90e2, #357abd);
}

.report-card:hover, .class-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
    border-color: #4a90e2;
}

.report-card .icon, .class-card .icon { font-size: 3rem; margin-bottom: 1rem; color: #4a90e2; }
.class-card .icon { font-size: 2.5rem; }
.report-card h3, .class-card h3 { color: #333; font-size: 1.3rem; margin-bottom: 1rem; font-weight: 600; }
.report-card p, .class-card p { color: #666; font-size: 0.95rem; line-height: 1.6; }

.class-card .class-stats {
    margin-top: 1rem;
    display: flex;
    justify-content: space-around;
    padding-top: 1rem;
    border-top: 1px solid #e1e5e9;
}

.class-stat { text-align: center; }
.class-stat-value { font-size: 1.2rem; font-weight: bold; color: #4a90e2; }
.class-stat-label { font-size: 0.8rem; color: #666; }

.report-content {
    display: none;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    overflow: hidden;
}

.report-content.active { display: block; }

.report-header {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    padding: 2rem;
    text-align: center;
    position: relative;
}

.report-header h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.report-header p { color: rgba(255,255,255,0.9); }

.back-btn {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.back-btn:hover { background: rgba(255,255,255,0.3); }

.report-table { margin: 2rem; }
.report-table table { width: 100%; border-collapse: collapse; }

.report-table th {
    background: #f8f9fa;
    color: #333;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e1e5e9;
}

.report-table td { padding: 1rem; border-bottom: 1px solid #e1e5e9; }
.report-table tr:hover { background: #f8f9fa; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem;
}

.stat-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid #4a90e2;
}

.stat-value { font-size: 2rem; font-weight: bold; color: #4a90e2; margin-bottom: 0.5rem; }
.stat-label { color: #666; font-size: 0.9rem; }

.breadcrumb {
    background: #f8f9fa;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e1e5e9;
    font-size: 0.9rem;
    color: #666;
}

.breadcrumb a { color: #4a90e2; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ============ ACCOUNT / ADMIN PANELS ============ */

.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.account-panel {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    padding: 1.5rem;
}

.account-panel h3 { color: #4a90e2; margin-bottom: 1.2rem; }

.users-table { width: 100%; border-collapse: collapse; }

.users-table th {
    background: #f1f3f5;
    padding: 0.8rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e1e5e9;
    font-size: 0.9rem;
}

.users-table td { padding: 0.8rem; border-bottom: 1px solid #e1e5e9; font-size: 0.9rem; }
.users-table .btn { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .main-content { margin-left: 0; width: 100%; }
    .reports-grid, .classes-grid { grid-template-columns: 1fr; }
    .back-btn { position: static; transform: none; margin-bottom: 1rem; display: inline-block; }
    .class-stats { flex-direction: column; gap: 0.5rem; }
    .edit-q-list-item { flex-direction: column; align-items: stretch; }
    .edit-q-list-item .q-actions { justify-content: flex-end; }
    .create-actions { flex-direction: column; align-items: stretch; }
    .navigation-buttons { flex-direction: column; gap: 1rem; }
    .navigation-buttons .btn { width: 100%; }
    .account-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
}
