/* ===== Foxden — Foxline dark theme ===== */

:root {
  color-scheme: dark;
  --bg: #262624;
  --card: #202020;
  --accent: #e17a3e;
  --accent-hover: #e8884e;
  --accent-bg: #383024;
  --accent-dim: rgba(225,122,62,0.12);
  --btn-gray: #4b4943;
  --text: #faf9f7;
  --text-secondary: #b5b4b2;
  --text-muted: #a09b8b;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.1);
  --red: #e05252;
  --yellow: #d4a22e;
  --green: #3fb950;
  --good: #3fb950;
  --radius: 10px;
  --radius-sm: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ===== Layout shell ===== */
.shell {
  width: min(520px, calc(100vw - 32px));
  margin: 2rem auto;
  display: grid;
  gap: 1rem;
}

/* ===== Panel (card) ===== */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
}

/* ===== Hidden utility ===== */
.hidden {
  display: none !important;
}

/* ===== Typography ===== */
.hero h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}

.form h2,
.call h2,
#log-panel h2 {
  margin: 0 0 10px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.lede {
  color: var(--text-muted);
  font-size: 0.88rem;
  max-width: 340px;
}

.muted {
  color: var(--text-muted);
}

/* ===== Lobby ===== */
.lobby {
  display: grid;
  gap: 1rem;
  text-align: center;
}

.lobby .hero {
  background: transparent;
  border: none;
  padding: 0;
  padding-top: 1rem;
}

.lobby .hero .eyebrow {
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
}

.lobby .hero .lede {
  margin: 0 auto;
}

/* ===== Form ===== */
.form {
  display: grid;
  gap: 0.85rem;
  text-align: left;
  padding: 1.5rem;
}

.form h2 {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--btn-gray);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: var(--text-muted);
}

/* ===== Buttons ===== */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.25rem;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-hover);
}

/* Form submit button: full width with pulse */
.form button[type="submit"] {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 2rem;
  border-radius: var(--radius);
  animation: btn-pulse 2.5s ease-in-out infinite;
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225,122,62,0.4); }
  50% { box-shadow: 0 0 16px 4px rgba(225,122,62,0.15); }
}

/* Ghost button (Leave) */
button.ghost {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
}

button.ghost:hover {
  background: rgba(224,82,82,0.1);
}

/* ===== Form error ===== */
.form-error {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  background: rgba(224,82,82,0.1);
  color: var(--red);
  border-left: 3px solid var(--red);
}

/* ===== Call screen ===== */
.call {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.call-header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.call-header > div:first-child {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.call-header .eyebrow {
  display: none;
}

.call-header h2 {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

.call-header p {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0;
}

.status-wrap {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Status badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(63,185,80,0.12);
  color: var(--green);
}

.status.muted {
  background: var(--accent-bg);
  color: var(--accent);
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.5rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.toolbar-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

/* Add divider between toolbar groups */
.toolbar-group + .toolbar-group {
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-strong);
}

.toolbar-spacer {
  flex: 1;
}

.toolbar select {
  width: auto;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--btn-gray);
  color: var(--text-secondary);
}

.toolbar select:focus {
  border-color: var(--accent);
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--btn-gray);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  animation: none;
}

.toolbar button:hover {
  border-color: var(--text-muted);
  background: rgba(255,255,255,0.03);
}

/* Camera button states */
.toolbar .btn-camera {
  border-color: var(--btn-gray);
  color: var(--text-secondary);
  background: transparent;
}

.toolbar .btn-camera:hover {
  border-color: var(--text-muted);
  background: rgba(255,255,255,0.03);
}

.toolbar .btn-camera.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.toolbar .btn-screen-share.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(63,185,80,0.12);
}

/* ===== Participants section ===== */
.call > section:last-of-type {
  padding: 1.25rem;
}

.call > section:last-of-type h3 {
  display: none;
}

.participants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.screen-stage {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: #171717;
}

.screen-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  background: rgba(255,255,255,0.03);
}

.screen-stage-header span:first-child {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.screen-stage-header small {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

.screen-stage-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #050505;
}

.screen-stage-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  cursor: pointer;
}

.screen-stage-snapshot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  object-fit: contain;
  background: #050505;
}

.screen-stage-snapshot.visible {
  display: block;
}

.screen-share-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.75rem 0.75rem;
}

.screen-share-selector:empty {
  display: none;
}

.screen-share-selector button {
  padding: 0.3rem 0.55rem;
  font-size: 0.74rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--btn-gray);
}

.screen-share-selector button.active {
  color: var(--green);
  border-color: var(--green);
  background: rgba(63,185,80,0.12);
}

/* ===== Participant card ===== */
.participant {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s;
}

.participant:hover {
  border-color: var(--border-strong);
}

.participant.active-speaker {
  border-color: var(--accent);
}

.participant-info {
  padding: 1rem 1rem;
}

.participant-info h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* Pill badge in participant info */
.participant .pill {
  display: inline-block;
  width: fit-content;
  border-radius: 20px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(63,185,80,0.12);
  color: var(--green);
}

.participant audio[data-participant-audio="true"] {
  display: none;
}

.participant-volume-control {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) 3rem;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.volume-label,
.volume-value {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.volume-value {
  text-align: right;
  color: var(--text-secondary);
}

.participant-volume {
  width: 100%;
  accent-color: var(--accent);
}

/* ===== Video inside participant card ===== */
.participant-video {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #1a1a1a;
  cursor: pointer;
}

.participant-video.mirror {
  transform: scaleX(-1);
}

.participant-video:fullscreen {
  object-fit: contain;
  background: #000;
  cursor: default;
}

/* Name overlay on video */
.participant-name-overlay {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(0,0,0,0.5);
  color: #fff;
  pointer-events: none;
}

.participant.has-volume-control .participant-name-overlay {
  bottom: 58px;
}

/* Stats overlay on video */
.video-stats {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  background: rgba(0,0,0,0.55);
  color: #90ee90;
  font-family: 'SF Mono', ui-monospace, monospace;
  pointer-events: none;
}

.video-stats.fallback {
  color: #ffd700;
}

.screen-stage-stats {
  position: static;
  white-space: nowrap;
}

/* ===== Log panel ===== */
#log-panel {
  padding: 0;
  overflow: hidden;
}

#log-panel h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  padding: 0.6rem 1rem;
  margin: 0;
}

pre {
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.7;
  color: var(--text-secondary);
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.65rem 1rem;
}

/* ===== Lobby footer ===== */
.lobby-footer {
  margin-top: 1.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.lobby-footer a {
  color: var(--accent);
  text-decoration: none;
}

.lobby-footer a:hover {
  text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .shell {
    width: calc(100vw - 16px);
    margin: 1rem auto;
  }

  .panel {
    padding: 0.85rem;
  }

  .call-header,
  .toolbar {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .call > section:last-of-type {
    padding: 0.75rem;
  }

  .participants {
    grid-template-columns: 1fr;
  }

  .toolbar-group {
    flex-wrap: wrap;
  }
}

/* ===== Call screen uses wider shell ===== */
.call {
  max-width: none;
}

/* Widen the shell when in a call (lobby hidden, call visible) */
.shell:has(.call:not(.hidden)) {
  width: min(960px, calc(100vw - 32px));
}
