/* ════════════════════════════════════════════════════════════════════════════
   SPOTME MESSENGER · Stylesheet
   Version: 1.0
   Location: /chat/messenger.css
   
   Abhängigkeiten:
   - Aus spotme.css importierte Variablen werden erwartet (oder hier dupliziert)
   - Fonts: Outfit (Google Fonts)
   
   Layout-Sektionen:
   1. Reset & Base
   2. Login Screen
   3. Chat List
   4. Chat Detail
   5. P2P Indicator & Banner
   6. Messages Container
   7. Input Bar
   8. Connection Status Footer
   9. Helpers
   ════════════════════════════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────────────────────────
   1. RESET & BASE
   ──────────────────────────────────────────────────────────────────────────── */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100vh;
  height: 100dvh; /* Dynamic Viewport Height (modern Browser) */
  min-height: 100dvh;
}

/* ────────────────────────────────────────────────────────────────────────────
   2. LOGIN SCREEN
   ──────────────────────────────────────────────────────────────────────────── */

#loginScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 2rem;
}

#loginScreen .logo {
  font-size: 3rem;
  margin-bottom: 1rem;
}

#loginScreen h1 {
  margin-bottom: 0.5rem;
  color: #ff4f7b;
}

#loginScreen .subtitle {
  color: var(--muted2, #7a98aa);
  margin-bottom: 2rem;
}

#loginScreen input {
  width: 100%;
  max-width: 280px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  border: 1px solid #333;
  border-radius: 10px;
  background: #1a1f26;
  color: #fff;
  font-size: 1rem;
  text-align: center;
}

#loginScreen button {
  width: 100%;
  max-width: 280px;
  padding: 0.85rem;
  margin-top: 1rem;
  background: #ff4f7b;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}

.link-btn {
  width: auto !important;
  max-width: none !important;
  background: none !important;
  color: #ff9f00 !important;
  font-weight: 400 !important;
  font-size: 0.85rem;
  padding: 0.4rem !important;
  margin-top: 0.5rem !important;
  text-decoration: underline;
}

/* ── CREDENTIALS LAYER (nach Registrierung) ───────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 999;
}

.overlay-card {
  background: #14181f;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.overlay-card h2 {
  color: #ff9f00;
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

.overlay-card p {
  color: #ccc;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.overlay-card label {
  display: block;
  color: #7a8290;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.copy-row input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1f26;
  color: #fff;
  font-size: 0.9rem;
  font-family: monospace;
}

.copy-row button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: #ff9f00;
  color: #1a0f08;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.copy-feedback {
  color: #4ade80;
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}

.overlay-card .primary-btn {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #ff4f7b, #ff9f00);
  border: none;
  border-radius: 10px;
  font-weight: 600;
  color: #1a0f08;
  cursor: pointer;
  margin-top: 0.5rem;
}

/* ────────────────────────────────────────────────────────────────────────────
   3. CHAT LIST
   ──────────────────────────────────────────────────────────────────────────── */

#chatListScreen {
  display: none;
  height: 100vh;
}

.chat-list-header {
  padding: 1rem;
  background: #0f1218;
  border-bottom: 1px solid var(--bord, rgba(255, 255, 255, 0.06));
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-list-header h2 {
  flex: 1;
  margin: 0;
}

.new-chat-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ff4f7b, #ff9f00);
  color: #1a0f08;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-list {
  overflow-y: auto;
  height: calc(100vh - 60px);
}

.chat-item {
  padding: 1rem;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  position: relative;
}

.chat-item:hover {
  background: #15181e;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4f7b, #ff9f00);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.chat-preview {
  font-size: 0.85rem;
  color: var(--muted2, #7a98aa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  text-align: right;
  min-width: 70px;
  flex-shrink: 0;
}

.chat-time {
  font-size: 0.75rem;
  color: var(--muted, #4a6070);
}

.unread-badge {
  background: #ff4f7b;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 5px;
  display: inline-block;
}

/* ────────────────────────────────────────────────────────────────────────────
   4. CHAT DETAIL
   ──────────────────────────────────────────────────────────────────────────── */

#chatDetailScreen {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
}

.chat-header {
  flex-shrink: 0;
  padding: 1rem;
  background: #0f1218;
  border-bottom: 1px solid var(--bord, rgba(255, 255, 255, 0.06));
}

.back-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.header-info {
  flex: 1;
}

.header-name {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.header-status {
  font-size: 0.8rem;
}

/* ────────────────────────────────────────────────────────────────────────────
   5. P2P INDICATOR & BANNER
   ──────────────────────────────────────────────────────────────────────────── */

.p2p-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.p2p-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.p2p-active .p2p-dot {
  background: #4ade80;
}

.p2p-active {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.p2p-inactive .p2p-dot {
  background: #6b7280;
  animation: none;
}

.p2p-inactive {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.3);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.9);
  }
}

.p2p-banner {
  flex-shrink: 0;
  display: block;
  padding: 0.6rem 1rem;
  font-size: 0.78rem;
  text-align: center;
  background: #0a0d12;
  color: #4ade80;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.p2p-banner.p2p {
  border-bottom: 1px solid rgba(74, 222, 128, 0.25);
  color: #4ade80;
}

.p2p-banner.server {
  border-bottom: 1px solid rgba(74, 222, 128, 0.25);
  color: #4ade80;
}

/* ────────────────────────────────────────────────────────────────────────────
   6. MESSAGES CONTAINER
   ──────────────────────────────────────────────────────────────────────────── */

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #0a0d12;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.message {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  white-space: pre-wrap; /* FIX: sonst werden \n in mehrzeiligen Nachrichten ignoriert */
  position: relative;
  color: #e8eaf0; /* FIX: fehlte komplett → Text war unsichtbar auf .other */
  line-height: 1.4;
}

.message.mine {
  align-self: flex-end;
  margin-left: auto;
  background: linear-gradient(135deg, #ff4f7b, #ff9f00);
  color: #1a0f08; /* dunkler Warmton statt reinem Schwarz – ruhiger auf dem Gradient */
  box-shadow: 0 2px 10px rgba(255, 79, 123, 0.25);
}

.message.other {
  align-self: flex-start;
  background: #1a1f26;
  border-left: 3px solid #ff9f00; /* Akzent statt reiner Farbfläche – markiert Absender-Bubbles */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.msg-author {
  font-size: 0.7rem;
  color: #ff9f00; /* FIX: #aaa war auf dunklem BG kaum lesbar, jetzt Akzentfarbe wie im Rest der App */
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.message.mine .msg-author {
  display: none;
}

.msg-time {
  font-size: 0.65rem;
  color: #888;
  margin-top: 0.2rem;
  text-align: right;
}

.message.mine .msg-time {
  color: rgba(26, 15, 8, 0.6); /* passend zum dunklen Text auf dem hellen Gradient */
}

.msg-status {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  letter-spacing: -1px; /* Haken enger zusammenrücken */
}

.msg-status.sent {
  color: rgba(26, 15, 8, 0.45); /* dezent – nur "gesendet" */
}

.msg-status.delivered {
  color: #1a0f08; /* voller Kontrast – "zugestellt" bestätigt */
}

.message.other .msg-time {
  color: #7a8290; /* FIX: #888 auf #1a1f26 war grenzwertig, jetzt mehr Kontrast */
}

/* ────────────────────────────────────────────────────────────────────────────
   7. INPUT BAR
   ──────────────────────────────────────────────────────────────────────────── */

.input-bar {
  flex-shrink: 0; /* Niemals skalieren */
  padding: 0.75rem 1rem;
  background: #0f1218;
  border-top: 1px solid var(--bord, rgba(255, 255, 255, 0.06));
  display: flex;
  align-items: flex-end; /* Button bleibt unten, wenn Textarea wächst */
  gap: 0.5rem;
  position: sticky; /* Bleibt am unteren Rand kleben */
  bottom: 0;
  z-index: 100;
}

.input-bar textarea {
  flex: 1;
  padding: 0.65rem 0.9rem;
  border-radius: 20px;
  border: 1px solid #333;
  background: #1a1f26;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  max-height: 7.5rem; /* ~5 Zeilen, danach scrollt es intern */
  overflow-y: auto;
  line-height: 1.35;
}

.input-bar textarea:focus {
  outline: none;
  border-color: #ff4f7b;
}

.input-bar button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ff4f7b;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

/* ────────────────────────────────────────────────────────────────────────────
   8. STATUS (jetzt in der Topbar vereint – siehe .p2p-banner oben)
   ──────────────────────────────────────────────────────────────────────────── */

/* ────────────────────────────────────────────────────────────────────────────
   9. HELPERS
   ──────────────────────────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.error {
  color: #ff4f7b;
  margin-top: 1rem;
}

.success {
  color: #4ade80;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* ────────────────────────────────────────────────────────────────────────────
   10. RESPONSIVE OPTIMIZIERUNGEN
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #loginScreen {
    padding: 1rem;
  }

  .message {
    max-width: 85%;
  }

  .input-bar input {
    font-size: 0.95rem;
  }
}

@media (max-height: 600px) {
  #loginScreen {
    padding: 1rem;
  }

  .chat-header {
    padding: 0.75rem;
  }

  .input-bar {
    padding: 0.5rem 1rem;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   11. CACHING-LOOK (wie chat.html in SpotMe Caching)
   Gleiche Farben (theme-vars.css), gleiche Blasen, gleiche Leiste.
   ──────────────────────────────────────────────────────────────────────────── */

body { background: var(--bg, #080b10); color: var(--text, #dce8f0); font-family: 'Outfit', sans-serif; }

.p2p-banner {
  padding: max(0.35rem, env(safe-area-inset-top)) 1rem 0.35rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.64rem;
  background: var(--card, #111820);
  color: var(--muted2, #7a98aa) !important;
  border-bottom: none !important;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1rem;
  background: var(--glass-strong, rgba(8, 11, 16, 0.92));
  border-bottom: 1px solid var(--bord2, rgba(255, 255, 255, 0.11));
}
.chat-header .back-btn {
  order: 3;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--card, #111820);
  border: 1px solid var(--bord2, rgba(255, 255, 255, 0.11));
  color: var(--text, #dce8f0);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-header .hd-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: var(--cyan, #00e5ff);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.header-info { min-width: 0; }
.header-name {
  font-weight: 600; font-size: 1rem; margin-bottom: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-code {
  font-family: 'Space Mono', monospace;
  font-size: 0.66rem;
  color: var(--muted, #4a6070);
}
.header-status { font-size: 0.7rem; margin-top: 0.15rem; }
.header-status .p2p-indicator { padding: 1px 8px; font-size: 0.66rem; }

.messages-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg, #080b10);
  scroll-behavior: auto;
}

.message {
  max-width: 78%;
  padding: 0.55rem 0.8rem;
  margin: 0;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: none;
}
.message.mine {
  align-self: flex-end;
  margin-left: 0;
  background: var(--acc, #ff9f00);
  color: #080b10;
  border-bottom-right-radius: 4px;
  box-shadow: none;
}
.message.other {
  align-self: flex-start;
  background: var(--card, #111820);
  border: 1px solid var(--bord2, rgba(255, 255, 255, 0.11));
  border-left: 1px solid var(--bord2, rgba(255, 255, 255, 0.11));
  color: var(--text, #dce8f0);
  border-bottom-left-radius: 4px;
  box-shadow: none;
}
.msg-author { display: none !important; }
.msg-time,
.message.mine .msg-time,
.message.other .msg-time {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  color: inherit;
  opacity: 0.65;
  margin-top: 3px;
  text-align: left;
}
.msg-status, .msg-status.sent, .msg-status.delivered { color: inherit; margin-left: 0.3rem; }

.input-bar {
  gap: 0.5rem;
  padding: 0.6rem 0.8rem max(0.6rem, env(safe-area-inset-bottom));
  background: var(--glass-strong, rgba(8, 11, 16, 0.92));
  border-top: 1px solid var(--bord2, rgba(255, 255, 255, 0.11));
  align-items: center;
}
.input-bar textarea {
  min-width: 0;
  background: var(--card, #111820);
  border: 1px solid var(--bord2, rgba(255, 255, 255, 0.11));
  color: var(--text, #dce8f0);
  border-radius: 22px;
  padding: 0.7rem 1rem;
  font-size: 16px;
}
.input-bar textarea:focus { border-color: var(--acc, #ff9f00); }
.input-bar button {
  width: 46px; height: 46px;
  flex-shrink: 0;
  background: var(--acc, #ff9f00);
  color: #080b10;
  font-size: 1.1rem; font-weight: 700;
}

/* Tastatur: Chat-Fenster liegt fest am oberen Rand, Höhe setzt das Script (visualViewport) */
#chatDetailScreen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; height: auto; min-height: 0; overflow: hidden; }
.input-bar { position: relative; }

/* Chatliste: Löschen-Knopf + ungelesen */
.chat-item { position: relative; align-items: center; }
.chat-del {
  flex-shrink: 0;
  margin-left: 0.4rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--bord2, rgba(255,255,255,0.11));
  background: var(--card, #111820);
  color: var(--muted2, #7a98aa);
  font-size: 0.9rem;
  cursor: pointer;
}
.chat-meta { text-align: right; }
.unread-badge { background: var(--acc, #ff9f00); color: #080b10; font-weight: 700; }

/* Bilder (nur P2P) */
.img-hint { font-size: 0.72rem; padding: 0.35rem 1rem; text-align: center; border-top: 1px solid var(--bord2, rgba(255,255,255,0.11)); }
.img-hint.off { color: var(--muted2, #7a98aa); background: var(--card, #111820); }
.img-hint.on  { color: #22c55e; background: rgba(34, 197, 94, 0.1); font-weight: 600; }
.img-hint.warn { color: #080b10; background: var(--acc, #ff9f00); font-weight: 600; }
.input-bar .img-btn {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%;
  background: var(--card, #111820); border: 1px solid var(--bord2, rgba(255,255,255,0.11));
  color: var(--text, #dce8f0); font-size: 1.05rem; opacity: 0.45;
}
.input-bar .img-btn.on { opacity: 1; border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
.message.has-img { padding: 0.35rem; }
.chat-img { display: block; max-width: 100%; max-height: 300px; min-width: 120px; min-height: 80px; border-radius: 10px; background: rgba(0,0,0,0.25); }
.chat-img.blur { filter: blur(22px); }
.img-tap { font-size: 0.7rem; text-align: center; opacity: 0.7; margin-top: 3px; }
.chat-img:not(.blur) + .img-tap { display: none; }
.has-img .msg-time { padding: 0 0.4rem; }
.img-gone { font-size: 0.8rem; opacity: 0.7; padding: 0.5rem; display: inline-block; }
.img-preview { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 10px; margin: 0.6rem 0; }
.img-view { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Kontakt-Zustand: Hinweisleiste, Tags */
#chatNote.hidden { display: none; }
.chat-note { font-size: 0.78rem; line-height: 1.35; padding: 0.55rem 1rem; text-align: center; border-top: 1px solid var(--bord2, rgba(255,255,255,0.11)); color: var(--text, #e8eef2); background: var(--card, #111820); }
.chat-note.paused { background: rgba(122, 152, 170, 0.14); }
.chat-note.request { background: rgba(255, 159, 0, 0.14); }
.chat-note.wait { color: var(--muted2, #7a98aa); }
.note-btn { margin-left: 0.5rem; padding: 0.2rem 0.7rem; border-radius: 999px; border: 1px solid var(--acc, #ff9f00); background: transparent; color: var(--acc, #ff9f00); font: inherit; font-weight: 600; cursor: pointer; }
.chat-tag { display: inline-block; font-size: 0.68rem; padding: 0.05rem 0.45rem; border-radius: 999px; background: rgba(122,152,170,0.18); color: var(--muted2, #7a98aa); }
.chat-tag.req { background: rgba(255,159,0,0.18); color: var(--acc, #ff9f00); }
.input-bar textarea:disabled, .input-bar button:disabled { opacity: 0.45; }

.closed-box { margin: 0.8rem 1rem 1.2rem; font-size: 0.85rem; color: var(--muted2, #7a98aa); }
.closed-box summary { cursor: pointer; padding: 0.5rem 0; }
.closed-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0; border-top: 1px solid var(--bord2, rgba(255,255,255,0.11)); }
.closed-info { flex: 1; min-width: 0; }
.closed-hint { font-size: 0.72rem; margin: 0.4rem 0 0; }

/* Sicherungs-Leiste */
.backup-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.8rem; margin: 0.6rem 1rem; padding: 0.65rem 0.9rem; border-radius: 14px; background: rgba(255, 159, 0, 0.12); border: 1px solid rgba(255, 159, 0, 0.35); font-size: 0.8rem; line-height: 1.35; }
.backup-bar.hidden { display: none; }
.backup-bar .bk-btns { display: flex; gap: 0.4rem; margin-left: auto; }
.backup-bar .note-btn { margin-left: 0; }
.note-btn.ghost { border-color: var(--bord2, rgba(255,255,255,0.2)); color: var(--muted2, #7a98aa); }

.restore-sep{margin:1rem 0 .6rem;color:#7f93a3;font-size:.8rem;text-align:center}
