@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Regular.48cbe3a935fb.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-SemiBold.1792e2773e6e.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand colors */
  --primary: #567c8d;
  --primary-soft: color-mix(in srgb, var(--primary) 18%, white);
  --accent: #b7c688;
  --navy: #2f4156;
  --muted: #6b7280;
  --bg: #f4f0e7;
  --surface: #fbfaf6;
  --border: #c8d9e6;
  --success: #16a34a;
  --error: #dc2626;

  /* Typography */
  --font: "Poppins", system-ui, -apple-system, sans-serif;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 8px 24px rgba(47, 65, 86, 0.12), 0 24px 64px rgba(47, 65, 86, 0.12);
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over a component's display rule
   (a class like `display:flex` otherwise beats [hidden]'s UA `display:none`). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--navy);
  padding-bottom: var(--s-8);
}

a {
  color: var(--primary);
}

/* Type scale — one consistent set of heading sizes across every page, so
   "similar sections" (page titles, card headings, sub-headings) line up
   instead of each bare <h1> falling back to the oversized browser default. */
h1,
h2,
h3 {
  color: var(--navy);
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: 1.5rem; margin: 0 0 var(--s-4); }
h2 { font-size: 1.125rem; margin: 0 0 var(--s-3); }
h3 { font-size: 1rem; margin: 0 0 var(--s-2); }

.kp-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--s-4);
}

/* Card primitive */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
}

/* Modifier for standalone forms (e.g. login) that shouldn't stretch to the
   full width of the wider .kp-container. */
.card-narrow {
  max-width: 26rem;
  margin-left: auto;
  margin-right: auto;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}

/* Inside a card head the heading sits inline with the badge — drop its margin
   and let the global type scale drive the size (title h1 > section h2/h3). */
.card-head h1,
.card-head h2,
.card-head h3 {
  margin: 0;
}

/* Nav bar: tenant name (links home) + logout */
.kp-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  border-bottom: 1px solid var(--border);
  padding: var(--s-4) 0;
  margin-bottom: var(--s-5);
}

.kp-brand {
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
}

.btn-subtle {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: var(--s-1) var(--s-4);
  font-size: 0.85rem;
}

.btn-subtle:hover {
  background: var(--surface);
  color: var(--primary);
  box-shadow: none;
  transform: none;
}

/* Desktop tab nav — plain text links, underline marks the active tab */
.kp-tabs {
  display: flex;
  gap: var(--s-5);
  flex-wrap: wrap;
}

.kp-tab {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding-bottom: var(--s-2);
  border-bottom: 2px solid transparent;
}

.kp-tab:hover {
  color: var(--accent);
}

.kp-tab.active {
  color: var(--navy);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

.kp-tab.disabled {
  color: var(--muted);
  opacity: 0.5;
  pointer-events: none;
}

/* Home dashboard module: a clickable tile leading into a feature area */
.dashboard-tile {
  display: block;
  width: 100%;
  max-width: 320px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s-5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-tile:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dashboard-tile h2 {
  margin: 0 0 var(--s-4) 0;
  color: var(--navy);
  font-size: 1.1rem;
}

.dashboard-tile .tile-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.dashboard-tile .tile-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  font-size: 0.85rem;
  color: var(--muted);
}

.dashboard-tile .tile-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

/* Floating action button */
.kp-fab {
  position: fixed;
  right: var(--s-5);
  bottom: calc(var(--s-7) + var(--s-4));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-elevated);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
}

/* Forms */
.field {
  margin-bottom: var(--s-4);
}

.field label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: var(--s-1);
}

.field input {
  width: 100%;
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

.errors {
  color: var(--error);
  font-size: 0.875rem;
  margin-bottom: var(--s-4);
  list-style: none;
  padding: 0;
}

button {
  padding: var(--s-3) var(--s-5);
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover {
  background: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Status badge */
.badge {
  display: inline-block;
  padding: var(--s-1) var(--s-3);
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--border);
  color: var(--navy);
}

.badge.uploaded,
.badge.transcribing {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.done {
  background: #e6f6ea;
  color: var(--success);
}

.badge.error {
  background: #fde8e8;
  color: var(--error);
}

/* Recordings toolbar: search + status filter + sort (a plain GET form) */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  margin-bottom: var(--s-5);
}

.list-toolbar .toolbar-search {
  flex: 1 1 220px;
  min-width: 0;
}

.list-toolbar .toolbar-search,
.list-toolbar select {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--navy);
  background: var(--surface);
}

.list-toolbar select {
  cursor: pointer;
}

/* Group-by heading above a grid of that group's recordings */
.group-heading {
  margin: var(--s-6) 0 var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}

.group-heading:first-of-type {
  margin-top: 0;
}

.group-count {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

/* Recording list: card-per-recording grid */
.recording-grid {
  margin-bottom: var(--s-4);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-4);
}

.recording-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.recording-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Title spans the full tile width and clamps to two lines, so a long title
   never collides with the status badge (which now lives in the footer row).
   The reserved two-line height keeps every tile the same height. */
.rec-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
  margin: 0 0 var(--s-3);
  overflow-wrap: anywhere;
}

/* Footer pinned to the bottom of the tile: date on the left, badge on the
   right. Wraps the badge below the date only if the tile is very narrow. */
.rec-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1) var(--s-2);
  margin-top: auto;
}

.rec-foot .meta {
  margin: 0;
}

.empty {
  color: var(--muted);
}

/* Hides an input visually while keeping it functional and accessible
   (used for the file input triggered by the mic-FAB label). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Detail page top bar: back link + destructive action */
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.detail-topbar .back-link {
  font-size: 0.9rem;
}

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid color-mix(in srgb, var(--error) 35%, var(--border));
  box-shadow: none;
  padding: var(--s-1) var(--s-4);
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
  box-shadow: none;
  transform: none;
}

/* Details card: view + edit of the AI fields (title/category/customer/address) */
.meta-list {
  margin: 0;
  display: grid;
  gap: var(--s-2);
}

.meta-list > div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: var(--s-3);
  align-items: baseline;
}

.meta-list dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.meta-list dd {
  margin: 0;
  color: var(--navy);
}

@media (max-width: 480px) {
  .meta-list > div { grid-template-columns: 1fr; gap: 0; }
}

.meta-form .field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: var(--s-1);
}

.meta-form .field select {
  width: 100%;
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--navy);
}

.meta-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-3);
}

/* Audio player */
.audio-player {
  width: 100%;
  margin: var(--s-4) 0 var(--s-2);
}

/* Playback-speed control under the audio player */
.audio-speed {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.audio-speed-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.audio-speed button {
  padding: var(--s-1) var(--s-3);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--navy);
  box-shadow: none;
  cursor: pointer;
}

.audio-speed button:hover {
  transform: none;
  box-shadow: none;
  background: var(--surface);
}

.audio-speed button.active,
.audio-speed button.active:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Row of actions at the foot of a card (Kopieren + Neu generieren) */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  margin-top: var(--s-4);
}

/* "Transcription running" state with a live pulse */
.processing-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
}

.processing-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Transcript */
.transcript-details {
  margin-top: var(--s-4);
}

.transcript-details summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.9rem;
}

.transcript {
  white-space: pre-wrap;
  line-height: 1.5;
  margin-top: var(--s-3);
}

.meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: var(--s-5);
}

.error-msg {
  color: var(--error);
}

/* Summary card — a calm, consistent surface like every other card (not a heavy
   dark block), with a thin left accent bar so it still reads as the primary
   insight without shouting. */
.insight-hero {
  border-left: 3px solid var(--primary);
}

.insight-hero #summary-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 0;
}

.insight-hero #summary-key-points {
  padding-left: var(--s-5);
}

.insight-hero #summary-key-points li {
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Pulsing "generating" indicator */
.pulse-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 0.9rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Extraction card: exactly three text levels — the card title (h2), section
   labels (h3), and one uniform body treatment for ALL content (the lead
   sentence, item lines, materials, open questions) so nothing drifts in size. */
.extraction-list h3 {
  margin: var(--s-4) 0 var(--s-2);
}

.extraction-list h3:first-child {
  margin-top: 0;
}

.extraction-list p,
.extraction-list li {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
}

.extraction-list p {
  margin: 0 0 var(--s-2);
}

.extraction-lead {
  margin-bottom: var(--s-4);
}

.extraction-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.extraction-list li {
  padding: var(--s-1) 0;
}

.hidden {
  display: none;
}

/* Toast notification */
.kp-toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  z-index: 30;
}
