/* ═══════════════════════════════════════════════════════════════════════════
   AmericasMMLU — Stylesheet
   Mobile-first, no external dependencies
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --color-primary:    #2D6A4F;
  --color-primary-d:  #1B4332;
  --color-primary-l:  #40916C;
  --color-accent:     #95D5B2;
  --color-warn:       #F4A261;
  --color-danger:     #E63946;
  --color-info:       #4895EF;
  --color-success:    #2D6A4F;

  --color-bg:         #F4F7F5;
  --color-surface:    #FFFFFF;
  --color-border:     #D1E0D8;
  --color-text:       #1A2E22;
  --color-muted:      #6B8C7A;

  --radius:           8px;
  --shadow:           0 2px 8px rgba(0,0,0,.10);
  --shadow-md:        0 4px 16px rgba(0,0,0,.14);

  --font-body:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:        'Courier New', Courier, monospace;

  --max-w:            1300px;
  --header-h:         60px;
}

/* ─── Reset / Base ─────────────────────────────────────────────────────────── */
*, *::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(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--color-primary-l); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { padding-left: 1.4rem; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 1rem; }
.site-main  { flex: 1; padding: 1.5rem 0 3rem; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-primary-d);
  color: #fff;
  height: var(--header-h);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-md);
}
.header-inner { display: flex; align-items: center; height: 100%; gap: 1rem; }
.site-logo { font-size: 1.1rem; font-weight: 700; color: #fff; white-space: nowrap; text-decoration: none; }
.site-nav { display: none; align-items: center; gap: 1rem; margin-left: auto; }
.site-nav.is-open { display: flex; }
.site-nav a { color: rgba(255,255,255,.85); font-size: .9rem; padding: .25rem .5rem; border-radius: 4px; transition: background .15s; text-decoration: none; }
.site-nav a:hover, .site-nav a.active { color: #fff; background: rgba(255,255,255,.15); }
.nav-user { color: rgba(255,255,255,.7); font-size: .85rem; }
.nav-user small { margin-left: .25rem; }
.lang-switch { display: flex; gap: 2px; border: 1px solid rgba(255,255,255,.3); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.lang-btn { padding: .2rem .55rem; font-size: .75rem; font-weight: 700; color: rgba(255,255,255,.7); text-decoration: none; transition: background .15s, color .15s; }
.lang-btn:hover { color: #fff; background: rgba(255,255,255,.15); text-decoration: none; }
.lang-btn--active { background: rgba(255,255,255,.25); color: #fff; }
.nav-toggle { margin-left: auto; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; padding: .25rem; }
@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .site-nav   { display: flex !important; }
}
@media (max-width: 767px) {
  .site-nav.is-open {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    background: var(--color-primary-d); flex-direction: column; align-items: flex-start;
    padding: 1rem; gap: .75rem; box-shadow: var(--shadow-md); z-index: 99;
  }
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.site-footer { background: var(--color-primary-d); color: rgba(255,255,255,.6); font-size: .8rem; padding: 1rem 0; text-align: center; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.2rem; border-radius: var(--radius); border: 2px solid transparent; font-size: .9rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; text-decoration: none; }
.btn--primary  { background: var(--color-primary); color: #fff; }
.btn--primary:hover  { background: var(--color-primary-d); color: #fff; text-decoration: none; }
.btn--outline  { background: transparent; border-color: var(--color-primary); color: var(--color-primary); }
.btn--outline:hover  { background: var(--color-primary); color: #fff; text-decoration: none; }
.btn--ghost    { background: transparent; color: var(--color-muted); }
.btn--ghost:hover    { background: var(--color-border); text-decoration: none; }
.btn--danger   { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn--danger:hover   { background: #c1121f; text-decoration: none; }
.btn--sm       { padding: .3rem .75rem; font-size: .8rem; }
.btn--full     { width: 100%; justify-content: center; }

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert--info    { background: #e0f0ff; color: #1a5276; border-left: 4px solid var(--color-info); }
.alert--success { background: #d4edda; color: #155724; border-left: 4px solid var(--color-success); }
.alert--warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--color-warn); }
.alert--danger  { background: #fce4e4; color: #7b1a1a; border-left: 4px solid var(--color-danger); }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.form-group label { font-weight: 600; font-size: .9rem; color: var(--color-text); }
.form-group label small { font-weight: 400; color: var(--color-muted); }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%; padding: .6rem .8rem; border: 1.5px solid var(--color-border);
  border-radius: var(--radius); font-size: .95rem; font-family: var(--font-body);
  background: var(--color-surface); color: var(--color-text); transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary-l);
  box-shadow: 0 0 0 3px rgba(64,145,108,.2);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.req { color: var(--color-danger); }
.select-sm { width: auto; padding: .3rem .6rem; font-size: .85rem; }
.form-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.form-row .form-group { flex: 1 1 180px; margin-bottom: 0; }
.form-row .form-group--action { flex: 0 0 auto; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.info-line { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: 1rem; font-size: .9rem; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding: .6rem 0; }
.checkbox-row label { display: flex; align-items: center; gap: .4rem; font-weight: 400; font-size: .9rem; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: auto; }

/* ─── Auth ────────────────────────────────────────────────────────────────────── */
body.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--color-primary-d) 0%, var(--color-primary) 100%); }
.auth-card { background: var(--color-surface); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 1.5rem; color: var(--color-primary); }
.auth-logo p  { color: var(--color-muted); font-size: .9rem; margin-top: .25rem; }
.auth-form .btn { margin-top: .5rem; }

/* ─── Page header ────────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.4rem; color: var(--color-primary-d); }
.page-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ─── Panel ──────────────────────────────────────────────────────────────────── */
.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel h3 { font-size: 1.05rem; margin-bottom: 1rem; color: var(--color-primary-d); }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.panel-header h3 { margin-bottom: 0; }

/* ─── Admin stats grid ───────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; }
.stat-card h3 { font-size: 1rem; color: var(--color-primary-d); margin-bottom: .75rem; }
.stat-card h3 small { color: var(--color-muted); font-weight: 400; }
.stat-numbers { display: flex; gap: 1.5rem; margin-bottom: .75rem; }
.stat-item { text-align: center; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: .75rem; color: var(--color-muted); }
.progress-bar-wrap { height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; margin-bottom: .25rem; }
.progress-bar { height: 100%; background: var(--color-primary-l); border-radius: 4px; transition: width .4s; }

/* ─── Annotator stats ────────────────────────────────────────────────────────── */
.annotator-stats { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.astat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: .75rem 1.25rem; text-align: center; min-width: 80px; }
.astat-value { display: block; font-size: 1.6rem; font-weight: 700; }
.astat-label { font-size: .75rem; color: var(--color-muted); }
.astat--done    .astat-value { color: var(--color-primary); }
.astat--draft   .astat-value { color: var(--color-warn); }
.astat--todo    .astat-value { color: var(--color-muted); }
.astat--total   .astat-value { color: var(--color-text); }
.astat--skipped .astat-value { color: #7c3aed; }

/* ─── Filter row ─────────────────────────────────────────────────────────────── */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: .5rem; }
.filter-tab { padding: .35rem .9rem; border-radius: 20px; border: 1.5px solid var(--color-border); font-size: .85rem; color: var(--color-muted); text-decoration: none; transition: all .15s; }
.filter-tab:hover, .filter-tab.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; text-decoration: none; }
.subject-filter-form { display: flex; align-items: center; gap: .5rem; }

/* ─── Section header ─────────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0 .75rem; flex-wrap: wrap; }
.section-header h3 { margin: 0; font-size: 1.05rem; color: var(--color-text); }

/* ─── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { text-align: left; padding: .6rem .75rem; background: var(--color-bg); color: var(--color-muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--color-border); white-space: nowrap; }
.data-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: #f9fbfa; }
.data-table tbody tr.active { background: #f0f9f4; }
.empty-cell { text-align: center; color: var(--color-muted); padding: 2rem; }
.caption-cell { max-width: 260px; font-size: .82rem; }

/* ─── Tab bar ─────────────────────────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 1.5rem; }
.tab { padding: .6rem 1.25rem; font-weight: 600; font-size: .9rem; color: var(--color-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; text-decoration: none; transition: all .15s; }
.tab:hover { color: var(--color-primary); text-decoration: none; }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 12px; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.badge--draft      { background: #fff3cd; color: #856404; }
.badge--done       { background: #d4edda; color: #155724; }
.badge--muted      { background: #f0f0f0; color: #666; }
.badge--info       { background: #d0e8ff; color: #0b4f9a; }
.badge--pending    { background: #fde8d0; color: #7b4200; }
.badge--answer     { background: #d4edda; color: #155724; font-size: .8rem; padding: .2rem .6rem; border-radius: var(--radius); }
.badge--skipped    { background: #ede9fe; color: #4c1d95; }
.badge--admin      { background: #d0e8ff; color: #0b4f9a; }
.badge--annotator  { background: #e8d4f0; color: #5a1a7b; }
.badge--lang_admin { background: #d4f0e8; color: #155724; }

/* ─── Subject tag ─────────────────────────────────────────────────────────────── */
.subject-tag { display: inline-block; padding: .15rem .5rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 4px; font-size: .75rem; color: var(--color-muted); white-space: nowrap; }

/* ─── Question meta bar ─────────────────────────────────────────────────────── */
.question-meta-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }

/* ─── Translation layout — two-column side by side ───────────────────────────── */
.translate-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 900px) {
  .translate-layout { grid-template-columns: 1fr 1fr; }
}

.translate-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.translate-panel--source { border-color: var(--color-border); }
.translate-panel--target { border-color: var(--color-primary-l); border-width: 2px; }

.panel-lang-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary-d);
  margin-bottom: 0;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--color-border);
}

.translate-block { display: flex; flex-direction: column; gap: .5rem; }

.translate-field-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Source text — read-only display */
.source-text {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--color-text);
  min-height: 80px;
}

/* Choices grid */
.choices-grid { display: flex; flex-direction: column; gap: .5rem; }

.choice-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .5rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  transition: border-color .15s;
}

.choice-row--correct {
  border-color: var(--color-primary-l);
  background: #f0f9f4;
}

.choice-letter {
  font-weight: 700;
  font-size: .9rem;
  color: var(--color-primary-d);
  min-width: 20px;
  flex-shrink: 0;
  padding-top: .1rem;
}

.choice-text {
  font-size: .9rem;
  line-height: 1.4;
  flex: 1;
  color: var(--color-text);
}

.choice-input {
  flex: 1;
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  padding: .35rem .6rem;
  font-size: .9rem;
  background: var(--color-surface);
  min-width: 0;
}

.choice-input:focus {
  border-color: var(--color-primary-l);
  box-shadow: 0 0 0 2px rgba(64,145,108,.2);
  outline: none;
}

/* ─── Guidelines box ─────────────────────────────────────────────────────────── */
.guidelines-box { background: #f0f9f4; border: 1px solid var(--color-accent); border-radius: var(--radius); padding: .75rem 1rem; font-size: .85rem; }
.guidelines-box summary { cursor: pointer; font-weight: 700; color: var(--color-primary-d); list-style: none; padding: .1rem 0; }
.guidelines-box summary::before { content: '▶ '; font-size: .75rem; }
.guidelines-box[open] summary::before { content: '▼ '; }
.guidelines-box ol { margin-top: .75rem; display: flex; flex-direction: column; gap: .4rem; color: var(--color-text); }

/* ─── Activity panel ─────────────────────────────────────────────────────────── */
.activity-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.activity-panel h3 { font-size: 1rem; margin-bottom: .75rem; color: var(--color-text); }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem; padding: .45rem 0; border-bottom: 1px solid var(--color-border); font-size: .85rem; line-height: 1.4; }
.activity-item:last-child { border-bottom: none; }
.activity-actor { font-weight: 600; color: var(--color-primary-d); white-space: nowrap; }
.activity-time { margin-left: auto; font-size: .75rem; color: var(--color-muted); white-space: nowrap; }

/* ─── Filter bar ─────────────────────────────────────────────────────────────── */
.filter-bar { margin-bottom: 1rem; }
.filter-bar-inner { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }

/* ─── Pagination ──────────────────────────────────────────────────────────────── */
.pagination { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1.25rem; }
.page-btn { padding: .3rem .65rem; border: 1.5px solid var(--color-border); border-radius: 6px; font-size: .85rem; color: var(--color-muted); text-decoration: none; transition: all .15s; }
.page-btn:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.page-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
}
.modal-card h3 { margin-bottom: 1rem; color: var(--color-primary-d); }

/* ─── Code block ──────────────────────────────────────────────────────────────── */
.code-block { background: #1a2e22; color: #95D5B2; border-radius: var(--radius); padding: 1rem 1.25rem; font-family: var(--font-mono); font-size: .82rem; overflow-x: auto; line-height: 1.6; white-space: pre; }

/* ─── Skip button & notice ────────────────────────────────────────────────────── */
.btn--skip { color: #7c3aed; margin-left: auto; }
.btn--skip:hover { background: #ede9fe; text-decoration: none; }
.skipped-notice { margin-top: .75rem; font-size: .85rem; color: #7c3aed; background: #ede9fe; border-radius: var(--radius); padding: .5rem .85rem; }

/* ─── Subject checklist (user_edit) ──────────────────────────────────────────── */
.subject-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .35rem .75rem;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem;
  background: var(--color-bg);
}
.subject-check-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  cursor: pointer;
}
.subject-check-item input { flex-shrink: 0; cursor: pointer; }

/* ─── Misc ────────────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-muted); grid-column: 1/-1; }
.muted { color: var(--color-muted); }
