/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--gray-900); background: var(--gray-50); line-height: 1.6; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* Navbar */
.navbar { background: var(--primary); color: white; padding: 12px 0; box-shadow: var(--shadow-md); position: sticky; top: 0; z-index: 100; }
.nav-container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.nav-brand { color: white; text-decoration: none; font-size: 1.25rem; font-weight: 700; }
.nav-links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-links a { color: rgba(255,255,255,.9); text-decoration: none; font-size: .9rem; transition: color .2s; }
.nav-links a:hover { color: white; }
.nav-user { color: rgba(255,255,255,.8); font-size: .85rem; }

/* Main */
main.container { padding-top: 30px; padding-bottom: 50px; min-height: calc(100vh - 140px); }

/* Footer */
.footer { background: var(--gray-900); color: var(--gray-300); text-align: center; padding: 20px; margin-top: 40px; }

/* Typography */
h1 { font-size: 1.75rem; margin-bottom: 20px; color: var(--gray-900); }
h2 { font-size: 1.4rem; margin-bottom: 16px; color: var(--gray-700); }
h3 { font-size: 1.15rem; margin-bottom: 12px; }

/* Cards */
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-200); }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; text-align: center; }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }

/* Buttons */
.btn { display: inline-block; padding: 10px 20px; border-radius: var(--radius); border: none; cursor: pointer; font-size: .9rem; font-weight: 500; text-decoration: none; text-align: center; transition: all .2s; line-height: 1.4; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; border: 1px solid white; color: white; padding: 6px 14px; }
.btn-outline:hover { background: rgba(255,255,255,.15); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--gray-700); font-size: .9rem; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .95rem; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
select.form-control { appearance: auto; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-inline { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* Tables */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); white-space: nowrap; }
tr:hover { background: var(--gray-50); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Login Page */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.login-box { background: white; border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 40px; width: 100%; max-width: 420px; }
.login-box h2 { text-align: center; margin-bottom: 24px; }

/* Exam */
.question-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; border-left: 4px solid var(--primary); }
.question-card.answered { border-left-color: var(--success); }
.question-number { font-weight: 600; color: var(--primary); margin-bottom: 8px; font-size: .85rem; }
.question-text { font-size: 1.05rem; margin-bottom: 16px; line-height: 1.7; }
.question-meta { display: flex; gap: 10px; margin-bottom: 12px; }
.options-list { list-style: none; }
.options-list li { margin-bottom: 8px; }
.option-label { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 2px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; transition: all .2s; }
.option-label:hover { border-color: var(--primary); background: #eff6ff; }
.option-label input { margin-top: 3px; }
.option-label.selected { border-color: var(--primary); background: #eff6ff; }
.option-label.correct { border-color: var(--success); background: #dcfce7; }
.option-label.incorrect { border-color: var(--danger); background: #fee2e2; }

/* Result */
.result-summary { text-align: center; padding: 40px; }
.result-score { font-size: 3rem; font-weight: 700; }
.result-score.passed { color: var(--success); }
.result-score.failed { color: var(--danger); }

/* Competency Grid */
.competency-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.competency-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; transition: transform .2s, box-shadow .2s; cursor: pointer; text-decoration: none; color: inherit; }
.competency-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.competency-card h3 { color: var(--primary); margin-bottom: 8px; }
.competency-card p { color: var(--gray-500); font-size: .85rem; }

/* Level selector */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.level-btn { display: block; padding: 16px; text-align: center; border: 2px solid var(--gray-200); border-radius: var(--radius); text-decoration: none; color: var(--gray-700); font-weight: 600; transition: all .2s; }
.level-btn:hover, .level-btn.active { border-color: var(--primary); background: #eff6ff; color: var(--primary); }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span { padding: 8px 14px; border: 1px solid var(--gray-200); border-radius: var(--radius); text-decoration: none; color: var(--gray-700); font-size: .85rem; }
.pagination a:hover { background: var(--gray-100); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* Exam progress bar */
.progress-bar { background: var(--gray-200); border-radius: 20px; height: 8px; margin-bottom: 20px; overflow: hidden; }
.progress-bar .fill { background: var(--primary); height: 100%; border-radius: 20px; transition: width .3s; }

/* Timer */
.exam-timer { position: fixed; top: 70px; right: 20px; background: white; padding: 12px 20px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-weight: 600; z-index: 50; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); z-index: 200; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 30px; width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Explanation box */
.explanation { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius); padding: 12px 16px; margin-top: 12px; font-size: .9rem; }

/* Title selection */
.title-group .title-list { padding-top: 4px; }
details summary { cursor: pointer; color: var(--gray-500); font-size: .9rem; margin-top: 12px; }
details[open] summary { color: var(--primary); }

/* Tabs (title_profile) */
.tab-btn { padding: 10px 20px; border: none; background: none; cursor: pointer; font-size: .95rem; color: var(--gray-500); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .nav-container { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .exam-timer { position: sticky; top: 60px; right: 0; margin-bottom: 16px; text-align: center; }
}
