/* ============================
   shared.css — Abitur Trainer
   Gemeinsame Styles für alle Module
   ============================ */

/* ====== CSS CUSTOM PROPERTIES ====== */
:root {
  --ink: #1a1a2e;
  --ink-light: #4a4a6a;
  --ink-muted: #8888a4;
  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: #d1fae5;
  --accent-glow: rgba(5, 150, 105, 0.08);
  --surface: #fff;
  --bg: #f0f0f5;
  --bg-warm: #fafafa;
  --border: #e2e2ec;
  --border-light: #f0f0f5;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #dc2626;
  --warning-bg: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(26,26,46,0.06);
  --shadow-md: 0 4px 16px rgba(26,26,46,0.08);
  --shadow-lg: 0 8px 32px rgba(26,26,46,0.12);
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* ====== BLUE ACCENT (English modules, Dashboard) ====== */
[data-accent="blue"] {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-glow: rgba(37, 99, 235, 0.08);
}

/* ====== AMBER ACCENT (Geschichte module) ====== */
[data-accent="amber"] {
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-soft: #fef3c7;
  --accent-glow: rgba(180, 83, 9, 0.08);
}

/* ====== VIOLET ACCENT (Wirtschaft & Recht module) ====== */
[data-accent="violet"] {
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #ede9fe;
  --accent-glow: rgba(124, 58, 237, 0.08);
}

/* ====== DARK MODE ====== */
[data-theme="dark"] {
  --ink: #e4e4ed;
  --ink-light: #b0b0c8;
  --ink-muted: #7878a0;
  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-soft: rgba(52, 211, 153, 0.15);
  --accent-glow: rgba(52, 211, 153, 0.08);
  --surface: #1e1e2e;
  --bg: #14141f;
  --bg-warm: #1a1a28;
  --border: #2e2e42;
  --border-light: #252538;
  --success: #34d399;
  --success-bg: rgba(52,211,153,0.1);
  --warning: #f87171;
  --warning-bg: rgba(248,113,113,0.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}
[data-accent="blue"][data-theme="dark"] {
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --accent-glow: rgba(96, 165, 250, 0.08);
}
[data-accent="amber"][data-theme="dark"] {
  --accent: #fbbf24;
  --accent-hover: #fcd34d;
  --accent-soft: rgba(251, 191, 36, 0.15);
  --accent-glow: rgba(251, 191, 36, 0.08);
}
[data-accent="violet"][data-theme="dark"] {
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, 0.15);
  --accent-glow: rgba(167, 139, 250, 0.08);
}

/* ====== RESET & BASE ====== */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ====== HEADER ====== */
header {
  background: var(--surface);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
header h1 { font-family: var(--font-display); font-size: 1.3rem; }
header h1 span { color: var(--accent); }
.header-left { display: flex; align-items: center; gap: 1rem; }
.back-link { color: var(--ink-muted); text-decoration: none; font-size: .85rem; }
.back-link:hover { color: var(--accent); }
.header-meta { font-size: .8rem; color: var(--ink-muted); }
.theme-toggle {
  background: var(--border);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
}
.theme-toggle:hover { background: var(--accent-soft); }
.header-right { display: flex; align-items: center; gap: .8rem; }

/* ====== NAV / STEPPER ====== */
nav {
  background: var(--surface);
  padding: 0 2rem;
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
nav button {
  background: none;
  border: none;
  padding: 1rem 1.2rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink-muted);
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
nav button:hover { color: var(--ink-light); }
nav button.active { color: var(--accent); border-bottom-color: var(--accent); }
.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  font-size: .75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
nav button.active .step-num { background: var(--accent); color: white; }

/* ====== MAIN CONTENT ====== */
main { flex: 1; max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; width: 100%; }
section { display: none; animation: fadeUp .3s ease-out; }
section.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; } }

/* ====== CARDS ====== */
.card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
}
.card-header { font-family: var(--font-display); font-size: 1.35rem; margin-bottom: 1.2rem; }

/* ====== FORMS ====== */
label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  color: var(--ink-light);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
select, input[type="number"] {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .95rem;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}
select:focus, input:focus { border-color: var(--accent); }
.form-group { margin-bottom: 1.2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--accent);
  color: white;
  border: none;
  padding: .75rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .95rem;
  transition: all .2s;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-danger { background: var(--warning); }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: .5rem 1rem; font-size: .85rem; }

/* ====== TASK & SOURCE ====== */
.task-box {
  background: var(--accent-glow);
  border-left: 4px solid var(--accent);
  padding: 1.4rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.7;
}
.source-text {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.6rem;
  margin: 1rem 0;
  line-height: 1.9;
  max-height: 500px;
  overflow-y: auto;
  cursor: text;
}
.source-meta { font-size: .85rem; color: var(--ink-muted); margin-top: 1rem; font-style: italic; }

/* ====== TEXTAREA & WRITE ====== */
textarea {
  width: 100%;
  min-height: 400px;
  padding: 1.4rem;
  font-family: var(--font-mono);
  font-size: .92rem;
  line-height: 1.7;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  color: var(--ink);
  background: var(--surface);
}
textarea:focus { border-color: var(--accent); }
.write-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .8rem;
  flex-wrap: wrap;
  gap: .8rem;
}
.word-counter { font-size: .85rem; color: var(--ink-muted); font-family: var(--font-mono); }

/* ====== SCORES ====== */
.scores-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.score-card {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  text-align: center;
}
.score-card.total { background: var(--accent-glow); border-color: var(--accent); }
.score-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; color: var(--ink-muted); margin-bottom: .3rem; }
.score-value { font-family: var(--font-display); font-size: 2rem; line-height: 1; }
.score-card.total .score-value { color: var(--accent); }
.score-max { font-size: .8rem; color: var(--ink-muted); }

/* ====== FEEDBACK ====== */
.feedback-body { line-height: 1.7; }
.feedback-body h2 { font-family: var(--font-display); font-size: 1.15rem; margin: 1.3rem 0 .6rem; }
.feedback-body ul, .feedback-body ol { padding-left: 1.5rem; margin: .5rem 0; }
.feedback-body li { margin-bottom: .3rem; }
.feedback-body p { margin-bottom: .6rem; }
.feedback-body blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1rem 0; color: var(--ink-light); font-style: italic; }
.pdf-actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ====== FEHLERKORREKTUR ====== */
.fehler-rs { background: #fecdd3; color: #be123c; border-radius: 2px; padding: 0 2px; cursor: help; }
.fehler-gr { background: #fed7aa; color: #c2410c; border-radius: 2px; padding: 0 2px; cursor: help; }
.korrektur-legende { display: flex; gap: 1rem; margin-bottom: 1rem; font-size: .8rem; }
.fehler-rs-demo { background: #fecdd3; color: #be123c; padding: 2px 8px; border-radius: 4px; }
.fehler-gr-demo { background: #fed7aa; color: #c2410c; padding: 2px 8px; border-radius: 4px; }
.korrektur-body { font-size: .95rem; line-height: 1.7; white-space: pre-wrap; padding: 1rem; background: var(--bg-warm); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.korrektur-teil { margin-bottom: 1rem; }
.korrektur-teil h3 { font-size: .9rem; font-weight: 600; margin-bottom: .5rem; color: var(--ink-muted); }

/* ====== FEHLENDE ASPEKTE ====== */
.aspekt-details { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; }
.aspekt-details summary { padding: .8rem 1rem; cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.aspekt-details summary:hover { background: var(--bg-warm); }
.aspekt-count { font-size: .75rem; color: var(--ink-muted); font-weight: 400; }
.aspekt-liste { padding: .5rem 1rem .8rem 2rem; }
.aspekt-liste li { margin-bottom: .3rem; color: var(--ink-muted); }

/* ====== LOADER ====== */
.loader { display: none; margin: 2rem auto; text-align: center; }
.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto .8rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: .85rem; color: var(--ink-muted); }

/* ====== TIMER ====== */
.timer-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem 1.2rem;
  margin-bottom: 1rem;
  display: none;
  align-items: center;
  justify-content: space-between;
}
.timer-bar.active { display: flex; }
.timer-display { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.timer-display.warning { color: var(--warning); }
.timer-controls { display: flex; gap: .5rem; }
.timer-label {
  font-size: .8rem;
  color: var(--ink-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.timer-controls button {
  background: var(--border);
  border: none;
  padding: .4rem .7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-light);
  transition: all .15s;
}
.timer-controls button:hover { background: var(--accent-soft); color: var(--accent); }
.timer-setup { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.timer-setup input[type="number"] { width: 70px; padding: .4rem .6rem; text-align: center; }

/* ====== PROGRESS / STATS ====== */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-warm); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; text-align: center; }
.stat-value { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: .75rem; color: var(--ink-muted); text-transform: uppercase; margin-top: .2rem; }
.chart-container { height: 220px; margin: 1rem 0; }
.history-chart { width: 100%; height: 220px; margin: 1rem 0; }
.history-chart canvas { width: 100% !important; height: 100% !important; }
.history-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 1rem; }
.history-table th {
  text-align: left;
  padding: .6rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--border);
}
.history-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border-light); color: var(--ink-light); }
.history-table tr:hover td { background: var(--accent-glow); }
.history-score { font-family: var(--font-mono); font-weight: 600; color: var(--accent); }
.history-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: .85rem;
  padding: .2rem;
  transition: color .15s;
}
.history-delete:hover { color: var(--warning); }
.history-empty { text-align: center; padding: 3rem 1rem; color: var(--ink-muted); }
.history-empty .empty-icon { font-size: 2.5rem; margin-bottom: .8rem; }

/* ====== HIGHLIGHTER ====== */
:root {
  --hl-yellow: rgba(250,204,21,.45);
  --hl-green: rgba(74,222,128,.45);
  --hl-blue: rgba(96,165,250,.45);
  --hl-pink: rgba(244,114,182,.45);
  --hl-orange: rgba(251,146,60,.45);
}
[data-theme="dark"] {
  --hl-yellow: rgba(250,204,21,.35);
  --hl-green: rgba(74,222,128,.35);
  --hl-blue: rgba(96,165,250,.35);
  --hl-pink: rgba(244,114,182,.35);
  --hl-orange: rgba(251,146,60,.35);
}
.highlighter-toolbar {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: .8rem;
  padding: .7rem 1rem;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.highlighter-toolbar .hl-label { font-size: .8rem; color: var(--ink-muted); font-weight: 600; margin-right: .3rem; }
.hl-btn { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .1s; }
.hl-btn:hover { transform: scale(1.1); }
.hl-btn.active { border-color: var(--ink); transform: scale(1.15); }
.hl-btn.yellow { background: #facc15; }
.hl-btn.green { background: #4ade80; }
.hl-btn.blue { background: #60a5fa; }
.hl-btn.pink { background: #f472b6; }
.hl-btn.orange { background: #fb923c; }
.hl-btn.eraser { background: var(--surface); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.hl-clear { margin-left: auto; font-size: .75rem; color: var(--ink-muted); background: none; border: 1px solid var(--border); padding: .3rem .6rem; border-radius: 4px; cursor: pointer; }
.hl-clear:hover { border-color: var(--warning); color: var(--warning); }
.hl-yellow { background: var(--hl-yellow); border-radius: 2px; padding: 0 2px; }
.hl-green { background: var(--hl-green); border-radius: 2px; padding: 0 2px; }
.hl-blue { background: var(--hl-blue); border-radius: 2px; padding: 0 2px; }
.hl-pink { background: var(--hl-pink); border-radius: 2px; padding: 0 2px; }
.hl-orange { background: var(--hl-orange); border-radius: 2px; padding: 0 2px; }

/* ====== TOAST ====== */
.toast {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warning);
  color: white;
  padding: .8rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .9rem;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: toastIn .3s ease-out;
  max-width: 90vw;
  text-align: center;
}
.toast.success { background: var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ====== OCR UPLOAD ====== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--bg-warm);
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-glow); }
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-icon { font-size: 2rem; margin-bottom: .5rem; }
.upload-text { font-size: .9rem; color: var(--ink-muted); }
.upload-text strong { color: var(--accent); }
.ocr-pages { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.ocr-page-thumb {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.ocr-page-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ocr-page-thumb .page-num {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,.6);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  text-align: center;
  padding: .15rem;
}
.ocr-page-thumb .remove-page {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220,38,38,.85);
  color: white;
  border: none;
  font-size: .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
}
.ocr-page-thumb:hover .remove-page { opacity: 1; }
.ocr-page-thumb.processing { border-color: var(--accent); animation: pulse 1.5s infinite; }
.ocr-page-thumb.done { border-color: var(--success); }
.ocr-page-thumb.error { border-color: var(--warning); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* ====== MODE TOGGLE ====== */
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .9rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink-muted);
  transition: all .2s;
}
.mode-btn:hover { border-color: var(--accent); color: var(--ink); }
.mode-btn.active { border-color: var(--accent); background: var(--accent-glow); color: var(--accent); }

/* ====== PDF ACTIONS ====== */
.pdf-actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ====== LOGIN SCREEN ====== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  text-align: center;
}
.login-box h2 { font-family: var(--font-display); font-size: 1.6rem; margin: .5rem 0; }
.login-box p { color: var(--ink-muted); font-size: .9rem; }
.login-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  background: var(--bg-warm);
  color: var(--ink);
  margin-top: .6rem;
  transition: border-color .2s;
}
.login-input:focus { border-color: var(--accent); }
.login-error {
  display: none;
  margin-top: .8rem;
  color: var(--warning);
  font-size: .85rem;
  font-weight: 600;
}
.school-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: .8rem;
  padding: .3rem .8rem;
  border-radius: 20px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
#app-wrapper {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

/* ====== UTILITIES ====== */
.text-muted { font-size: .85rem; color: var(--ink-muted); }

/* ====== FOOTER ====== */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--ink-muted);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
footer a { color: var(--ink-muted); text-decoration: none; }

/* ====== RESPONSIVE ====== */
@media (max-width: 650px) {
  .form-row, .scores-grid, .stats-grid { grid-template-columns: 1fr; }
  nav { padding: 0 1rem; }
  main { padding: 0 1rem; }
  .highlighter-toolbar { gap: .3rem; }
  header { padding: 1rem; }
}
