/* SoalKu — Main Stylesheet */
/* Design: Clean SaaS, Mobile-first */

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface-2: #f3f2ef;
  --border: #e8e5e0;
  --border-strong: #d0ccc5;
  --text: #1a1816;
  --text-muted: #8a847b;
  --text-light: #b5b0a8;
  --accent: #5046e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --error: #ef4444;
  --error-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.10);
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1, h2, h3, h4 { line-height: 1.3; font-weight: 600; letter-spacing: -.02em; }
.serif { font-family: var(--font-display); font-weight: 400; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(248,247,244,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}
.navbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  height: 60px;
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 1.5rem; color: var(--text);
  text-decoration: none; flex-shrink: 0;
}
.nav-logo span { color: var(--accent); }
.nav-spacer { flex: 1; }
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-link {
  padding: .45rem .8rem; border-radius: 8px;
  color: var(--text-muted); font-size: .875rem; font-weight: 500;
  text-decoration: none; transition: all .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-light); }
.btn-nav {
  padding: .45rem .9rem; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: .875rem; font-weight: 500;
  text-decoration: none; transition: opacity .15s;
}
.btn-nav:hover { opacity: .85; text-decoration: none; color: #fff; }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%;
  overflow: hidden; border: 2px solid var(--border);
  cursor: pointer; flex-shrink: 0;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 600;
  text-decoration: none;
}
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .5rem;
  min-width: 180px; box-shadow: var(--shadow-lg);
  display: none; z-index: 200;
}
.user-menu:hover .user-dropdown,
.user-dropdown.open { display: block; }
.dropdown-item {
  display: block; padding: .6rem .8rem; border-radius: 8px;
  color: var(--text); font-size: .875rem;
  text-decoration: none; transition: background .15s;
}
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-light); }
.dropdown-divider { height: 1px; background: var(--border); margin: .4rem 0; }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.page-padding { padding: 2rem 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.2rem; border-radius: 10px;
  font-size: .9rem; font-weight: 500; cursor: pointer;
  border: none; font-family: var(--font-body);
  transition: all .2s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: .45rem .85rem; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: .9rem 1.8rem; font-size: 1rem; border-radius: 14px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-sm { padding: 1rem; border-radius: var(--radius); }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

/* ── Search Bar ── */
.search-wrapper { position: relative; }
.search-input {
  width: 100%; padding: 1rem 1.25rem 1rem 3rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text);
  font-size: 1rem; font-family: var(--font-body);
  transition: border-color .2s; outline: none;
  box-shadow: var(--shadow);
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-light); }
.search-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-btn {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  padding: .5rem 1rem; background: var(--accent); color: #fff;
  border: none; border-radius: 10px; font-size: .875rem;
  font-weight: 500; cursor: pointer; font-family: var(--font-body);
  transition: opacity .2s;
}
.search-btn:hover { opacity: .85; }

/* ── Question Card ── */
.question-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1rem;
  transition: border-color .2s;
}
.question-card.answered { border-color: var(--accent-light); }
.question-number { font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.question-text { font-size: 1rem; font-weight: 500; margin-bottom: 1.2rem; line-height: 1.6; }
.options-grid { display: grid; gap: .5rem; }
.option-label {
  display: flex; align-items: flex-start; gap: .85rem;
  padding: .85rem 1rem; border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: all .15s;
  user-select: none;
}
.option-label:hover { border-color: var(--accent); background: var(--accent-light); }
.option-label input[type="radio"] { display: none; }
.option-label.selected { border-color: var(--accent); background: var(--accent-light); }
.option-label.correct { border-color: var(--success); background: var(--success-light); }
.option-label.wrong { border-color: var(--error); background: var(--error-light); }
.option-key {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  background: var(--surface-2); display: flex; align-items: center;
  justify-content: center; font-size: .8rem; font-weight: 700;
  color: var(--text-muted);
}
.option-label.selected .option-key { background: var(--accent); color: #fff; }
.option-label.correct .option-key { background: var(--success); color: #fff; }
.option-label.wrong .option-key { background: var(--error); color: #fff; }
.option-text { font-size: .9rem; line-height: 1.5; padding-top: 2px; }
.explanation-box {
  margin-top: 1rem; padding: .85rem 1rem;
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 10px; font-size: .85rem; color: #166534;
  display: none;
}
.explanation-box.show { display: block; }

/* ── Result ── */
.score-ring { position: relative; display: inline-block; }
.score-display {
  text-align: center; padding: 2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.score-number { font-size: 3.5rem; font-weight: 700; line-height: 1; }
.score-label { font-size: 1rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Category Pills ── */
.category-pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.category-pill {
  padding: .4rem 1rem; border-radius: 20px;
  background: var(--surface); border: 1.5px solid var(--border);
  font-size: .85rem; font-weight: 500; color: var(--text-muted);
  text-decoration: none; transition: all .15s; cursor: pointer;
}
.category-pill:hover, .category-pill.active {
  border-color: var(--accent); background: var(--accent-light);
  color: var(--accent); text-decoration: none;
}

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── Stats ── */
.stat-card { text-align: center; }
.stat-number { font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Loading ── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(248,247,244,.85);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
  display: none;
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: .95rem; color: var(--text-muted); }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--text); color: #fff; padding: .75rem 1.25rem;
  border-radius: 12px; font-size: .875rem; box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--text); margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* ── Progress Bar ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1rem; margin-top: 4rem;
  text-align: center; color: var(--text-muted);
  font-size: .875rem;
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .nav-links .nav-link { display: none; }
  .hide-mobile { display: none !important; }
}
@media (max-width: 480px) {
  .card { padding: 1.25rem; }
  .question-card { padding: 1.25rem; }
}

/* ── Animations ── */
.fade-in { animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── Misc ── */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-auto { margin-top: auto; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
