/* Zitzelsberger Kundenportal — Corporate Design #00a7b7
   Barrierefreier Textton #007a87 (Kontrast >= 4.5:1 auf weiss). */
:root {
  --primary: #00a7b7;        /* Flaechen, Gradient, Borders, Icons */
  --primary-deep: #007a87;   /* barrierefrei fuer Text/Links/Buttons (>=4.5:1) */
  --primary-dark: #008a99;   /* Hover/Active */
  --primary-text: #007a87;   /* Alias zu --primary-deep (Abwaertskompatibilitaet) */
  --primary-soft: #e0f7f9;
  --success: #059669;
  --warn: #d97706;
  --error: #dc2626;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f7f8;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--primary-dark); color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--primary-deep);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Heller Fokusring auf dem tuerkisen Header-Hintergrund */
.app-header :focus-visible {
  outline-color: #fff;
}

.hidden { display: none !important; }

/* Nur fuer Screenreader sichtbar */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Bewegung reduzieren, wenn vom System gewuenscht */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Header ───────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #00a7b7 0%, #008a99 100%);
  color: #fff;
}
.header-inner {
  max-width: 1000px; margin: 0 auto; padding: .8rem 1rem;
  display: flex; align-items: center; gap: .9rem;
}
.logo { height: 34px; width: auto; }
.header-title { font-weight: 600; font-size: 1.1rem; letter-spacing: .02em; }
.logout-btn {
  margin-left: auto; background: rgba(255,255,255,.18); color: #fff;
  border: 1px solid rgba(255,255,255,.5); border-radius: 8px;
  padding: .4rem .9rem; cursor: pointer; font-size: .9rem;
}
.logout-btn:hover { background: rgba(255,255,255,.3); }

/* ── Layout ───────────────────────────────────────────────────────────── */
main { flex: 1; max-width: 1000px; width: 100%; margin: 0 auto; padding: 1.5rem 1rem; }
.app-footer {
  text-align: center; color: var(--muted); font-size: .85rem;
  padding: 1rem; border-top: 1px solid var(--line);
}

/* ── Login ────────────────────────────────────────────────────────────── */
.login-view { display: flex; justify-content: center; padding-top: 2rem; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.6rem; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.login-card { max-width: 420px; width: 100%; }
.login-card h1 { margin: 0 0 .3rem; color: var(--primary-text); font-size: 1.5rem; }
.sub { color: var(--muted); margin: 0 0 1.2rem; }
.auth-form { display: flex; flex-direction: column; gap: .6rem; }
.auth-form label { font-weight: 600; font-size: .9rem; }
.auth-form input {
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem;
}
.auth-form input:focus { border-color: var(--primary-deep); }
.code-hint { margin: 0 0 .3rem; color: var(--muted); font-size: .9rem; }

.btn-primary {
  background: var(--primary-text); color: #fff; border: none; border-radius: 8px;
  padding: .75rem 1rem; font-size: 1rem; font-weight: 600; cursor: pointer;
  margin-top: .3rem;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: progress; }

.link-btn {
  background: none; border: none; color: var(--primary-text);
  text-decoration: underline; cursor: pointer; font-size: .9rem; padding: .2rem;
}
.form-error {
  color: var(--error); font-size: .9rem; margin: .3rem 0 0;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: .5rem .7rem;
}
.form-info {
  color: var(--success); font-size: .9rem; margin: .3rem 0 0;
}

/* ── Portal ───────────────────────────────────────────────────────────── */
.welcome { color: var(--muted); margin: 0 0 1.4rem; }
.portal-h1 { color: var(--primary-text); font-size: 1.6rem; margin: 0 0 .2rem; }
.detail-h1 { color: var(--ink); font-size: 1.4rem; margin: 0 0 1rem; }
.detail-h2 { color: var(--ink); font-size: 1.15rem; margin: 1.6rem 0 1rem; }

h2 { color: var(--ink); font-size: 1.2rem; margin: 0 0 1rem; }

/* ── Kachel-Startseite (Dashboard) ──────────────────────────────────────── */
.card-grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.feature-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .5rem;
  text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.3rem; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  font: inherit; color: var(--ink); width: 100%;
}
.feature-card:hover {
  border-color: var(--primary);
  background: linear-gradient(180deg, #fff 0%, var(--primary-soft) 220%);
  box-shadow: 0 4px 14px rgba(0,167,183,.16);
  transform: translateY(-2px);
}
.feature-card:focus-visible { transform: translateY(-2px); }
.fc-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
}
.fc-icon svg { width: 28px; height: 28px; }
.fc-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.fc-desc { font-size: .9rem; color: var(--muted); line-height: 1.45; }
.fc-status {
  margin-top: auto; font-size: .82rem; font-weight: 600;
  display: inline-block; padding: .25rem .6rem; border-radius: 999px;
}
.fc-status:empty { display: none; }
.fc-status-info { background: var(--primary-soft); color: var(--primary-text); }
.fc-status-ok   { background: #d1fae5; color: #065f46; }
.fc-status-warn { background: #fef3c7; color: #92400e; }

/* ── Detail-Ansicht + Zurück-Navigation ─────────────────────────────────── */
.detail-view:focus { outline: none; }
.back-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #fff; color: var(--primary-deep); border: 1px solid var(--primary-deep);
  border-radius: 8px; padding: .5rem .95rem; font-size: .92rem; font-weight: 600;
  cursor: pointer; margin-bottom: 1.2rem;
}
.back-btn:hover { background: var(--primary-soft); }

/* ── Eingebettetes Reklamations-Tool (iframe) ───────────────────────────── */
.iframe-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.tool-iframe {
  display: block; width: 100%; height: 78vh; min-height: 520px; border: 0;
}
.iframe-fallback { font-size: .85rem; color: var(--muted); margin: .6rem 0 0; }
.iframe-fallback a { color: var(--primary-deep); font-weight: 600; }

/* Dashboard-Kacheln */
.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.objekt-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; display: flex; flex-direction: column; gap: .5rem;
}
.objekt-card h3 { margin: 0; font-size: 1.05rem; }
.objekt-meta { color: var(--muted); font-size: .85rem; }
.ampel-row { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; }
.ampel {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(0,0,0,.1);
}
.ampel.gruen { background: var(--success); }
.ampel.gelb  { background: var(--warn); }
.ampel.rot   { background: var(--error); }
.ampel.none  { background: #d1d5db; }
.ampel-label { font-size: .9rem; }
.trend { display: flex; gap: 4px; margin-top: .2rem; }
.trend .dot { width: 10px; height: 10px; border-radius: 50%; }
.trend .dot.gruen { background: var(--success); }
.trend .dot.gelb  { background: var(--warn); }
.trend .dot.rot   { background: var(--error); }
.trend .dot.none  { background: #d1d5db; }

/* Listen (Reklamationen / Berichte) */
.list { display: flex; flex-direction: column; gap: .7rem; }
.list-item {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; display: flex; flex-direction: column; gap: .35rem;
}
.list-item .row-top {
  display: flex; justify-content: space-between; align-items: center; gap: .6rem;
  flex-wrap: wrap;
}
.list-item h3 { margin: 0; font-size: 1rem; }
.item-meta { color: var(--muted); font-size: .85rem; }
.item-desc { font-size: .92rem; }

.badge {
  display: inline-block; padding: .2rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--primary-soft);
  color: var(--primary-text);
}
.badge.gruen { background: #d1fae5; color: #065f46; }
.badge.gelb  { background: #fef3c7; color: #92400e; }
.badge.rot   { background: #fee2e2; color: #991b1b; }

.download-link {
  align-self: flex-start; margin-top: .3rem;
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--primary-text); color: #fff; text-decoration: none;
  padding: .5rem .9rem; border-radius: 8px; font-weight: 600; font-size: .9rem;
}
.download-link:hover { background: var(--primary-dark); }

/* Leerzustaende */
.empty {
  text-align: center; color: var(--muted); padding: 2rem 1rem;
  background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty .big { font-size: 1.5rem; margin-bottom: .3rem; }

.loading { color: var(--muted); padding: 1rem 0; }

/* ── Formulare (Reklamation, Anfrage, Chat) ───────────────────────────────── */
.form-card { margin-bottom: 1.2rem; }
.panel-intro { color: var(--muted); margin: 0 0 1rem; }
.data-form { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input,
.field select,
.field textarea {
  padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; font-family: inherit; color: var(--ink); background: #fff;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 3rem; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--primary-deep); }

.btn-secondary {
  background: #fff; color: var(--primary-deep); border: 1px solid var(--primary-deep);
  border-radius: 8px; padding: .5rem .9rem; font-size: .9rem; font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--primary-soft); }
.btn-secondary:disabled { opacity: .6; cursor: default; }

.form-feedback {
  font-size: .9rem; margin: .2rem 0 0;
  border-radius: 6px; padding: .55rem .7rem;
}
.form-feedback.is-error { color: var(--error); background: #fef2f2; border: 1px solid #fecaca; }
.form-feedback.is-success { color: #065f46; background: #d1fae5; border: 1px solid #6ee7b7; }

.antwort {
  background: var(--primary-soft); border-radius: 8px; padding: .6rem .8rem;
  font-size: .92rem; margin-top: .3rem;
}

/* ── Leistungsverzeichnis ──────────────────────────────────────────────────── */
.lv-content { display: flex; flex-direction: column; gap: 1rem; }
.lv-bereich {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.lv-bereich h3 { margin: 0 0 .6rem; font-size: 1.05rem; color: var(--primary-deep); }
.lv-pos {
  display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem;
  padding: .6rem 0; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.lv-pos:first-of-type { border-top: none; }
.lv-pos-main { flex: 1; min-width: 60%; }
.lv-pos-name { font-weight: 600; font-size: .95rem; }
.lv-inline-form {
  flex-basis: 100%; margin-top: .6rem; padding: .9rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}

/* ── Chat ──────────────────────────────────────────────────────────────────── */
.chat-threads { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.2rem; }
.chat-thread {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; cursor: pointer; text-align: left; width: 100%;
}
.chat-thread:hover { border-color: var(--primary); }
.chat-thread-main { display: flex; flex-direction: column; gap: .15rem; }
.chat-thread-objekt { font-weight: 600; }
.chat-badge {
  background: var(--error); color: #fff; border-radius: 999px;
  min-width: 1.4rem; height: 1.4rem; padding: 0 .4rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
}
.chat-view {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; display: flex; flex-direction: column; gap: .8rem;
}
.chat-title { margin: 0; font-size: 1.05rem; color: var(--primary-deep); }
.chat-verlauf {
  display: flex; flex-direction: column; gap: .6rem;
  max-height: 420px; overflow-y: auto; padding: .3rem;
}
.msg { display: flex; }
.msg-mine { justify-content: flex-end; }
.msg-other { justify-content: flex-start; }
.msg-bubble {
  max-width: 80%; border-radius: 12px; padding: .55rem .8rem;
  border: 1px solid var(--line);
}
.msg-mine .msg-bubble { background: var(--primary-soft); border-color: #b8eef2; }
.msg-other .msg-bubble { background: var(--bg); }
.msg-author { font-size: .78rem; font-weight: 700; color: var(--primary-deep); margin-bottom: .15rem; }
.msg-text { font-size: .95rem; white-space: pre-wrap; word-break: break-word; }
.msg-time { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.chat-form { display: flex; flex-direction: column; gap: .5rem; }
.chat-form textarea {
  padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; font-family: inherit; resize: vertical;
}
.chat-form textarea:focus { border-color: var(--primary-deep); }
.chat-form .btn-primary { align-self: flex-start; }
.chat-hint { font-size: .8rem; color: var(--muted); margin: 0; }

/* ── Verträge ──────────────────────────────────────────────────────────────── */
.vertrag-actions {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .4rem;
}
.vertrag-msg { margin: 0; }

@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .header-title { font-size: 1rem; }
  .logo { height: 28px; }
  .lv-pos { flex-direction: column; }
  .lv-pos .btn-secondary { align-self: flex-start; }
  .msg-bubble { max-width: 92%; }
  .portal-h1 { font-size: 1.35rem; }
  .tool-iframe { height: 70vh; }
}
