/* ====================================================
   Kombucha Log – Gemeinsames Stylesheet
   Mobile-first, organischer Stil mit Erdtönen
   ==================================================== */

/* --- CSS-Variablen (Farbpalette & Abstände) --- */
:root {
  --braun-dunkel:  #3D1F0D;
  --braun:         #7B4A2D;
  --braun-hell:    #B8865A;
  --beige-dunkel:  #C4A882;
  --beige:         #E8DFC8;
  --beige-hell:    #F5F0E8;
  --gruen:         #6B9162;
  --gruen-hell:    #A8C5A0;
  --gruen-blass:   #EAF2E8;
  --gelb:          #C9A227;
  --gelb-blass:    #FBF4DC;
  --rot-blass:     #F5E8E8;
  --rot:           #C45A5A;
  --text-dunkel:   #2C1A0E;
  --text-mittel:   #5C3D25;
  --text-hell:     #8B6B4A;
  --hintergrund:   #F5F0E8;
  --karte-bg:      #FDFAF5;
  --rahmen:        #D4C4A8;
  --schatten:      rgba(75, 40, 15, 0.12);
}

/* --- Reset & Basis --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--hintergrund);
  color: var(--text-dunkel);
  line-height: 1.6;
  min-height: 100vh;
  /* Sicherer Bereich für iPhone-Notch etc. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Typographie --- */
h1, h2, h3 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: normal;
  line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { color: var(--text-mittel); }

/* --- App-Header --- */
.app-header {
  background: var(--braun);
  color: var(--beige-hell);
  padding: 0.9rem 1.25rem;
  padding-top: calc(0.9rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--schatten);
}

.app-header .logo {
  font-size: 1.4rem;
  line-height: 1;
}

.app-header h1 {
  font-size: 1.2rem;
  color: var(--beige-hell);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Zurück-Button im Header */
.back-btn {
  background: none;
  border: none;
  color: var(--beige-hell);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem 0.1rem;
  line-height: 1;
  text-decoration: none;
  display: flex;
  align-items: center;
  opacity: 0.9;
}

.back-btn:hover { opacity: 1; }

/* --- Haupt-Container --- */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* --- Karten --- */
.karte {
  background: var(--karte-bg);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 2px 12px var(--schatten);
  margin-bottom: 1rem;
  border: 1px solid var(--rahmen);
  animation: einblenden 0.2s ease both;
}

/* Brew-Karte als klickbarer Link */
.brew-karte {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.brew-karte:active {
  transform: scale(0.985);
  box-shadow: 0 1px 6px var(--schatten);
}

/* Farbiger Status-Streifen links */
.brew-karte-balken {
  width: 4px;
  min-height: 64px;
  border-radius: 2px;
  align-self: stretch;
  flex-shrink: 0;
}

.brew-karte-inhalt {
  flex: 1;
  min-width: 0;
}

.brew-karte-kopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.brew-karte-name {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  color: var(--text-dunkel);
  line-height: 1.3;
}

/* --- Status-Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.badge-aktiv {
  background: var(--gruen-blass);
  color: var(--gruen);
}

.badge-fertig {
  background: var(--beige);
  color: var(--text-hell);
}

.badge-pausiert {
  background: var(--gelb-blass);
  color: var(--gelb);
}

.badge-abgebrochen {
  background: var(--rot-blass);
  color: var(--rot);
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* --- pH-Info-Reihe (Karten-Unterzeile) --- */
.ph-info {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.ph-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.ph-info-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-hell);
  font-weight: 600;
}

.ph-info-wert {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-mittel);
}

/* pH-Farben: grün ≤3.5, gelb 3.5–5.0, rot >5.0 */
.ph-gut     { color: var(--gruen); }
.ph-okay    { color: var(--gelb); }
.ph-hoch    { color: var(--rot); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 1.4rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.12s, transform 0.1s;
  text-decoration: none;
  min-height: 50px;
  font-family: inherit;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.88;
}

.btn-primaer   { background: var(--braun);  color: var(--beige-hell); }
.btn-sekundaer { background: var(--beige);  color: var(--text-mittel); border: 1.5px solid var(--rahmen); }
.btn-gruen     { background: var(--gruen);  color: #fff; }
.btn-gefahr    { background: var(--rot-blass); color: var(--rot); border: 1.5px solid var(--rot); }

.btn-block { width: 100%; }

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.05rem;
  min-height: 58px;
  border-radius: 13px;
}

.btn-klein {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  min-height: 32px;
  border-radius: 7px;
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  right: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 29px;
  background: var(--braun);
  color: var(--beige-hell);
  border: none;
  font-size: 1.7rem;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(61, 31, 13, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.14s, box-shadow 0.14s;
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  padding-bottom: 1px; /* optische Zentrierung des + */
}

.fab:active {
  transform: scale(0.91);
  box-shadow: 0 2px 8px rgba(61, 31, 13, 0.3);
}

/* --- Formulare --- */
.form-gruppe {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-mittel);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1.5px solid var(--rahmen);
  border-radius: 10px;
  background: #fff;
  color: var(--text-dunkel);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 50px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--braun);
  box-shadow: 0 0 0 3px rgba(123, 74, 45, 0.13);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* Select mit eigenem Pfeil */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='%238B6B4A' d='M6 7L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-hell);
  margin-top: 0.3rem;
}

/* Großes pH-Eingabefeld für messung.html */
.ph-eingabe-gross {
  font-size: 3.2rem !important;
  text-align: center !important;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--braun);
  padding: 1rem !important;
  min-height: 90px !important;
  border-radius: 14px !important;
  border-width: 2px !important;
}

/* --- Foto-Upload --- */
.foto-upload-label {
  display: block;
  cursor: pointer;
}

.foto-upload-bereich {
  border: 2px dashed var(--rahmen);
  border-radius: 12px;
  padding: 1.75rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.foto-upload-bereich:hover,
.foto-upload-label:hover .foto-upload-bereich {
  border-color: var(--braun-hell);
  background: var(--beige);
}

.foto-upload-icon { font-size: 2rem; margin-bottom: 0.4rem; }
.foto-upload-text { color: var(--text-hell); font-size: 0.9rem; }

.foto-vorschau {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 0.75rem;
  display: none;
}

/* --- Sterne-Bewertung (CSS-only) --- */
/* DOM-Reihenfolge: ★5 ★4 ★3 ★2 ★1 → row-reverse dreht Anzeige um → ★1 ... ★5 */
.sterne-bewertung {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 0.3rem;
}

.sterne-bewertung input[type="radio"] { display: none; }

.sterne-bewertung label {
  font-size: 2.2rem;
  color: var(--beige-dunkel);
  cursor: pointer;
  transition: color 0.12s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.sterne-bewertung label:hover { transform: scale(1.12); }

/* Hover: diesen Stern und alle kleineren (spätere DOM-Geschwister) färben */
.sterne-bewertung label:hover,
.sterne-bewertung label:hover ~ label,
.sterne-bewertung input[type="radio"]:checked ~ label {
  color: var(--braun-hell);
}

/* --- Messungen-Liste --- */
.messungen-liste { list-style: none; }

.messung-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--beige);
}
.messung-item:last-child { border-bottom: none; }

.messung-ph {
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 3rem;
  font-family: Georgia, serif;
}

.messung-details { flex: 1; min-width: 0; }

.messung-notiz {
  font-size: 0.9rem;
  color: var(--text-dunkel);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messung-datum {
  font-size: 0.75rem;
  color: var(--text-hell);
  margin-top: 0.1rem;
}

/* --- Stats-Reihe (Brew-Detailseite oben) --- */
.stats-reihe {
  display: flex;
  border-radius: 14px;
  overflow: hidden;
}

.stat-item {
  flex: 1;
  text-align: center;
  padding: 0.9rem 0.5rem;
  border-right: 1px solid var(--beige);
}
.stat-item:last-child { border-right: none; }

.stat-wert {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--braun);
  font-family: Georgia, serif;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-hell);
  font-weight: 600;
  margin-top: 0.15rem;
}

/* --- Chart-Container --- */
.chart-container {
  position: relative;
  height: 190px;
  margin: 0.5rem 0;
}

/* --- Aktions-Buttons nebeneinander --- */
.aktionen-reihe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* --- Abschnitts-Titel --- */
.sektion-titel {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-hell);
  font-weight: 700;
  margin-bottom: 0.85rem;
}

/* --- Trennlinie --- */
.trenner {
  height: 1px;
  background: var(--beige);
  margin: 1rem 0;
}

/* --- Leerer Zustand --- */
.leer-zustand {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  color: var(--text-hell);
}

.leer-zustand-emoji { font-size: 3.5rem; margin-bottom: 1rem; }
.leer-zustand h2 { color: var(--text-mittel); margin-bottom: 0.5rem; }

/* --- Detail-Grid (Brew-Infos) --- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.detail-item {}

.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-hell);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.detail-wert {
  font-size: 0.95rem;
  color: var(--text-dunkel);
  font-weight: 500;
}

/* --- Einblende-Animation --- */
@keyframes einblenden {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Desktop-Anpassungen (ab 640px) --- */
@media (min-width: 640px) {
  .container { padding: 2rem; }

  .brew-karten-raster {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .brew-karten-raster .karte { margin-bottom: 0; }

  h1 { font-size: 2rem; }

  .ph-eingabe-gross { font-size: 4rem !important; }
}
