/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; line-height: 1.6; min-height: 100vh; }

/* ===== NAVBAR ===== */
.navbar { background: #1a1a2e; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; height: 56px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.nav-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-right a { color: #cbd5e1; text-decoration: none; font-size: .9rem; transition: color .2s; }
.nav-right a:hover { color: #fff; }
.nav-user { color: #94a3b8; font-size: .85rem; }

/* ===== LAYOUT ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.2rem; border: none; border-radius: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; text-decoration: none; transition: all .2s; line-height: 1.4; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline { background: transparent; border: 1.5px solid currentColor; }
.btn-outline:hover { opacity: .8; }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); padding: 1.5rem; margin-bottom: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem; }
.card-header h2, .card-header h3 { margin: 0; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; color: #475569; }
.form-control { width: 100%; padding: .55rem .8rem; border: 1.5px solid #d1d5db; border-radius: 8px; font-size: .9rem; font-family: inherit; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: auto; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: #2563eb; }

/* ===== FLASH MESSAGES ===== */
.flash-messages { margin-bottom: 1rem; }
.flash { padding: .75rem 1rem; border-radius: 8px; font-size: .9rem; margin-bottom: .5rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: .9rem; }
th { font-weight: 600; color: #475569; background: #f8fafc; }
tr:hover { background: #f8fafc; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-info { background: #eff6ff; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ===== LOGIN ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-card { background: #fff; padding: 2.5rem; border-radius: 16px; width: 100%; max-width: 400px; margin: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card h1 { text-align: center; margin-bottom: .3rem; color: #1a1a2e; }
.login-card .subtitle { text-align: center; color: #64748b; margin-bottom: 2rem; font-size: .9rem; }

/* ===== STUDENT DASHBOARD ===== */
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.case-card { background: #fff; border-radius: 12px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,.08); border-left: 4px solid #2563eb; transition: transform .2s, box-shadow .2s; }
.case-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.case-card h3 { margin-bottom: .5rem; color: #1a1a2e; }
.case-card .meta { color: #64748b; font-size: .85rem; margin-bottom: 1rem; }
.case-card .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ===== CASE PLAYER ===== */
.player-container { display: flex; flex-direction: column; height: calc(100vh - 56px); overflow: hidden; }
.player-header { background: #fff; padding: .8rem 1.5rem; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; flex-wrap: wrap; gap: .5rem; }
.player-header h2 { font-size: 1.1rem; margin: 0; }
.progress-bar { height: 4px; background: #e5e7eb; border-radius: 4px; flex: 1; max-width: 300px; margin: 0 1rem; }
.progress-fill { height: 100%; background: #2563eb; border-radius: 4px; transition: width .3s; }
.timer { font-family: 'Courier New', monospace; font-size: 1.1rem; color: #475569; font-weight: 600; }

.player-body { display: flex; flex: 1; overflow: hidden; }
.panel-left { flex: 1; overflow-y: auto; padding: 1.5rem; border-right: 1px solid #e5e7eb; background: #fafbfc; }
.panel-right { flex: 1; overflow-y: auto; padding: 1.5rem; background: #fff; display: flex; flex-direction: column; }

.step-title { font-size: 1.15rem; color: #1a1a2e; margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 2px solid #2563eb; }

.info-block { margin-bottom: 1.2rem; }
.info-block h4 { color: #475569; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; }
.info-block .content { background: #fff; padding: 1rem; border-radius: 8px; border: 1px solid #e5e7eb; white-space: pre-wrap; word-wrap: break-word; font-size: .9rem; line-height: 1.7; }
.info-block .content img { max-width: 100%; height: auto; border-radius: 4px; margin: .5rem 0; }

.question-block { margin-bottom: 1.5rem; }
.question-block h3 { font-size: 1rem; margin-bottom: 1rem; color: #1a1a2e; }
.option-btn { display: block; width: 100%; text-align: left; padding: .8rem 1rem; margin-bottom: .5rem; border: 2px solid #e5e7eb; border-radius: 10px; background: #fff; font-size: .9rem; cursor: pointer; transition: all .2s; line-height: 1.5; }
.option-btn:hover:not(:disabled) { border-color: #2563eb; background: #eff6ff; }
.option-btn.selected { border-color: #2563eb; background: #eff6ff; }
.option-btn.correct { border-color: #16a34a; background: #dcfce7; }
.option-btn.wrong { border-color: #dc2626; background: #fef2f2; }
.option-btn:disabled { cursor: default; opacity: .7; }

.explanation-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 1rem; margin-top: 1rem; font-size: .9rem; line-height: 1.6; }
.explanation-box h4 { color: #92400e; margin-bottom: .5rem; }

.step-nav { display: flex; justify-content: flex-end; gap: .5rem; margin-top: auto; padding-top: 1rem; }
.step-indicator { color: #64748b; font-size: .85rem; }

/* ===== RESULT PAGE ===== */
.result-header { text-align: center; padding: 2rem; }
.result-score { font-size: 3rem; font-weight: 700; color: #2563eb; }
.result-details { display: flex; gap: 2rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.result-stat { text-align: center; }
.result-stat .value { font-size: 1.5rem; font-weight: 700; }
.result-stat .label { color: #64748b; font-size: .85rem; }

.result-step { margin-bottom: .5rem; }
.result-step .step-name { font-weight: 600; margin-bottom: .3rem; }
.result-q { display: flex; justify-content: space-between; padding: .4rem .8rem; background: #f8fafc; border-radius: 6px; margin-bottom: .3rem; font-size: .9rem; }
.attempts-1 { color: #16a34a; font-weight: 600; }
.attempts-many { color: #f59e0b; font-weight: 600; }

/* ===== ADMIN: STEP EDITOR ===== */
.step-editor { border: 1px solid #e5e7eb; border-radius: 12px; margin-bottom: 1rem; overflow: hidden; }
.step-editor-header { background: #f8fafc; padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; border-bottom: 1px solid #e5e7eb; cursor: pointer; }
.step-editor-header:hover { background: #f1f5f9; }
.step-editor-header h3 { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.step-editor-body { padding: 1.2rem; display: none; }
.step-editor.open .step-editor-body { display: block; }
.step-editor-actions { display: flex; gap: .3rem; flex-wrap: wrap; }

.question-editor { background: #f8fafc; border-radius: 8px; padding: 1rem; margin-bottom: .8rem; border: 1px solid #e5e7eb; }
.option-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.option-row .form-control { flex: 1; }
.correct-mark { color: #16a34a; font-weight: 700; }

.image-thumb { width: 80px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid #e5e7eb; }

/* ===== ADMIN: TABS ===== */
.tabs { display: flex; border-bottom: 2px solid #e5e7eb; margin-bottom: 1.5rem; gap: 0; }
.tab { padding: .6rem 1.2rem; cursor: pointer; font-weight: 500; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; font-size: .9rem; }
.tab:hover { color: #1a1a2e; }
.tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== MODAL ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 2rem; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 1rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    html { font-size: 14px; }
    .navbar { padding: 0 1rem; }
    .nav-right { gap: .5rem; }
    .nav-user { display: none; }
    .container { padding: 1rem; }
    
    .player-body { flex-direction: column; }
    .panel-left { border-right: none; border-bottom: 1px solid #e5e7eb; max-height: 40vh; }
    .panel-right { flex: 1; }
    
    .player-header { padding: .6rem 1rem; }
    .progress-bar { display: none; }
    
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: auto; }
    
    .result-details { flex-direction: column; gap: 1rem; }
    .case-grid { grid-template-columns: 1fr; }
    
    .step-editor-actions { flex-direction: column; }
    .step-editor-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .login-card { padding: 1.5rem; margin: .5rem; }
    .card { padding: 1rem; }
}
