/* Miet-Monitor Web — Gestaltung.
 *
 * Bewusst dieselbe Farb- und Formensprache wie die statische Uebersicht
 * (report.py): es ist dieselbe Anwendung, nur mit Anmeldung. Wer beides
 * nebeneinander offen hat, soll nicht zwei Programme sehen.
 *
 * Als eigene Datei und nicht im Template, weil die Content-Security-Policy
 * kein `unsafe-inline` erlaubt. Der statische Bericht muss einbetten, weil er
 * per file:// laeuft — hier ist das Gegenteil richtig.
 *
 * Thai: keine Webfonts (die CSP laesst keine fremde Quelle zu, und das
 * Projekt liefert grundsaetzlich keine fremden Ressourcen aus). Stattdessen
 * eine Schriftliste mit den Thai-Systemschriften und mehr Zeilenabstand —
 * thailaendische Schrift hat Ober- und Unterzeichen, die bei 1.55 kollidieren.
 */

:root {
  --bg: #f7f6f3; --karte: #ffffff; --text: #1c1b19; --gedaempft: #6b6862;
  --rand: #e0ddd6; --akzent: #1f6f5c; --akzent-schwach: #e6f0ec;
  --warn-bg: #fdf3e3; --warn-text: #8a5a12;
  --stern: #d9a406;
  --fehler-bg: #fdecea; --fehler-text: #a3282c;
  --status-offen-bg: #eeece7; --status-offen-text: #5c5952;
  --status-angefragt-bg: #fdf3e3; --status-angefragt-text: #8a5a12;
  --status-antwort-bg: #e6f0ec; --status-antwort-text: #1f6f5c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a; --karte: #1f2225; --text: #e8e6e3; --gedaempft: #9a9791;
    --rand: #32363a; --akzent: #5cc4a7; --akzent-schwach: #1d3630;
    --warn-bg: #3a2f1c; --warn-text: #e0b969;
    --stern: #e8bd3c;
    --fehler-bg: #3b1f20; --fehler-text: #f0a3a5;
    --status-offen-bg: #2a2d30; --status-offen-text: #a8a5a0;
    --status-angefragt-bg: #3a2f1c; --status-angefragt-text: #e0b969;
    --status-antwort-bg: #1d3630; --status-antwort-text: #5cc4a7;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0; padding: 0 1.25rem 4rem;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
}

/* Thai braucht Luft: die Vokal- und Tonzeichen stehen ueber und unter der
 * Grundlinie und beruehren sich bei engem Zeilenabstand. */
html[lang="th"] body {
  font-family: "Noto Sans Thai", "IBM Plex Sans Thai", "Sarabun", "Thonburi",
               -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.8;
}
html[lang="th"] .marke, html[lang="th"] .status { line-height: 1.5; }

.huelle { max-width: 1080px; margin: 0 auto; }
a { color: var(--akzent); }

/* -- Kopfzeile ------------------------------------------------------------ */
.kopfleiste {
  border-bottom: 1px solid var(--rand); margin-bottom: 1.5rem;
  background: var(--karte);
  margin-left: -1.25rem; margin-right: -1.25rem; padding: 0 1.25rem;
}
.kopfleiste .huelle {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .7rem 0;
}
.marke-name { font-weight: 700; font-size: 1rem; margin: 0; }
.marke-name a { color: inherit; text-decoration: none; }
nav.haupt { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
nav.haupt a {
  text-decoration: none; font-size: .9rem; color: var(--gedaempft);
  padding: .2rem 0; border-bottom: 2px solid transparent;
}
nav.haupt a:hover { color: var(--text); }
nav.haupt a.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); }
nav.haupt .zahl {
  font-size: .72rem; background: var(--akzent-schwach); color: var(--akzent);
  border-radius: 999px; padding: .05rem .4rem; margin-left: .25rem;
}
.kopf-rechts {
  display: flex; align-items: center; gap: .85rem; flex-wrap: wrap;
  font-size: .85rem; color: var(--gedaempft);
}

/* Auf dem Telefon reicht die Breite nicht fuer eine Zeile. Ohne diese Regel
 * bricht die Navigation um und jeder Punkt landet rechtsbuendig auf einer
 * eigenen Zeile — 400 px Kopfleiste, bevor der erste Treffer kommt.
 * Deshalb hier ausdruecklich drei Reihen: Name, Navigation, Konto. */
@media (max-width: 640px) {
  .kopfleiste .huelle {
    flex-direction: column; align-items: stretch; gap: .55rem; padding: .6rem 0;
  }
  nav.haupt { flex: none; gap: 1.1rem; }
  .kopf-rechts { justify-content: space-between; gap: .6rem; }
  .kopf-rechts > span { order: -1; }        /* Name vor die Knoepfe */
}

/* Sprachumschalter: zwei Knöpfe, kein Auswahlfeld — bei zwei Sprachen ist
 * ein Klick weniger Arbeit als aufklappen, wählen, bestätigen. */
.sprachwahl { display: flex; gap: .25rem; }
.sprachwahl button {
  font: inherit; font-size: .82rem; padding: .2rem .55rem; cursor: pointer;
  background: transparent; color: var(--gedaempft);
  border: 1px solid var(--rand); border-radius: 6px;
}
.sprachwahl button:hover { color: var(--text); }
.sprachwahl button[aria-current="true"] {
  background: var(--akzent-schwach); color: var(--akzent);
  border-color: var(--akzent); font-weight: 600;
}

/* -- Knoepfe -------------------------------------------------------------- */
.knopf, button.knopf {
  font: inherit; font-size: .9rem; padding: .45rem .9rem; cursor: pointer;
  background: var(--akzent); color: #fff; border: 1px solid var(--akzent);
  border-radius: 6px; text-decoration: none; display: inline-block;
}
.knopf:hover { filter: brightness(1.08); }
.knopf.leise {
  background: transparent; color: var(--gedaempft); border-color: var(--rand);
}
.knopf.leise:hover { color: var(--text); }
.textknopf {
  background: none; border: none; padding: 0; font: inherit; font-size: .875rem;
  color: var(--akzent); cursor: pointer; text-decoration: underline;
}

/* -- Seitenkopf ----------------------------------------------------------- */
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
.stand { color: var(--gedaempft); font-size: .875rem; margin-bottom: 1.5rem; }

/* -- Filter --------------------------------------------------------------- */
.filter {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 10px;
  padding: 1rem; margin-bottom: 1.25rem;
  display: grid; gap: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}
.filter label {
  display: block; font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--gedaempft); margin-bottom: .3rem;
}
html[lang="th"] .filter label { text-transform: none; letter-spacing: 0; }
.filter input, .filter select {
  width: 100%; padding: .45rem .55rem; font: inherit; font-size: .9rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--rand); border-radius: 6px;
}
.filter input:focus, .filter select:focus {
  outline: 2px solid var(--akzent); outline-offset: -1px;
}

.zusammenfassung {
  display: flex; flex-wrap: wrap; gap: .5rem 1.25rem;
  align-items: baseline; margin-bottom: 1rem; font-size: .9rem;
}
.zusammenfassung strong { font-size: 1.15rem; }
.zusammenfassung .zaehler { color: var(--gedaempft); font-size: .85rem; }

/* -- Trefferkarte --------------------------------------------------------- */
.karte {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 10px;
  padding: .95rem 1.1rem; margin-bottom: .7rem;
  display: flex; gap: 1rem; align-items: flex-start;
}
.karte.ist-favorit { border-left: 3px solid var(--stern); }
.karte > .inhalt { flex: 1; min-width: 0; }

.bild {
  flex: 0 0 132px; width: 132px; height: 99px;   /* 4:3 */
  border-radius: 7px; overflow: hidden; background: var(--akzent-schwach);
  display: flex; align-items: center; justify-content: center;
}
.bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bild.leer::after {
  content: attr(data-leer); font-size: .7rem; color: var(--gedaempft);
  text-align: center; padding: .2rem;
}

@media (max-width: 560px) {
  .karte { flex-direction: column; }
  .bild { flex: none; width: 100%; height: 150px; }
}

.kopf {
  display: flex; gap: .75rem; align-items: baseline;
  justify-content: space-between; flex-wrap: wrap;
}
.titelzeile { display: flex; gap: .5rem; align-items: baseline; min-width: 0; }
.titel { font-weight: 600; font-size: 1rem; margin: 0; }
.titel a { color: inherit; text-decoration: none; }
.titel a:hover { color: var(--akzent); text-decoration: underline; }
.preis {
  font-weight: 700; font-size: 1.05rem; color: var(--akzent);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.preis .einheit { font-weight: 400; }
.meta { color: var(--gedaempft); font-size: .875rem; margin-top: .3rem; }
.fasst { margin-top: .45rem; font-size: .9rem; }
.meta.strand { margin-top: .15rem; }
.meta.strand.nah { color: var(--akzent); font-weight: 600; }

.marken { margin-top: .55rem; display: flex; flex-wrap: wrap; gap: .35rem;
  align-items: center; }
.marke {
  font-size: .74rem; padding: .16rem .5rem; border-radius: 999px;
  background: var(--akzent-schwach); color: var(--akzent); white-space: nowrap;
}
.marke.warn { background: var(--warn-bg); color: var(--warn-text); }

.region-kopf {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--gedaempft);
  margin: 1.6rem 0 .55rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--rand);
}
html[lang="th"] .region-kopf { text-transform: none; letter-spacing: 0; }
.nichts { text-align: center; padding: 3rem 1rem; color: var(--gedaempft); }

/* -- Stern -------------------------------------------------------------- */
.stern {
  background: none; border: none; padding: .1rem .2rem; cursor: pointer;
  font-size: 1.15rem; line-height: 1; color: var(--rand);
  flex: 0 0 auto; border-radius: 5px;
}
.stern:hover { color: var(--stern); }
.stern[aria-pressed="true"] { color: var(--stern); }
.stern:focus-visible { outline: 2px solid var(--akzent); }
.stern[disabled] { opacity: .4; cursor: progress; }

/* -- Status ------------------------------------------------------------- */
.status {
  font-size: .74rem; font-weight: 600; padding: .16rem .55rem;
  border-radius: 999px; white-space: nowrap;
  background: var(--status-offen-bg); color: var(--status-offen-text);
}
.status[data-status="angefragt"] {
  background: var(--status-angefragt-bg); color: var(--status-angefragt-text);
}
.status[data-status="antwort_vermieter"] {
  background: var(--status-antwort-bg); color: var(--status-antwort-text);
}

/* -- Karte (Leaflet) ---------------------------------------------------- */
#karte {
  height: 420px; border: 1px solid var(--rand); border-radius: 10px;
  margin-bottom: 1.25rem; background: var(--karte); z-index: 0;
}
#karte.aus { display: none; }
.karten-kopf {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap;
}
.karten-kopf .zaehler { color: var(--gedaempft); font-size: .85rem; }
/* Eigener Marker statt Leaflet-Standardbild (keine Bilddateien dabei). */
.pin {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--akzent); border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.pin.favorit { background: var(--stern); }
.leaflet-popup-content { margin: .6rem .8rem; font: inherit; font-size: .85rem; }
.leaflet-popup-content img {
  width: 100%; border-radius: 5px; margin-bottom: .4rem; display: block;
}
.leaflet-popup-content .pp { font-weight: 700; color: var(--akzent); }
.leaflet-popup-content a { color: var(--akzent); }
.leaflet-container { background: var(--akzent-schwach); font: inherit; }

/* -- Anmeldung ---------------------------------------------------------- */
.anmeldebox {
  max-width: 380px; margin: 4rem auto; background: var(--karte);
  border: 1px solid var(--rand); border-radius: 12px; padding: 1.75rem;
}
.anmeldebox h1 { font-size: 1.3rem; margin-bottom: 1.25rem; }
.feld { margin-bottom: 1rem; }
.feld label {
  display: block; font-size: .78rem; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--gedaempft); margin-bottom: .3rem;
}
html[lang="th"] .feld label { text-transform: none; letter-spacing: 0; }
.feld input[type="email"], .feld input[type="password"], .feld textarea,
.feld select {
  width: 100%; padding: .55rem .65rem; font: inherit;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--rand); border-radius: 6px;
}
.feld input:focus, .feld textarea:focus, .feld select:focus {
  outline: 2px solid var(--akzent); outline-offset: -1px;
}
.feld.kasten { display: flex; align-items: center; gap: .5rem; }
.feld.kasten label {
  text-transform: none; letter-spacing: 0; margin: 0; font-weight: 400;
  font-size: .9rem; color: var(--text);
}
.anmeldebox .knopf { width: 100%; text-align: center; }
.meldung {
  padding: .6rem .75rem; border-radius: 6px; font-size: .88rem;
  margin-bottom: 1rem;
}
.meldung.fehler { background: var(--fehler-bg); color: var(--fehler-text); }
.meldung.hinweis { background: var(--akzent-schwach); color: var(--akzent); }
.klein { font-size: .8rem; color: var(--gedaempft); margin-top: 1.25rem; }
.mittig { text-align: center; }

/* -- Favoritenliste ----------------------------------------------------- */
.statusgruppe { margin-top: 2rem; }
.statusgruppe:first-of-type { margin-top: 1rem; }
.statusgruppe > h2 {
  font-size: .95rem; margin: 0 0 .7rem; display: flex; align-items: center;
  gap: .5rem;
}
.statusgruppe .anzahl { color: var(--gedaempft); font-weight: 400;
  font-size: .82rem; }

/* Die drei Formulare (Status, Notiz, Entfernen) sind unterschiedlich hoch.
 * Aussen oben ausrichten, damit alle Beschriftungen auf einer Linie stehen —
 * mit flex-end wuerde das kurze Statusfeld nach unten rutschen. Der Knopf
 * innerhalb eines Formulars sitzt weiter unten am Feldrand. */
.fav-werkzeuge {
  margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--rand);
  display: flex; gap: .75rem; align-items: flex-start; flex-wrap: wrap;
}
.fav-werkzeuge form {
  display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap;
}
.fav-werkzeuge .feld { margin: 0; }
/* Die Notiz nimmt den freien Platz — und zwar bis ins Feld hinein, sonst
 * waechst nur das Formular und das Textfeld bleibt schmal. */
.fav-werkzeuge .notiz { flex: 1; min-width: 240px; }
.fav-werkzeuge .notiz .feld { flex: 1; min-width: 160px; }
/* "Entfernen" hat kein Feld und wuerde sonst neben den Beschriftungen kleben.
 * Nach rechts abgesetzt — es ist die eine Aktion, die man nicht aus
 * Versehen treffen soll. */
.fav-werkzeuge form:last-child { margin-left: auto; }
/* Zwei Zeilen, auch mit dem groesseren Zeilenabstand der Thai-Ansicht. */
.fav-werkzeuge textarea { min-height: 3.6rem; resize: vertical; }
.gespeichert {
  font-size: .8rem; color: var(--akzent); opacity: 0; transition: opacity .2s;
}
.gespeichert.sichtbar { opacity: 1; }

.verlauf-liste { list-style: none; padding: 0; margin: .6rem 0 0; }
.verlauf-liste li {
  font-size: .82rem; color: var(--gedaempft); padding: .15rem 0;
}
.verlauf-liste .zeit { font-variant-numeric: tabular-nums; }
details.verlauf > summary {
  font-size: .82rem; color: var(--gedaempft); cursor: pointer;
  margin-top: .5rem;
}

.verlaufseite { list-style: none; padding: 0; }
.verlaufseite li {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 8px;
  padding: .6rem .85rem; margin-bottom: .4rem; font-size: .9rem;
}
.verlaufseite .zeit {
  color: var(--gedaempft); font-size: .8rem; font-variant-numeric: tabular-nums;
}
.verlaufseite .inserat { color: var(--gedaempft); font-size: .82rem; }

/* -- Fusszeile ---------------------------------------------------------- */
footer {
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rand);
  color: var(--gedaempft); font-size: .8rem;
}
footer p { margin: .35rem 0; }

/* Nur fuer Hilfstechnik sichtbar. */
.nur-vorlesen {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
