/* SchüSta Zeugnisarchiv – Styles */

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

:root {
  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-border: #d0d0d0;
  --color-primary: #1a4a8a;
  --color-primary-hover: #153d73;
  --color-secondary: #5a5a5a;
  --color-danger: #c0392b;
  --color-text: #1a1a1a;
  --color-muted: #666;
  --radius: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────── */
header {
  background: var(--color-primary);
  color: #fff;
  padding: 12px 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

header h1 { font-size: 20px; font-weight: 700; }

.header-subtitle {
  font-size: 13px;
  opacity: 0.75;
}

/* ── Main ────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
  flex: 1;
  width: 100%;
}

/* ── Suche ───────────────────────────────────────────── */
.search-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  flex: 1;
  min-width: 150px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(26,74,138,0.15);
}

.search-input--small { flex: 0 0 130px; }

.search-select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
  outline: none;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn--primary  { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }

.btn--secondary { background: var(--color-secondary); color: #fff; }
.btn--secondary:hover { opacity: 0.85; }

.btn--ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn--ghost:hover { background: rgba(26,74,138,0.06); }

.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--pdf  { background: #c0392b; color: #fff; }
.btn--pdf:hover  { background: #a93226; }

/* Word-Download Buttons */
.btn--docx { background: #1f5fa6; color: #fff; text-decoration: none; }
.btn--docx:hover { background: #174d8a; }

.docx-hint {
  font-size: 12px;
  color: #555;
  font-weight: 600;
  margin-bottom: 6px;
}

/* ── Ergebnistabelle ─────────────────────────────────── */
.results-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.results-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: #fafafa;
}

.results-count {
  font-size: 13px;
  color: var(--color-muted);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th {
  background: #f0f3f8;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-secondary);
  border-bottom: 1px solid var(--color-border);
}

.results-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: #f8f9fc; cursor: pointer; }

.name-cell { font-weight: 600; }
.klasse-badge {
  display: inline-block;
  background: #e8edf5;
  color: var(--color-primary);
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Detail-Panel ────────────────────────────────────── */
.detail-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.detail-header h2 { font-size: 18px; }

.schuljahr-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.schuljahr-block-header {
  background: #f0f3f8;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.schuljahr-block-header:hover { background: #e8edf5; }

.schuljahr-block-body {
  padding: 12px 14px;
  display: none;
}

.schuljahr-block-body.open { display: block; }

.noten-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.note-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #fafafa;
  border-radius: 4px;
  border: 1px solid #eee;
  font-size: 13px;
}

.note-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.note-1 { background: #27ae60; color: #fff; }
.note-2 { background: #2ecc71; color: #fff; }
.note-3 { background: #f39c12; color: #fff; }
.note-4 { background: #e67e22; color: #fff; }
.note-5 { background: var(--color-danger); color: #fff; }
.note-null { background: #ccc; color: #555; }

.pdf-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ── PDF Viewer ──────────────────────────────────────── */
.pdf-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f0f3f8;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.pdf-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.pdf-frame {
  width: 100%;
  height: 80vh;
  border: none;
  display: block;
}

/* ── Loading ─────────────────────────────────────────── */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--color-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #ddd;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Fehler ──────────────────────────────────────────── */
.error-box {
  background: #fdf0ee;
  border: 1px solid #f5c6c0;
  border-radius: var(--radius);
  color: var(--color-danger);
  padding: 12px 16px;
  margin-bottom: 16px;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 16px;
  color: var(--color-muted);
  font-size: 12px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
