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

:root {
  --bg:        #0d0d14;
  --surface:   #16161f;
  --surface2:  #1e1e2a;
  --border:    #2a2a3a;
  --accent:    #6366f1;
  --accent-h:  #818cf8;
  --green:     #22c55e;
  --red:       #ef4444;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --radius:    10px;
}

html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

/* ── Landing Page ─────────────────────────────────────────── */
.landing-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

.logo { color: var(--accent); }
.landing-card h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); text-align: center; font-size: 0.9rem; line-height: 1.5; }

.btn-large { width: 100%; padding: 0.85rem; font-size: 1rem; }

.divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.join-row .input { flex: 1; }

.hint { color: var(--text-muted); font-size: 0.78rem; text-align: center; }

/* ── Buttons ──────────────────────────────────────────────── */
button { cursor: pointer; border: none; border-radius: var(--radius); font-size: 0.9rem; font-weight: 500; transition: all 0.15s ease; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.65rem 1.25rem;
}
.btn-primary:hover { background: var(--accent-h); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.65rem 1rem;
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-h); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-sm { font-size: 0.8rem; border-radius: 6px; }

/* ── Input ────────────────────────────────────────────────── */
.input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

/* ── Room Layout ──────────────────────────────────────────── */
.room-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
}
.room-header-left { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.logo-icon { color: var(--accent); flex-shrink: 0; }
.room-label { color: var(--text-muted); }
.room-id-text { color: var(--text); font-family: monospace; font-size: 0.9rem; }

/* Main */
.room-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* Participants */
.participants-panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-title {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.participant {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  transition: background 0.1s;
}
.participant:hover { background: var(--surface2); }
.participant.self .participant-avatar { background: var(--accent); }

.participant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.participant-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.participant-name {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.participant-status {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.participant-status.connected { color: var(--green); }
.participant-status.connecting { color: #f59e0b; }
.participant-status.disconnected, .participant-status.failed { color: var(--red); }

/* System log */
.system-log {
  padding: 0.5rem;
  max-height: 120px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.system-message {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.2rem 0.4rem;
  line-height: 1.4;
}

/* Screen panel (chat container) */
.screen-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Error banner */
.error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  text-align: center;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  min-width: 80px;
  font-size: 0.72rem;
  font-weight: 500;
  transition: all 0.15s;
}
.control-btn:hover { border-color: var(--accent); color: var(--accent-h); }
.control-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent);
  color: var(--accent-h);
}
.control-btn.muted {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red);
  color: #fca5a5;
}
.leave-btn { border-color: rgba(239,68,68,0.3); color: #fca5a5; }
.leave-btn:hover { background: rgba(239,68,68,0.15); border-color: var(--red); color: #fca5a5; }

.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.mic-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  max-width: 130px;
  cursor: pointer;
  outline: none;
}
.mic-select:focus { border-color: var(--accent); }
.mic-select option { background: var(--surface2); }

/* Chat */
.chat-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-header {
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--surface2);
  word-break: break-word;
  max-width: 70%;
}
.chat-msg.self {
  background: rgba(99,102,241,0.15);
  align-self: flex-end;
}
.chat-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-h);
}
.chat-msg.self .chat-name { color: var(--accent); }
.chat-text { font-size: 0.85rem; color: var(--text); line-height: 1.45; }
.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}
.chat-input { flex: 1; padding: 0.45rem 0.7rem; font-size: 0.85rem; }
.chat-send { padding: 0.45rem 0.9rem; font-size: 0.82rem; }

/* Volume sliders */
.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.vol-slider:hover::-webkit-slider-thumb { background: var(--accent-h); }

/* Participant volume row */
.participant-vol {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.participant:hover .participant-vol { opacity: 1; }
.participant-vol svg { flex-shrink: 0; color: var(--text-muted); }
.participant-vol .vol-slider { width: 70px; }

/* Scrollbars */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Responsive */
@media (max-width: 600px) {
  .participants-panel { width: 170px; }
  .control-btn { min-width: 64px; padding: 0.55rem 0.8rem; }
}

/* ── Landing layout (card + online panel) ─────────────────── */
.landing-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  max-width: 740px;
  width: 100%;
  padding: 1.5rem 1rem;
}

/* Name row */
.name-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}
.name-label { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* Create section */
.create-section { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; }

/* Join section */
.join-section { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }

/* Toggle label */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }

/* Input error state */
.input.input-error { border-color: var(--red); animation: shake 0.3s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ── Online panel ─────────────────────────────────────────── */
.online-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 240px;
  flex-shrink: 0;
  overflow: hidden;
  align-self: flex-start;
}

.online-list {
  padding: 0.4rem;
  max-height: 420px;
  overflow-y: auto;
}

.online-empty {
  padding: 1.25rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.online-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  transition: background 0.1s;
}
.online-user:hover { background: var(--surface2); }

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.online-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.online-user-name {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-room { font-size: 0.7rem; }
.online-room.idle    { color: var(--text-muted); }
.online-room.private { color: var(--text-muted); }
.online-room.public  { color: var(--accent-h); text-decoration: none; }
.online-room.public:hover { text-decoration: underline; }

/* ── Password overlay ─────────────────────────────────────── */
.password-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.password-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  margin: 1rem;
}
.password-modal h3 { font-size: 1.1rem; font-weight: 600; }
.password-modal p  { color: var(--text-muted); font-size: 0.875rem; }
.password-modal-btns { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── Responsive landing ───────────────────────────────────── */
@media (max-width: 680px) {
  .landing-layout { flex-direction: column; align-items: center; }
  .online-panel { width: 100%; max-width: 420px; }
}
