/* HM Protokoll App – Stylesheet */
/* Corporate Design: HM Immobilien GmbH & Co. KG */
/* Optimiert für Tablets und Mobile */

:root {
  /* HM Corporate Design Farben */
  --hm-gelb: #FDC40A;         /* Primär: Buttons, Akzente, Highlights */
  --hm-anthrazit: #282E30;    /* Sekundär: Text, Headlines, dunkle UI */
  --hm-grau: #E6EAEC;         /* Tertiär: Hintergründe, Trennflächen */

  /* UI-Farben */
  --hm-grau-text: #555;
  --hm-border: #d0d4d6;
  --hm-success: #2d8a4e;
  --hm-warning: #e67e22;
  --hm-danger: #c0392b;

  /* Layout */
  --radius-btn: 4px;          /* Buttons: max 4px laut CD */
  --radius-card: 6px;         /* Cards: leicht gerundet */
  --shadow: 0 2px 12px rgba(40,46,48,0.08);
  --shadow-lg: 0 4px 24px rgba(40,46,48,0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DIN Pro', 'Arial', 'Helvetica Neue', sans-serif;
  background: var(--hm-grau);
  color: var(--hm-anthrazit);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ─── LAYOUT ──────────────────────────────────────────────────────────────────── */

#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#top-bar {
  background: var(--hm-anthrazit);
  color: white;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border-bottom: 3px solid var(--hm-gelb);
}

#top-bar .logo {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: white;
  text-decoration: none;
}

#top-bar .logo span {
  color: var(--hm-gelb);
}

#page-title {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  opacity: 0.9;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

#main-content {
  flex: 1;
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ─── BOTTOM NAV ──────────────────────────────────────────────────────────────── */

#bottom-nav {
  background: white;
  border-top: 2px solid var(--hm-gelb);
  display: flex;
  position: sticky;
  bottom: 0;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(40,46,48,0.1);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 10px;
  cursor: pointer;
  color: var(--hm-grau-text);
  font-size: 11px;
  text-decoration: none;
  border: none;
  background: none;
  gap: 2px;
  transition: color 0.2s;
}

.nav-item .nav-icon { font-size: 22px; }
.nav-item.active { color: var(--hm-anthrazit); font-weight: 700; }
.nav-item.active .nav-icon { filter: drop-shadow(0 0 2px var(--hm-gelb)); }
.nav-item:hover { color: var(--hm-anthrazit); }

/* ─── CARDS ───────────────────────────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--hm-anthrazit);
  margin-bottom: 12px;
  border-bottom: 3px solid var(--hm-gelb);
  padding-bottom: 8px;
}

.card-warning { border-left: 4px solid var(--hm-warning); }
.card-danger { border-left: 4px solid var(--hm-danger); }

/* ─── HOME ────────────────────────────────────────────────────────────────────── */

.home-grid {
  display: grid;
  gap: 12px;
}

.hero-card {
  background: var(--hm-gelb);
  color: var(--hm-anthrazit);
  border-radius: var(--radius-card);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-lg);
}

.hero-card:hover, .hero-card:active {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(253,196,10,0.4);
}

.hero-icon { font-size: 48px; margin-bottom: 12px; }
.hero-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.hero-card p { opacity: 0.75; font-size: 14px; }

.quick-actions h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--hm-grau-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.btn-action {
  display: block;
  width: 100%;
  background: white;
  border: 1px solid var(--hm-border);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  color: var(--hm-anthrazit);
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}

.btn-action:hover {
  background: var(--hm-grau);
  border-color: var(--hm-gelb);
}

.stats-card h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--hm-grau-text);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--hm-grau);
  font-size: 13px;
}

.stat-row:last-child { border-bottom: none; }

/* ─── SCANNER ─────────────────────────────────────────────────────────────────── */

.scanner-container { display: flex; flex-direction: column; gap: 16px; }

.scanner-viewfinder {
  position: relative;
  background: #000;
  border-radius: var(--radius-card);
  overflow: hidden;
  aspect-ratio: 4/3;
  max-height: 60vh;
}

.scanner-viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-frame {
  width: 200px;
  height: 200px;
  border: 3px solid var(--hm-gelb);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { border-color: var(--hm-gelb); }
  50% { border-color: white; }
}

.scanner-status {
  position: absolute;
  bottom: 12px;
  left: 0; right: 0;
  text-align: center;
  color: white;
  font-size: 13px;
  background: rgba(0,0,0,0.55);
  padding: 6px;
}

.scanner-manual { background: white; border-radius: var(--radius-card); padding: 16px; }
.scanner-manual p { font-size: 13px; color: var(--hm-grau-text); margin-bottom: 10px; }

.manual-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.manual-input input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--hm-border);
  border-radius: var(--radius-btn);
  font-size: 16px;
}

.manual-input span { font-weight: bold; color: var(--hm-grau-text); }

/* ─── WOHNUNGSDETAIL ──────────────────────────────────────────────────────────── */

.wohnung-header {
  background: var(--hm-anthrazit);
  color: white;
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  border-bottom: 3px solid var(--hm-gelb);
}

.wohnung-header h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.wohnung-header p { opacity: 0.75; font-size: 13px; margin-bottom: 10px; }

.wohnung-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  color: white;
}

.badge-entwurf { background: var(--hm-grau); color: var(--hm-anthrazit); }
.badge-abgeschlossen { background: #d4edda; color: var(--hm-success); }
.badge-versendet { background: var(--hm-gelb); color: var(--hm-anthrazit); }
.badge-warning { background: #fff3cd; color: var(--hm-warning); }

.mieter-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.mieter-info a { color: var(--hm-gelb); text-decoration: none; }

/* ─── PROTOKOLL-TYPEN ─────────────────────────────────────────────────────────── */

.protokoll-typen { display: flex; flex-direction: column; gap: 8px; }

.protokoll-typ-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--hm-border);
  border-radius: var(--radius-card);
  cursor: pointer;
  background: white;
  transition: background 0.2s, border-color 0.2s;
}

.protokoll-typ-card:hover, .protokoll-typ-card:active {
  background: var(--hm-grau);
  border-color: var(--hm-gelb);
  border-left: 4px solid var(--hm-gelb);
}

.typ-icon { font-size: 28px; }

.protokoll-typ-card strong { display: block; font-size: 14px; color: var(--hm-anthrazit); font-weight: 700; }
.protokoll-typ-card small { font-size: 12px; color: var(--hm-grau-text); }

/* ─── PROTOKOLL LISTE EINTRÄGE ────────────────────────────────────────────────── */

.protokoll-eintrag {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--hm-grau);
  cursor: pointer;
}

.protokoll-eintrag:last-child { border-bottom: none; }
.protokoll-eintrag:hover { background: var(--hm-grau); margin: 0 -16px; padding: 12px 16px; }

.prot-info { display: flex; flex-direction: column; gap: 2px; }
.prot-info strong { font-size: 14px; }
.prot-info span { font-size: 12px; color: var(--hm-grau-text); }

.prot-right, .prot-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
}

/* ─── FORMULARE ───────────────────────────────────────────────────────────────── */

.form-header {
  background: white;
  border-radius: var(--radius-card);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--hm-gelb);
}

.form-meta { display: flex; gap: 8px; align-items: center; }

input[type="text"], input[type="date"], input[type="number"], input[type="email"],
select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--hm-border);
  border-radius: var(--radius-btn);
  font-size: 14px;
  width: 100%;
  background: white;
  color: var(--hm-anthrazit);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--hm-gelb);
  box-shadow: 0 0 0 3px rgba(253,196,10,0.2);
}

textarea { resize: vertical; }

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--hm-grau-text);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Bestandsaufnahme Tabelle */
.zustand-tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.zustand-tabelle th {
  background: var(--hm-anthrazit);
  color: white;
  padding: 6px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.zustand-tabelle tr:nth-child(even) td {
  background: var(--hm-grau);
}

.zustand-tabelle td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--hm-grau);
  vertical-align: middle;
}

.zustand-select { width: 100%; padding: 4px; font-size: 13px; }

/* Zähler, Mängel, Schlüssel Rows */
.zaehler-row, .mangel-row, .schluessel-row, .melder-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.zaehler-row input, .zaehler-row select,
.mangel-row input, .mangel-row select { flex: 1; min-width: 80px; }

.schluessel-row {
  flex-direction: column;
  border: 1px solid var(--hm-border);
  border-left: 4px solid var(--hm-gelb);
  border-radius: var(--radius-card);
  padding: 10px;
  background: white;
}
.schluessel-name { font-weight: 700; font-size: 14px; color: var(--hm-anthrazit); }
.schluessel-inputs { display: flex; gap: 12px; }
.schluessel-inputs label { font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.count-input { width: 60px !important; }
.serien-input { font-size: 13px; }

.melder-inputs { display: flex; gap: 6px; flex-wrap: wrap; }
.melder-inputs input, .melder-inputs select { flex: 1; min-width: 100px; }

.btn-add {
  background: none;
  border: 2px dashed var(--hm-gelb);
  border-radius: var(--radius-btn);
  padding: 10px;
  width: 100%;
  cursor: pointer;
  color: var(--hm-anthrazit);
  font-size: 14px;
  font-weight: 700;
  margin-top: 8px;
  transition: background 0.2s;
}

.btn-add:hover { background: rgba(253,196,10,0.12); }

/* ─── FOTOS ───────────────────────────────────────────────────────────────────── */

.foto-actions { display: flex; gap: 8px; margin-top: 12px; }

.btn-foto {
  flex: 1;
  display: block;
  background: var(--hm-anthrazit);
  color: white;
  border-radius: var(--radius-btn);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  border: none;
}

.btn-foto:hover { background: #3a4245; }

.foto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.foto-thumb {
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--hm-border);
  background: white;
}

.foto-thumb img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.foto-meta {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.foto-meta input {
  font-size: 11px;
  padding: 3px 6px;
}

.foto-meta button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  align-self: flex-end;
}

/* ─── FORM ACTIONS ────────────────────────────────────────────────────────────── */

.form-actions {
  display: flex;
  gap: 10px;
  padding: 16px 0;
  position: sticky;
  bottom: 60px;
  background: var(--hm-grau);
}

.btn-primary {
  flex: 1;
  background: var(--hm-gelb);
  color: var(--hm-anthrazit);
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  box-shadow: 0 4px 12px rgba(253,196,10,0.35);
  font-family: inherit;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-primary:hover { background: #e6b009; box-shadow: 0 4px 16px rgba(253,196,10,0.5); }

.btn-secondary {
  flex: 1;
  background: var(--hm-anthrazit);
  color: white;
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-secondary:hover { background: #3a4245; }

.btn-danger {
  background: var(--hm-danger);
  color: white;
  border: none;
  border-radius: var(--radius-btn);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  font-weight: 700;
}

/* ─── DIALOG ──────────────────────────────────────────────────────────────────── */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40,46,48,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.dialog {
  background: white;
  border-radius: var(--radius-card);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--hm-gelb);
}

.dialog h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.dialog p { color: var(--hm-grau-text); margin-bottom: 16px; }
.dialog-actions { display: flex; gap: 10px; }

/* ─── LOADING OVERLAY ─────────────────────────────────────────────────────────── */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40,46,48,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(253,196,10,0.3);
  border-top-color: var(--hm-gelb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text { color: white; font-size: 16px; font-weight: 700; }

/* ─── TOAST ───────────────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--hm-anthrazit);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--hm-gelb);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--hm-success); border-left-color: #d4edda; }
.toast-error { background: var(--hm-danger); border-left-color: #f5c6cb; }
.toast-warning { background: var(--hm-warning); border-left-color: #ffeaa7; }
.toast-info { background: var(--hm-anthrazit); border-left-color: var(--hm-gelb); }

/* ─── UTIL ────────────────────────────────────────────────────────────────────── */

.text-muted { color: var(--hm-grau-text); }
.text-center { text-align: center; }
.text-warning { color: var(--hm-warning); }

.status-online { color: var(--hm-success); }
.status-offline { color: var(--hm-danger); }

/* ─── LISTE ───────────────────────────────────────────────────────────────────── */

.liste-container { display: flex; flex-direction: column; gap: 12px; }
.liste-filter input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hm-border);
  border-radius: var(--radius-btn);
  font-size: 15px;
  box-shadow: var(--shadow);
}

/* ─── RESPONSIVE FÜR TABLETS ──────────────────────────────────────────────────── */

@media (min-width: 600px) {
  .home-grid { grid-template-columns: 1fr 1fr; }
  .hero-card { grid-column: span 2; }
  .hero-card.hero-half { grid-column: span 1; }
  .protokoll-typen { display: grid; grid-template-columns: 1fr 1fr; }
  .foto-grid { grid-template-columns: 1fr 1fr 1fr; }
  .form-actions { max-width: 600px; }
}

@media (min-width: 768px) {
  #main-content { padding: 20px 24px; }
  .zustand-tabelle td, .zustand-tabelle th { padding: 8px 10px; }
}

/* Raum-Karten */
.raum-card { margin-bottom: 8px; }
.raum-card h3 { font-size: 15px; color: var(--hm-anthrazit); font-weight: 700; }
