/* ─── Fonts ──────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@300;400;500&display=swap');

/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:        #0F0F10;
  --surface:   #171717;
  --surface-2: #1C1C1C;
  --border:    rgba(255, 255, 255, 0.07);
  --text:      #EDEDED;
  --muted:     #A1A1A1;
  --muted-2:   rgba(237, 237, 237, 0.6);
  --success:   #22C55E;
  --success-bg: rgba(34, 197, 94, 0.12);
  --success-border: rgba(34, 197, 94, 0.25);
  --danger:    #EF4444;
  --focus:     rgba(34, 197, 94, 0.25);
  --radius:    10px;
  --pad:       20px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

button:focus-visible {
  box-shadow: 0 0 0 3px var(--focus);
}

/* ─── Logo Component ────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1;
}

.brand-name em {
  font-style: normal;
  color: var(--success);
}

/* ─── Lobby ─────────────────────────────────────────────────────────────── */
.lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--pad);
  position: relative;
}

/* Subtle radial glow behind the card */
.lobby::before {
  content: '';
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 500px;
  background: radial-gradient(ellipse at center top, rgba(34, 197, 94, 0.07) 0%, transparent 65%);
  pointer-events: none;
}

.lobby-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
}

.lobby-card h1 {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.lobby-card .subtitle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 300;
  margin-top: 6px;
}

.btn-primary {
  background: var(--success);
  color: #000;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
  width: 100%;
  text-align: center;
}
.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.25);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.text-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus {
  border-color: var(--success-border);
  box-shadow: 0 0 0 3px var(--focus);
}

.link-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-box label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.link-row {
  display: flex;
  gap: 8px;
}

.link-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.link-row input:focus {
  border-color: rgba(255,255,255,0.2);
}

.btn-copy {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-copy:hover { background: #252525; }
.btn-copy.copied { color: var(--success); }

.redirect-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

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

/* ─── Top Bar ───────────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-name {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.app-name em {
  font-style: normal;
  color: var(--success);
}

.room-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.status-badge {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 2s ease-in-out infinite;
}
.status-badge.connected {
  color: var(--success);
}
.status-badge.connected::before {
  background: var(--success);
  animation: none;
}
.status-badge.hidden {
  display: none;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Control Buttons ───────────────────────────────────────────────────── */
.ctrl-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.ctrl-btn:hover { background: #252525; border-color: rgba(255,255,255,0.12); }

.ctrl-btn[data-active="false"] {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.ctrl-btn.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}
.ctrl-btn.danger:hover {
  background: var(--danger);
  color: #fff;
}

.ctrl-btn.active-screen {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--success);
}

.ctrl-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ─── Stage (video area) ────────────────────────────────────────────────── */
.stage {
  flex: 1;
  padding: 12px;
  overflow: hidden;
}

/* Split mode: equal halves */
.stage--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  gap: 10px;
}

.stage--split #panel-left  { grid-column: 1; grid-row: 1; }
.stage--split #panel-right { grid-column: 2; grid-row: 1; }
.stage--split #video-screen { display: none !important; }

/* Screen share mode */
.stage--screenshare {
  display: grid;
  grid-template-columns: 2fr 32px 1fr;
  grid-template-rows: 1fr;
  gap: 0;
}

.stage--screenshare #video-screen {
  display: block !important;
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  background: #000;
  object-fit: contain;
}

.stage--screenshare #panel-left { display: none; }

.stage--screenshare #panel-right {
  grid-column: 3;
  grid-row: 1;
  display: flex !important;
  flex-direction: column;
  gap: 10px;
}

/* ─── Video Panels ──────────────────────────────────────────────────────── */
.panel {
  position: relative;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.panel video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
}

.panel--half {
  flex: 1;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.panel--half video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.panel,
.panel--half {
  transition: box-shadow 0.4s ease;
}

.panel.speaking,
.panel--half.speaking {
  box-shadow: 0 0 0 2px var(--success), 0 0 16px rgba(34, 197, 94, 0.2);
}

.nametag {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  pointer-events: none;
}

/* Camera off placeholder */
.cam-off-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius);
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.cam-off-overlay svg {
  opacity: 0.4;
}

/* ─── Overlays ──────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 16, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  flex-direction: column;
  gap: 16px;
}

.overlay.hidden { display: none; }

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.overlay-card h2 { font-size: 18px; font-weight: 600; }
.overlay-card p  { font-size: 13px; color: var(--muted); line-height: 1.6; }

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--success);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Device Modal ──────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 16, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-card h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A1A1A1' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.modal-field select:focus { border-color: var(--success-border); }
.modal-field select option { background: var(--surface-2); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-modal-cancel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-modal-cancel:hover { background: var(--surface-2); }

.btn-modal-apply {
  background: var(--success);
  color: #000;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn-modal-apply:hover { opacity: 0.85; }

/* ─── Error message ─────────────────────────────────────────────────────── */
.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

/* ─── Utility ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
