/* SoftPrim VoiceLink — aceeași paletă caldă SoftPrim ca TempMail (hue ~75),
   adaptată pentru o interfață de apel: panou de call + chat lateral. */

:root {
  --bg: oklch(0.965 0.006 80);
  --bg-raised: oklch(0.99 0.003 85);
  --bg-sunken: oklch(0.93 0.008 80);
  --ink: oklch(0.24 0.015 75);
  --ink-muted: oklch(0.45 0.015 75);
  --accent: oklch(0.52 0.115 65);
  --accent-hover: oklch(0.45 0.12 65);
  --accent-pale: oklch(0.93 0.03 75);
  --hairline: oklch(0.87 0.01 80);
  --danger: oklch(0.5 0.18 25);
  --ok: oklch(0.55 0.13 145);
  --wa: oklch(0.6 0.14 150);
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; touch-action: manipulation; } /* fără zoom la dublu-tap; pinch rămâne */
html { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1 { font-size: 1.8rem; line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
.accent { color: var(--accent); }
.hint { color: var(--ink-muted); font-size: 0.875rem; }
.center { text-align: center; }
.hidden { display: none !important; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--hairline); background: var(--bg-raised);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; color: var(--ink); }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.brand-name { font-family: var(--mono); font-size: 0.95rem; }
.site-header nav a { color: var(--ink-muted); text-decoration: none; font-size: 0.92rem; }

.container { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 40px 24px 72px; }
.site-footer {
  border-top: 1px solid var(--hairline); background: var(--bg-raised);
  padding: 18px 24px; color: var(--ink-muted); font-size: 0.82rem;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.site-footer a { color: var(--ink-muted); }

/* Butoane */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 9px 18px; border-radius: 10px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-big { font-size: 1.1rem; padding: 14px 28px; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: oklch(0.42 0.17 25); }
.btn-wa { background: var(--wa); border-color: var(--wa); }
.btn-wa:hover { background: oklch(0.5 0.13 150); }
.btn.active { background: var(--accent-pale); color: var(--accent); border-color: var(--accent); }

/* Home */
.hero { text-align: center; padding: 24px 0 40px; }
.lead { max-width: 640px; margin: 0 auto 24px; color: var(--ink-muted); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 20px; }
.card p { color: var(--ink-muted); font-size: 0.92rem; margin-bottom: 0; }

/* Room */
.room-body { height: 100vh; height: 100dvh; overflow: hidden; }
.room-main {
  flex: 1; display: grid; grid-template-columns: 1fr 340px; gap: 0; min-height: 0;
}
.call-panel { display: flex; flex-direction: column; padding: 18px 22px; min-height: 0; overflow-y: auto; position: relative; }
.chat-panel {
  display: flex; flex-direction: column; border-left: 1px solid var(--hairline);
  background: var(--bg-raised); min-height: 0;
}
.chat-title { margin: 14px 16px 6px; font-size: 0.95rem; color: var(--ink-muted); }
.chat-log { flex: 1; overflow-y: auto; padding: 6px 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { background: var(--bg-sunken); border-radius: 10px; padding: 7px 11px; font-size: 0.92rem; max-width: 95%; overflow-wrap: anywhere; }
.chat-msg.mine { background: var(--accent-pale); align-self: flex-end; }
.chat-msg.system { background: transparent; color: var(--ink-muted); font-size: 0.8rem; align-self: center; text-align: center; }
.chat-msg .who { font-weight: 650; font-size: 0.8rem; color: var(--accent); display: block; }
.chat-msg img { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 4px; cursor: pointer; }
.chat-msg .when { font-size: 0.7rem; color: var(--ink-muted); margin-left: 6px; font-weight: 400; }
.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--hairline); }
.chat-form input { flex: 1; min-width: 0; }

input {
  font: inherit; padding: 9px 12px; border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--bg); color: var(--ink); outline: none;
}
input:focus { border-color: var(--accent); }

/* Participanți */
.participants { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: 999px;
  padding: 6px 14px; font-size: 0.9rem;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); opacity: .4; }
.pill.incall .dot { background: var(--ok); opacity: 1; }
.pill .cam { font-size: 0.8rem; }

/* Video — grila se adaptează la numărul de camere; una singură poate fi mare. */
.videos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; margin-bottom: 14px; }
.videos:empty { display: none; }
.videos video { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: #000; }
.videos:has(> .video-tile:only-child) video { aspect-ratio: 16/10; max-height: 46dvh; }
.video-tile { position: relative; }
.video-tile.mirror video { transform: scaleX(-1); } /* camera frontală în oglindă, ca la selfie */
.video-tile .tag {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 0.75rem; padding: 2px 8px; border-radius: 6px;
}

.call-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 16px; justify-content: center; }
.call-controls .btn { min-width: 52px; }
.btn svg { width: 20px; height: 20px; vertical-align: -4px; }
.btn-ic { display: inline-flex; align-items: center; justify-content: center; }
.btn-big svg { width: 22px; height: 22px; margin-right: 6px; }
.pill .cam svg { vertical-align: -2px; color: var(--accent); }
.card h2 svg { width: 20px; height: 20px; vertical-align: -3px; margin-right: 8px; color: var(--accent); }
.chat-toggle { display: none; position: relative; }
.badge {
  position: absolute; top: -7px; right: -7px; background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 0.68rem; min-width: 18px; height: 18px;
  line-height: 18px; text-align: center; padding: 0 4px; font-weight: 700;
}
.chat-close { display: none; }

/* Toast cu mesajul primit (când chatul e închis); click deschide chatul */
.msg-toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 86px; z-index: 45;
  max-width: min(92vw, 420px); background: var(--bg-raised); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 10px 16px; font-size: 0.9rem; cursor: pointer;
  box-shadow: 0 6px 24px oklch(0.3 0.01 75 / .25);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  animation: conn-in 0.2s ease;
}

/* Viewer poză pe tot ecranul */
.img-viewer {
  position: fixed; inset: 0; z-index: 70; background: oklch(0.15 0.01 75 / .9);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.img-viewer img { max-width: 96vw; max-height: 92dvh; border-radius: 8px; }

/* Banner stare conexiune server (reconectare / revenire) */
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  text-align: center; font-weight: 650; font-size: 0.95rem;
  padding: 12px 16px; color: #fff;
  animation: conn-in 0.2s ease;
}
.conn-banner.warn { background: oklch(0.55 0.14 60); }
.conn-banner.ok { background: var(--ok); }
.conn-banner.update { background: var(--accent); cursor: pointer; }
@keyframes conn-in { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* Indicator rețea */
.net-badge {
  position: absolute; top: 14px; right: 18px; font-size: 0.8rem; letter-spacing: 2px;
  color: var(--ink-muted); user-select: none;
}
.net-badge.good { color: var(--ok); }
.net-badge.weak { color: oklch(0.6 0.13 80); }
.net-badge.bad { color: var(--danger); }

/* Overlay */
.overlay {
  position: fixed; inset: 0; background: oklch(0.3 0.01 75 / .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-card {
  background: var(--bg-raised); border-radius: 16px; padding: 26px 28px; max-width: 360px; width: 100%;
  border: 1px solid var(--hairline);
}
.overlay-card form { display: flex; gap: 8px; margin-top: 12px; }
.overlay-card input { flex: 1; min-width: 0; }

.share { display: flex; gap: 8px; }

@media (max-width: 760px) {
  .room-main { display: flex; flex-direction: column; }

  /* Zona de apel ocupă tot ecranul; jos lăsăm loc pentru bara fixă de butoane. */
  .call-panel { flex: 1; padding: 12px 14px 96px; }

  /* Butoanele stau FIX jos — vizibile mereu, oricâte video-uri sunt deschise. */
  .call-controls {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    background: var(--bg-raised); border-top: 1px solid var(--hairline);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .call-controls .btn { flex: 0 1 auto; padding: 12px 16px; font-size: 1.05rem; }
  .btn-big { flex: 1 1 100% !important; }
  .chat-toggle { display: inline-block; }

  /* Chatul devine sertar care alunecă de jos, peste apel. */
  .chat-panel {
    position: fixed; left: 0; right: 0; bottom: 0; height: 72dvh; z-index: 40;
    border-left: none; border-top: 1px solid var(--hairline);
    border-radius: 16px 16px 0 0; box-shadow: 0 -10px 34px oklch(0.3 0.01 75 / .25);
    transform: translateY(105%); transition: transform 0.25s ease;
  }
  body.chat-open .chat-panel { transform: translateY(0); }
  .chat-close {
    display: block; position: absolute; top: 8px; right: 10px; z-index: 2;
    background: none; border: none; font-size: 1.15rem; color: var(--ink-muted);
    padding: 6px 10px; cursor: pointer;
  }
  .chat-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .chat-form input { font-size: 16px; } /* sub 16px iOS face zoom la focus */

  /* Video compact: niciodată mai înalt decât ~o treime de ecran. */
  .videos { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .videos video { max-height: 32dvh; }

  .share .btn { padding: 7px 10px; font-size: 0.78rem; }
  .site-header { padding: 10px 12px; }
  .net-badge { top: 10px; right: 12px; }
}
