/* AKROVAL Lernsystem — Corporate Design */
/* Abgeleitet aus akroval-de/src/css/style.css */

/* ── Schriftarten (lokal, DSGVO-konform) ─────────────────────────────────── */

@font-face {
  font-family: 'Ubuntu';
  src: url('/static/fonts/ubuntu-700-latin-ext.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Ubuntu';
  src: url('/static/fonts/ubuntu-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hanken Grotesk';
  src: url('/static/fonts/hanken-grotesk-latin-ext.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF;
}

@font-face {
  font-family: 'Hanken Grotesk';
  src: url('/static/fonts/hanken-grotesk-latin.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

/* ── CSS-Variablen ────────────────────────────────────────────────────────── */

:root {
  --color-primary:     #2c4a6e;
  --color-accent:      #d4941f;
  --color-accent-dark: #b87d18;
  --color-surface:     #f0f4f8;
  --color-bg:          #ffffff;
  --color-text:        #555555;
  --color-text-dark:   #333333;
  --color-border:      #e0e0e0;
  --color-white:       #ffffff;
  --color-success-bg:  #eaf4ea;
  --color-success-fg:  #2d5a2d;
  --color-success-bd:  #4a8c4a;
  --color-error-bg:    #fdf0f0;
  --color-error-fg:    #7b1f1f;
  --color-error-bd:    #c0392b;

  --font-heading:  'Ubuntu', sans-serif;
  --font-body:     'Hanken Grotesk', sans-serif;

  --container-max: 1100px;
  --container-pad: 1.5rem;
  --header-h:      64px;
  --radius:        4px;
  --shadow-card:   0 2px 12px rgba(44, 74, 110, 0.07);
  --shadow-hover:  0 6px 24px rgba(44, 74, 110, 0.13);
  --transition:    160ms ease;
}

@media (min-width: 768px) {
  :root {
    --container-pad: 2.5rem;
    --header-h: 72px;
  }
}

/* ── Reset & Basis ────────────────────────────────────────────────────────── */

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

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

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--color-primary);
  line-height: 1.2;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Skip-Link ────────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  background: var(--color-primary);
  color: var(--color-white);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  z-index: 9999;
  transition: top var(--transition);
}
.skip-link:focus { top: 0.5rem; }

/* ── Container ────────────────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--color-primary);
  white-space: nowrap;
}

.logo-badge {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-accent);
  background: rgba(212, 148, 31, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  white-space: nowrap;
}

.main-nav ul {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  align-items: center;
}

.main-nav a {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-dark);
  position: relative;
  padding-bottom: 2px;
  transition: color var(--transition);
  text-decoration: none;
}

.main-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width var(--transition);
}

.main-nav a:hover { color: var(--color-primary); text-decoration: none; }
.main-nav a:hover::after { width: 100%; }

.main-nav a.active {
  color: var(--color-primary);
}
.main-nav a.active::after { width: 100%; }

/* ── Haupt-Inhalt ─────────────────────────────────────────────────────────── */

main {
  flex: 1;
  padding-top: var(--header-h);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

.site-footer {
  background: var(--color-primary);
  color: rgba(255, 255, 255, 0.7);
  padding-block: 1.25rem;
  font-size: 0.875rem;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  text-align: center;
}

@media (min-width: 768px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition:
    background-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-white);
}

.btn-primary:hover {
  background: var(--color-accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 148, 31, 0.3);
  color: var(--color-white);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface);
  text-decoration: none;
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Formulare ────────────────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text-dark);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #bbbbbb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44, 74, 110, 0.12);
}

.form-group textarea { resize: vertical; min-height: 120px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */

.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  border-left: 4px solid;
}

.alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-bd);
  color: var(--color-success-fg);
}

.alert-error {
  background: var(--color-error-bg);
  border-color: var(--color-error-bd);
  color: var(--color-error-fg);
}

.alert-info {
  background: rgba(44, 74, 110, 0.06);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-left: 4px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition:
    border-left-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.card:hover {
  border-left-color: var(--color-accent);
  box-shadow: var(--shadow-hover);
}

/* ── Login-Seite ──────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h) - 60px);
  padding: 2rem var(--container-pad);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2.5rem 2rem;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-card .subtitle {
  font-size: 0.875rem;
  color: #999;
  margin-bottom: 2rem;
}

.login-divider {
  display: block;
  width: 2.5rem;
  height: 3px;
  background: var(--color-accent);
  margin: 0.6rem 0 1.5rem;
}

/* ── Chat-Seite ───────────────────────────────────────────────────────────── */

.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - 60px);
  max-width: var(--container-max);
  margin-inline: auto;
  padding: 1.5rem var(--container-pad);
  gap: 1rem;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.chat-toolbar label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-dark);
}

.collection-checks {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.collection-checks label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
}

.collection-checks input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 1rem;
  height: 1rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.message {
  max-width: 85%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  line-height: 1.65;
}

.message-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-white);
}

.message-assistant {
  align-self: flex-start;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  color: var(--color-text-dark);
}

.message-sources {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: #777;
}

.source-tag {
  display: inline-block;
  background: rgba(44, 74, 110, 0.07);
  color: var(--color-primary);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  margin: 0.15rem;
  font-size: 0.78rem;
}

.chat-input-row {
  display: flex;
  gap: 0.75rem;
}

.chat-input-row textarea {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  resize: none;
  min-height: 56px;
  max-height: 160px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-row textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44, 74, 110, 0.12);
}

/* ── Upload-Seite ─────────────────────────────────────────────────────────── */

.upload-page {
  max-width: 800px;
  margin-inline: auto;
  padding: 2rem var(--container-pad);
}

.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  background: var(--color-surface);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--color-accent);
  background: rgba(212, 148, 31, 0.04);
}

.upload-area p {
  color: #777;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.upload-list {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.upload-item {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.upload-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

.upload-item-name {
  font-weight: 500;
  color: var(--color-text-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.upload-status {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.15rem 0.6rem;
  border-radius: 2px;
  white-space: nowrap;
}

.status-uploading {
  background: rgba(44, 74, 110, 0.1);
  color: var(--color-primary);
}

.status-processing {
  background: rgba(212, 148, 31, 0.1);
  color: #a06010;
}

.status-done {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}

.status-error {
  background: var(--color-error-bg);
  color: var(--color-error-fg);
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--color-surface);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 0.2s ease;
  width: 0%;
}

.progress-fill.done { background: var(--color-success-bd); }
.progress-fill.error { background: var(--color-error-bd); }

/* ── Gutachten-Seite ──────────────────────────────────────────────────────── */

.gutachten-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 1.5rem var(--container-pad);
  max-width: var(--container-max);
  margin-inline: auto;
}

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

.gutachten-sidebar {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: fit-content;
}

.gutachten-sidebar h3 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-accent);
}

.pflicht-liste {
  list-style: none;
  font-size: 0.83rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pflicht-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 2px;
  color: var(--color-text);
  transition: background var(--transition);
}

.pflicht-item:hover { background: var(--color-surface); }

.pflicht-bullet {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--color-border);
  margin-top: 0.45rem;
}

.pflicht-bullet.checked { background: var(--color-success-bd); }
.pflicht-bullet.missing { background: var(--color-error-bd); }

.gutachten-chat-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: calc(100vh - var(--header-h) - 100px);
}

/* ── Abschnitt-Titel ──────────────────────────────────────────────────────── */

.section-title {
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  color: var(--color-primary);
  margin-bottom: 0.1rem;
}

.section-title::after {
  content: '';
  display: block;
  width: 2.5rem;
  height: 3px;
  background: var(--color-accent);
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
}

/* ── Lade-Indikator ───────────────────────────────────────────────────────── */

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.6rem 0.8rem;
  align-self: flex-start;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-border);
  animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 80%, 100% { background: var(--color-border); }
  40%           { background: var(--color-primary); }
}

/* ── Reduced Motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Responsiv ────────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .main-nav ul { gap: 1rem; }
  .main-nav a { font-size: 0.85rem; }
  .chat-layout { padding: 1rem; }
  .message { max-width: 95%; }
}

/* ── Docs-Verwaltungsliste ────────────────────────────────────────────────── */

.docs-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.docs-empty {
  color: #999;
  font-size: 0.875rem;
}

.docs-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.docs-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-text-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.docs-item-meta {
  font-size: 0.78rem;
  color: #999;
  white-space: nowrap;
}

.docs-cat-badge {
  font-size: 0.73rem;
  font-weight: 500;
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
  white-space: nowrap;
}

.docs-cat-lehrmaterial { background: rgba(44, 74, 110, 0.1); color: var(--color-primary); }
.docs-cat-gutachten    { background: rgba(212, 148, 31, 0.1); color: #a06010; }
.docs-cat-marktdaten   { background: rgba(74, 140, 74, 0.1);  color: var(--color-success-fg); }

.btn-delete {
  background: none;
  border: 1px solid var(--color-error-bd);
  color: var(--color-error-fg);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.btn-delete:hover  { background: var(--color-error-bg); }
.btn-delete:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Markdown-Formatierung in Chat-Nachrichten ────────────────────────────── */

.message-assistant p {
  margin: 0 0 0.6rem;
}

.message-assistant p:last-child { margin-bottom: 0; }

.message-assistant h4,
.message-assistant h5 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.75rem 0 0.25rem;
  color: var(--color-primary);
}

.message-assistant h4:first-child,
.message-assistant h5:first-child { margin-top: 0; }

.message-assistant ul,
.message-assistant ol {
  margin: 0.35rem 0 0.6rem 1.4rem;
  padding: 0;
}

.message-assistant li { margin-bottom: 0.2rem; }

.message-assistant code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85em;
  background: rgba(44, 74, 110, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

.message-assistant hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.75rem 0;
}

.message-assistant strong { font-weight: 700; }
.message-assistant em     { font-style: italic; }

.message-assistant table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.6rem 0;
  font-size: 0.88rem;
}
.message-assistant th,
.message-assistant td {
  border: 1px solid #d0cfc8;
  padding: 0.35rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
.message-assistant th {
  background: #f0ede5;
  font-weight: 700;
  color: var(--color-primary, #3b2f1e);
}
.message-assistant tr:nth-child(even) td {
  background: #faf9f6;
}
