/* Tier-Tagebuch - schlankes CSS ohne Framework.
 * Mobile-first. Ein Spaltenlayout reicht in der Halter-Sicht;
 * in der Tierarzt-Sicht weiten sich Tabellen auf grossen Bildschirmen. */

:root {
  --primaer: #2b6cb0;
  --primaer-dunkel: #234e7a;
  --hintergrund: #f7fafc;
  --karte: #ffffff;
  --rand: #e2e8f0;
  --text: #1a202c;
  --text-leise: #4a5568;
  --erfolg: #2f855a;
  --fehler: #c53030;
  --hinweis: #2c5282;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--hintergrund);
}

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

.kopf {
  background: var(--primaer);
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.kopf a, .kopf .kopf-titel, .kopf .kopf-user { color: white; }
.kopf-titel { font-weight: 700; font-size: 1.1rem; }
.kopf-nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.kopf-nav a { padding: 0.25rem 0.5rem; border-radius: 4px; }
.kopf-nav a:hover { background: var(--primaer-dunkel); text-decoration: none; }
.kopf-user { opacity: 0.9; font-size: 0.95rem; }
.kopf-logout { margin: 0; }
.link-button {
  background: none; border: 1px solid white; color: white;
  padding: 0.25rem 0.6rem; border-radius: 4px; cursor: pointer;
  font: inherit;
}
.link-button:hover { background: rgba(255,255,255,0.1); }

.inhalt {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

.fuss {
  text-align: center;
  color: var(--text-leise);
  padding: 1.5rem 1rem;
}

.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.karte.schmal { max-width: 480px; margin-left: auto; margin-right: auto; }

h1, h2, h3 { margin-top: 0; color: var(--text); }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }

.zeile-zwischen {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kopf-aktionen { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.brot-krumen { color: var(--text-leise); margin-top: 0; }

.kacheln { display: flex; gap: 1rem; flex-wrap: wrap; }
.kachel {
  flex: 1 1 140px;
  background: var(--hintergrund);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text);
}
.kachel:hover { text-decoration: none; border-color: var(--primaer); }
.kachel-zahl { font-size: 2rem; font-weight: 700; color: var(--primaer); }
.kachel-label { color: var(--text-leise); font-size: 0.9rem; }

.tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.tabelle th, .tabelle td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rand);
}
.tabelle th { color: var(--text-leise); font-weight: 600; }

.daten { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; }
.daten dt { color: var(--text-leise); }
.daten dd { margin: 0; }

.steckbrief {
  font-size: 1.05rem;
  color: var(--text);
  margin: 0.3rem 0 0.2rem;
}
.klinische-notizen-karte {
  border-left: 4px solid var(--primaer);
}

.formular { display: flex; flex-direction: column; gap: 0.85rem; }
.formular.tagebuch { gap: 2.4rem; }
.formular.tagebuch fieldset { margin: 0; padding: 0.6rem 1.1rem 1.4rem; }
.formular.tagebuch fieldset legend { padding: 0 0.4rem; font-size: 1.05rem; }

/* Abstand zwischen den einzelnen Fragen innerhalb eines Fieldsets */
.formular.tagebuch .menge-zeile,
.formular.tagebuch .zaehl-zeile,
.formular.tagebuch .zwei-spalten { margin-top: 2rem; }
.formular.tagebuch .feld-gruppe-label { margin-top: 1.4rem; }
.formular.tagebuch .skala-pillen { margin: 0.4rem 0 0.4rem; }

/* Erstes Element nach dem Legend bekommt keinen extra Abstand. */
.formular.tagebuch fieldset > .zaehl-zeile:first-of-type,
.formular.tagebuch fieldset > .menge-zeile:first-of-type,
.formular.tagebuch fieldset > .schieberegler-rail:first-of-type,
.formular.tagebuch fieldset > label:first-of-type { margin-top: 0; }

.formular.tagebuch > label { margin-top: 0.4rem; }
.formular label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 500;
}
.formular input, .formular select, .formular textarea {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rand);
  border-radius: 6px;
  background: white;
  width: 100%;
  box-sizing: border-box;
}
.formular input[type="checkbox"],
.formular input[type="radio"],
.formular input[type="file"] {
  width: auto;
  padding: initial;
}
.formular textarea { resize: vertical; }
.formular .zeile-checkbox {
  flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400;
}

button, .knopf {
  background: var(--primaer);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover, .knopf:hover { background: var(--primaer-dunkel); text-decoration: none; }
.knopf-sekundaer {
  background: white;
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 0.7rem 1.1rem;
  font-weight: 500;
}
.knopf-sekundaer:hover { background: var(--hintergrund); text-decoration: none; }
.knoepfe { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }

.fehler { color: var(--fehler); background: #fff5f5; padding: 0.6rem 0.8rem;
          border-radius: 6px; border: 1px solid #feb2b2; }
.erfolg { color: var(--erfolg); background: #f0fff4; padding: 0.6rem 0.8rem;
          border-radius: 6px; border: 1px solid #9ae6b4; }
.hinweis { color: var(--hinweis); }
.hinweis-klein { color: var(--text-leise); font-size: 0.9rem; }

/* Status-Pillen */
.erfolg-pille, .entwurf-pille {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.erfolg-pille { background: #c6f6d5; color: #22543d; }
.entwurf-pille { background: #fed7aa; color: #7c2d12; }

/* Mehrzeiliger Text mit erhaltenen Zeilenumbrüchen (Hausbesuch-Details) */
.vorformatiert {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  line-height: 1.55;
}

/* Internes Feld: hebt sich vom Rest ab, damit klar ist
 * "das sieht die Halterin nicht". */
.intern-feld {
  background: #fffbf0;
  border: 1px dashed #f6c343;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.4rem;
}
.intern-feld-titel {
  color: #92621c;
  font-weight: 600;
  font-size: 0.92rem;
}

.privat-text {
  background: #fffbf0;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border-left: 3px solid #f6c343;
}

/* Anhang-Galerie */
.anhang-liste {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
}
.anhang-eintrag {
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: white;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.anhang-vorschau {
  display: block;
  background: var(--hintergrund);
  text-align: center;
  border-bottom: 1px solid var(--rand);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.anhang-vorschau img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.anhang-pdf-icon {
  font-size: 3rem;
  padding: 1.5rem;
  color: var(--text-leise);
}
.anhang-info {
  padding: 0.6rem 0.8rem 0.8rem;
  font-size: 0.9rem;
}
.anhang-zeile {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}
.anhang-zeile small { color: var(--text-leise); font-size: 0.75rem; }
.anhang-beschreibung { color: var(--text); margin-bottom: 0.3rem; }
.anhang-meta {
  font-size: 0.78rem;
  color: var(--text-leise);
  word-break: break-all;
  margin-bottom: 0.5rem;
}
.anhang-meta a { color: var(--text-leise); }
.knopf-loeschen-klein {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 5px;
  background: white;
  color: var(--fehler);
  border: 1px solid #feb2b2;
  cursor: pointer;
  font-weight: 600;
}
.knopf-loeschen-klein:hover { background: #fff5f5; }
.anhang-upload { margin-top: 1rem; padding: 1rem; background: var(--hintergrund); border-radius: 8px; }
.anhang-upload h3 { margin-top: 0; font-size: 1rem; }

/* Detail-Sicht eines Anhangs */
.anhang-vorschau-gross { text-align: center; padding: 1rem; }
.anhang-vorschau-gross img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.anhang-pdf-embed {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: var(--hintergrund);
}

/* Chat zwischen Halterin und Tierärztin */
.chat-liste {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-nachricht {
  max-width: 80%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.95rem;
}
.chat-nachricht--fremd {
  background: var(--hintergrund);
  border: 1px solid var(--rand);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.chat-nachricht--eigen {
  background: var(--primaer);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.chat-kopf {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
  opacity: 0.85;
}
.chat-nachricht--eigen .chat-kopf { color: white; opacity: 0.9; }
.chat-inhalt {
  white-space: pre-wrap;
  line-height: 1.4;
  word-break: break-word;
}
.chat-eingabe { margin-top: 0.6rem; }
.chat-aktionen {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.6rem;
  font-size: 0.78rem;
}
.chat-aktionen a, .chat-aktionen .link-button-klein {
  color: inherit;
  opacity: 0.85;
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.chat-aktionen a:hover, .chat-aktionen .link-button-klein:hover { opacity: 1; }

fieldset {
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 0.75rem;
}
fieldset legend { padding: 0 0.4rem; font-weight: 600; }

.radio-pille {
  display: inline-flex;
  align-items: center;
  margin: 0.2rem 0.4rem 0.2rem 0;
  border: 1px solid var(--rand);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  background: white;
  font-weight: 500;
}
.radio-pille input { margin-right: 0.4rem; }
.radio-pille:has(input:checked) {
  background: var(--primaer);
  color: white;
  border-color: var(--primaer);
}

/* Balken-Skala: Pillen nebeneinander, eine davon als "normal" markiert. */
.skala-balken { padding: 0.9rem 1rem; }
.skala-pillen {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.skala-pille {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 4.5rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 500;
  position: relative;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.skala-pille input { display: none; }
.skala-pille span { display: block; }
.skala-pille small {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.15rem;
  color: var(--erfolg);
}
.skala-pille:hover { border-color: var(--primaer); }
.skala-pille--normal {
  border-color: var(--erfolg);
  background: #f0fff4;
}
.skala-pille:has(input:checked) {
  background: var(--primaer);
  border-color: var(--primaer);
  color: white;
}
.skala-pille:has(input:checked) small { color: white; }

.menge-zeile {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.6rem;
}
.menge-zeile span {
  font-size: 0.85rem;
  color: var(--text-leise);
  font-weight: 500;
}

/* Schieberegler für Appetit / Trinken */
.schieberegler { padding: 1rem 1rem 0.8rem; }
.schieberegler-rail {
  position: relative;
  padding: 2rem 0 0.6rem;
}
/* "normal"-Beschriftung garantiert mittig im selben Container
 * wie der Tick - damit beide auf einer vertikalen Linie sind. */
.schieberegler-text {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}
/* Vertikaler "normal"-Strich, geht oben und unten etwas über die
 * Slider-Linie hinaus. Pointer-Events ignorieren, damit man durch
 * ihn hindurch den Slider greifen kann. */
.schieberegler-tick {
  position: absolute;
  left: 50%;
  /* zentriert um die Slider-Linie (rail padding-top 2rem + halbe
   * Slider-Höhe 4px = ~36px), Höhe 16px → nur leicht über und
   * unter die Slider-Linie hinaus. */
  top: calc(2rem - 5px);
  height: 18px;
  width: 2px;
  background: #1a202c;
  pointer-events: none;
  transform: translateX(-50%);
}
.schieberegler input[type=range] {
  position: relative;
  z-index: 1;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--primaer);
  height: 8px;
  margin: 0;
  outline: none;
  background: transparent;
}
/* Track-Styling (Browser-spezifisch, weil accent-color den Fill nur
 * in Chrome/Edge richtig macht; in Safari/Firefox braucht es eigene
 * Track-Regeln). */
.schieberegler input[type=range]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
}
.schieberegler input[type=range]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
}
.schieberegler input[type=range]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--primaer);
}
.schieberegler input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primaer);
  cursor: grab;
  margin-top: -7px;
  border: none;
}
.schieberegler input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primaer);
  cursor: grab;
  border: none;
}
.schieberegler input[type=range]:active::-webkit-slider-thumb { cursor: grabbing; }
.schieberegler-skala {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-leise);
  gap: 0.2rem;
}
.schieberegler-skala span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  padding: 0 0.1rem;
  line-height: 1.2;
}
.schieberegler-skala span:first-child { text-align: left; }
.schieberegler-skala span:last-child  { text-align: right; }
.schieberegler-tick--normal {
  color: var(--erfolg);
  font-weight: 600;
}

/* Hilfsklassen für Erbrechen/Husten-Sektion */
.feld-gruppe-label {
  font-size: 0.85rem;
  color: var(--text-leise);
  font-weight: 500;
  margin: 0.7rem 0 0.3rem;
}
.feld-gruppe-label:first-child { margin-top: 0; }

/* Zähl-Zeile: Label oben, Eingabefeld darunter, schmaler */
.zaehl-zeile {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}
.zaehl-zeile span {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}
.zaehl-zeile input[type=number] {
  max-width: 10rem;
}
.zwei-spalten {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.zwei-spalten label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.zwei-spalten label span {
  font-size: 0.85rem;
  color: var(--text-leise);
  font-weight: 500;
}

/* Tab-Filter in der Tierarzt-Verlaufsansicht */
.kategorie-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.kategorie-tab {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--rand);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
}
.kategorie-tab:hover {
  border-color: var(--primaer);
  text-decoration: none;
}
.kategorie-tab--aktiv {
  background: var(--primaer);
  color: white;
  border-color: var(--primaer);
}

.liste-karten { list-style: none; padding: 0; margin: 0;
                display: flex; flex-direction: column; gap: 0.6rem; }
.karte-mini {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.75rem 1rem;
  border: 1px solid var(--rand); border-radius: 8px; background: white;
}
.karte-mini-link { display: flex; flex-direction: column; color: var(--text); }
.karte-mini-link:hover { text-decoration: none; }

.eintrags-liste { list-style: none; padding: 0; margin: 0;
                  display: flex; flex-direction: column; gap: 0.5rem; }
.eintrag { border: 1px solid var(--rand); border-radius: 8px;
           padding: 0.75rem 1rem; background: white; }
.eintrag-kopf { color: var(--text-leise); margin-bottom: 0.3rem; }
.eintrag-aktionen {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rand);
  align-items: stretch;
}
.inline-form {
  margin: 0;
  flex: 1 1 0;
  display: flex;
}
.eintrag-aktionen .knopf-klein,
.eintrag-aktionen .knopf-sekundaer-klein,
.eintrag-aktionen .knopf-loeschen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  text-align: center;
  line-height: 1.2;
}
.eintrag-aktionen .knopf-klein {
  background: var(--primaer); color: white;
}
.eintrag-aktionen .knopf-klein:hover {
  background: var(--primaer-dunkel); text-decoration: none;
}
.eintrag-aktionen .knopf-sekundaer-klein {
  background: white; color: var(--text); border-color: var(--rand);
}
.eintrag-aktionen .knopf-sekundaer-klein:hover {
  background: var(--hintergrund); text-decoration: none;
}
.eintrag-aktionen .knopf-loeschen {
  background: white; color: var(--fehler); border-color: #feb2b2;
}
.eintrag-aktionen .knopf-loeschen:hover { background: #fff5f5; }
.eintrag-daten { display: grid; grid-template-columns: max-content 1fr;
                 gap: 0.2rem 0.8rem; margin: 0; }
.eintrag-daten dt { color: var(--text-leise); }
.eintrag-daten dd { margin: 0; }

@media (min-width: 700px) {
  .formular.tagebuch fieldset { padding: 1rem; }
}
