/* Wadokai PWA – Mobile-First Styles */
:root {
  --primary: #A85561;
  --primary-dark: #8a4450;
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #e5e5e5;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --nav-height: 60px;
  --header-height: 52px;
}

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

html {
  height: 100%;
  background-color: var(--primary);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100%;
  padding-bottom: 0;
  padding-top: 0;
  margin: 0;
  background-color: var(--bg);
  /* Deckung für iOS: Statusleiste bleibt rot */
  background-image: linear-gradient(var(--primary) 0, var(--primary) env(safe-area-inset-top, 0px), var(--bg) env(safe-area-inset-top, 0px));
  background-attachment: fixed;
}

/* Feste rote Fläche hinter der iOS-Statusleiste (Uhr, WLAN, Akku) */
.status-bar-fill {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background-color: var(--primary);
  background-image: none;
  z-index: 1000;
  pointer-events: none;
}

/* Header – gleiche kräftige Farbe, mit Safe-Area-Padding */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  box-sizing: border-box;
  min-height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: 0;
  background-color: var(--primary) !important;
  background-image: none !important;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  /* Kein Transparenz-Effekt auf iOS */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.app-header .logo {
  height: 32px;
  width: auto;
}

/* Content */
.app-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  min-height: calc(100vh - var(--header-height) - var(--nav-height));
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.card h2, .card h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: var(--primary);
}
.card .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.card p { line-height: 1.5; font-size: 0.95rem; }
.card img {
  max-width: 100%;
  border-radius: 8px;
  margin: 8px 0;
}

/* Bottom Navigation – identisch auf allen Seiten */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  /* Nur die Nav-Höhe; Safe-Area als Padding darunter */
  height: var(--nav-height);
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: content-box; /* height + padding-bottom = Gesamt */
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0;
  margin: 0;
  height: var(--nav-height); /* Icons immer in den oberen 60px */
  transition: color .15s;
}
.bottom-nav a.active,
.bottom-nav a:hover {
  color: var(--primary);
}
.bottom-nav .icon {
  font-size: 1.35rem;
  margin-bottom: 2px;
  line-height: 1;
}


/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--muted);
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(168,85,97,.15);
}
.form-group textarea { min-height: 100px; resize: vertical; }

/* Toggle Switch (Push) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.toggle-row .label {
  font-weight: 500;
  font-size: 0.95rem;
}
.toggle-row .status {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}
.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 30px;
  transition: .25s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider {
  background: var(--success);
}
.switch input:not(:checked) + .slider {
  background: #ef4444; /* rot wenn aus */
}
.switch input:checked + .slider:before {
  transform: translateX(22px);
}

/* Login status */
.login-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  padding: 10px 0;
}
.login-status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}
.login-status.logged-in .dot {
  background: var(--success);
}

/* Termine Liste */
.termin-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.termin-item:last-child { border-bottom: none; }
.termin-date {
  flex: 0 0 56px;
  align-self: flex-start;
  width: 56px;
  height: 52px;
  max-height: 52px;
  box-sizing: border-box;
  text-align: center;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 0.75rem;
  line-height: 1.15;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.termin-date .day {
  font-size: 1.2rem;
  font-weight: 700;
  display: block;
  line-height: 1.1;
}
.termin-info {
  flex: 1;
  min-width: 0;
}
.termin-info h3 { font-size: 0.95rem; margin-bottom: 2px; color: var(--text); }
.termin-info .time { font-size: 0.8rem; color: var(--muted); }

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.chat-msg {
  margin-bottom: 12px;
  max-width: 85%;
}
.chat-msg.own {
  margin-left: auto;
}
.chat-msg .bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
  line-height: 1.4;
}
.chat-msg.own .bubble {
  background: #fce8eb;
  border-color: #f0c4cb;
}
.chat-msg .author {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}
.chat-msg .time {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
}
.chat-msg img.attachment {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
}
.chat-composer {
  /* Platzhalter – positionierung unter body.page-chat */
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 0;
  background: transparent;
  border-top: none;
}
.chat-file-preview {
  padding: 4px 0 6px;
  font-size: 0.8rem;
}
.chat-input-bar textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.95rem;
  resize: none;
}
.chat-input-bar .btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
}
.file-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.2rem;
}
.file-btn input { display: none; }

/* Vereine / Aktive */
.list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .name { font-weight: 600; font-size: 1rem; }
.list-item .role { font-size: 0.85rem; color: var(--primary); }
.list-item .contact { font-size: 0.85rem; color: var(--muted); }
.list-item a.mail {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.85rem;
}

/* Empty / Loading */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }

/* ---------- Android Install-Banner ---------- */
.pwa-install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px);
  z-index: 250;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  padding: 12px 14px;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  pointer-events: none;
}
.pwa-install-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.pwa-install-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pwa-install-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pwa-install-text strong {
  font-size: 0.95rem;
  color: var(--text);
}
.pwa-install-text span {
  font-size: 0.8rem;
  color: var(--muted);
}
.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.pwa-install-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.pwa-install-dismiss {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pwa-install-dismiss:hover {
  background: var(--bg);
  color: var(--text);
}

/* Im Standalone-Modus Banner nie anzeigen (CSS-Absicherung) */
@media (display-mode: standalone) {
  .pwa-install-banner {
    display: none !important;
  }
}



/* Chat: Eingabeleiste fest über der Fußnavigation */
body.page-chat .app-content {
  display: flex;
  flex-direction: column;
  /* Volle Höhe zwischen Header und Bottom-Nav */
  height: calc(100dvh - var(--header-height) - env(safe-area-inset-top, 0px));
  max-height: calc(100dvh - var(--header-height) - env(safe-area-inset-top, 0px));
  padding-bottom: 0 !important;
  overflow: hidden;
  box-sizing: border-box;
}
body.page-chat .chat-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Platz für Composer + Bottom-Nav */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}
body.page-chat .chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
body.page-chat .chat-more-wrap {
  flex-shrink: 0;
  padding-bottom: 8px;
}
body.page-chat .chat-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px) * 0);
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
  box-sizing: border-box;
}
/* Zusätzlicher Abstand unter den Nachrichten = Höhe der Composer-Leiste */
body.page-chat.chat-has-composer .chat-messages {
  padding-bottom: 72px;
}
body.page-chat .chat-container {
  /* Composer ~56px + optional preview */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 64px);
}


/* Footer-Fix global – verhindert abweichende Abstände auf einzelnen Seiten */
.bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: var(--nav-height) !important;
  padding: 0 !important;
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  box-sizing: content-box !important;
  margin: 0 !important;
}
.bottom-nav a {
  height: var(--nav-height) !important;
  box-sizing: border-box !important;
}


.chat-img-link {
  display: inline-block;
  margin-top: 6px;
}
.chat-img-link img.attachment {
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
  border-radius: 8px;
  display: block;
}


/* Suchleiste (Vereine, Termine) */
.pwa-search-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.pwa-search-bar input[type="search"],
.pwa-search-bar input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}
.pwa-search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(168, 85, 97, 0.15);
}
.pwa-search-bar .btn-search {
  flex: 0 0 auto;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-search-bar .btn-search:hover,
.pwa-search-bar .btn-search:active {
  background: var(--primary-dark);
}
