/* ============================================================
   style.css — PeerChat UI
   Dark, minimal, responsive. No frameworks.
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg:              #0d0d0d;
  --surface:         #161616;
  --surface-raised:  #1e1e1e;
  --border:          #2a2a2a;
  --border-focus:    #3b82f6;

  --text-1:          #f0f0f0;
  --text-2:          #8a8a8a;

  --accent:          #3b82f6;   /* blue */
  --accent-dark:     #2563eb;
  --success:         #22c55e;   /* green  — connected */
  --warning:         #f59e0b;   /* amber  — connecting */
  --danger:          #ef4444;   /* red    — error / muted / leave */

  --radius:          14px;
  --radius-sm:       8px;
  --radius-pill:     100px;

  --shadow:          0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-sm:       0 2px 8px  rgba(0, 0, 0, 0.3);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Base elements ─────────────────────────────────────────── */
button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease,
              box-shadow 0.15s ease;
}

button:active  { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="text"] {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus        { border-color: var(--border-focus); }
input[type="text"]::placeholder { color: var(--text-2); }

/* ── ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LANDING PAGE  (index.html)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ── */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.logo h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.tagline {
  color: var(--text-2);
  font-size: 13.5px;
  margin-bottom: 28px;
}

/* Primary CTA */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-dark); }

/* Secondary */
.btn-secondary {
  display: block;
  width: 100%;
  background: var(--surface-raised);
  color: var(--text-1);
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
}

.btn-secondary:hover { background: #252525; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 18px;
  color: var(--text-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Join form */
.join-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-error {
  font-size: 12.5px;
  color: var(--danger);
  min-height: 16px;
}

/* ── ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ROOM PAGE  (room.html)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ── */

.room-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;          /* dvh respects mobile browser chrome */
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.room-header {
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.room-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.room-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Connection status badge */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.status-dot.connected { background: var(--success); }
.status-dot.error     { background: var(--danger);  }

/* Room ID bar */
.room-id-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
}

.room-id-label {
  color: var(--text-2);
  flex-shrink: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.room-id-value {
  flex: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.copy-btn:hover { background: var(--surface); }

/* Peers section */
.peers-section {
  flex: 1;
  overflow-y: auto;
  padding: 18px 0 8px;
  overscroll-behavior: contain;
}

/* Custom scrollbar */
.peers-section::-webkit-scrollbar       { width: 4px; }
.peers-section::-webkit-scrollbar-track { background: transparent; }
.peers-section::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

/* Peer list */
.peers-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Peer item card */
.peer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Speaking state — blue glow border */
.peer-item.speaking {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Avatar circle */
.peer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  transition: border-color 0.2s ease;
  user-select: none;
}

.peer-item.speaking .peer-avatar {
  border-color: var(--accent);
}

/* Peer info */
.peer-info {
  flex: 1;
  min-width: 0;
}

.peer-name {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.peer-status {
  display: block;
  font-size: 12px;
  color: var(--text-2);
}

.peer-status.connected    { color: var(--success); }
.peer-status.connecting   { color: var(--warning); }
.peer-status.disconnected { color: var(--danger);  }

/* Error display */
.error-display {
  display: none;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13.5px;
  padding: 12px 14px;
  line-height: 1.5;
  margin-top: 12px;
}

.error-display.visible { display: block; }

/* Controls bar */
.room-controls {
  padding: 14px 0 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-shrink: 0;
}

/* Control buttons (pill shape) */
.control-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 26px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  min-width: 110px;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.mute-btn {
  background: var(--surface-raised);
  color: var(--text-1);
  border: 1px solid var(--border);
}

.mute-btn:hover { background: #272727; }

/* Muted state */
.mute-btn.muted {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.mute-btn.muted:hover { background: rgba(239, 68, 68, 0.2); }

.leave-btn {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.leave-btn:hover { background: rgba(239, 68, 68, 0.18); }

/* ── ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESPONSIVE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ── */

@media (max-width: 480px) {
  .landing-card {
    padding: 28px 20px;
    border-radius: var(--radius);
  }

  .room-layout {
    padding: 0 14px;
  }

  .control-btn {
    padding: 11px 18px;
    min-width: 90px;
  }
}

/* ── Utility ────────────────────────────────────────────────── */
.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;
}
