/**
 * style.css — TabStream UI styles
 *
 * Dark theme, responsive layout, minimal dependencies.
 */

/* ── Reset & base ─────────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background: #0f1117;
  color: #e4e4e7;
  line-height: 1.5;
}

a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  transition: background 0.15s, transform 0.1s;
}
button:active { transform: scale(0.97); }

input {
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid #2e2e38;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  background: #1a1b26;
  color: #e4e4e7;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: #60a5fa; }

/* ── Layout ───────────────────────────────────────────────────────────────── */

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 2rem 0 1rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  color: #9ca3af;
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* ── Sections (landing / host / viewer) ───────────────────────────────────── */

.section {
  display: none;
  flex-direction: column;
  gap: 1rem;
}
.section.active { display: flex; }

/* ── Landing ──────────────────────────────────────────────────────────────── */

#landing {
  align-items: center;
  gap: 1.5rem;
  padding-top: 2rem;
}

.card {
  background: #1a1b26;
  border: 1px solid #2e2e38;
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
}

.card h2 {
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
  width: 100%;
  padding: 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
  background: #27272a;
  color: #e4e4e7;
}
.btn-secondary:hover { background: #3f3f46; }

.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}
.input-row input { flex: 1; }

.divider {
  text-align: center;
  color: #6b7280;
  font-size: 0.85rem;
  position: relative;
}

/* ── Host / Viewer common ─────────────────────────────────────────────────── */

.room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: #1a1b26;
  border: 1px solid #2e2e38;
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.room-bar .room-id {
  font-weight: 600;
  color: #60a5fa;
}

.room-bar .count {
  font-size: 0.85rem;
  color: #9ca3af;
}

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

.invite-row code {
  background: #1a1b26;
  border: 1px solid #2e2e38;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  color: #a78bfa;
  word-break: break-all;
}

/* ── Video ────────────────────────────────────────────────────────────────── */

.video-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.video-wrap .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 1rem;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* ── Video controls (viewer) ──────────────────────────────────────────────── */

.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  opacity: 0;
  transition: opacity 0.25s;
}

.video-wrap:hover .video-controls,
.video-wrap:fullscreen .video-controls {
  opacity: 1;
}

.ctrl-btn {
  background: none;
  color: #fff;
  font-size: 1.2rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
}
.ctrl-btn:hover { background: rgba(255, 255, 255, 0.15); }

.ctrl-spacer { flex: 1; }

#volume-slider {
  width: 100px;
  accent-color: #3b82f6;
  cursor: pointer;
}

/* Fullscreen: make video fill */
.video-wrap:fullscreen {
  background: #000;
}
.video-wrap:fullscreen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Small preview for host */
.video-preview {
  aspect-ratio: 16 / 9;
  max-width: 360px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2e2e38;
}
.video-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Status bar ───────────────────────────────────────────────────────────── */

.status {
  font-size: 0.9rem;
  color: #9ca3af;
  padding: 0.5rem 0;
}

.status.live {
  color: #34d399;
}

.status.error {
  color: #f87171;
}

/* ── Chat ─────────────────────────────────────────────────────────────────── */

.chat-box {
  background: #1a1b26;
  border: 1px solid #2e2e38;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: 260px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  min-height: 120px;
}

.chat-messages .msg-system {
  color: #6b7280;
  font-style: italic;
}

.chat-messages .msg-user b {
  color: #60a5fa;
}

.chat-input-row {
  display: flex;
  border-top: 1px solid #2e2e38;
}

.chat-input-row input {
  flex: 1;
  border: none;
  border-radius: 0 0 0 10px;
  background: transparent;
}

.chat-input-row button {
  border-radius: 0 0 10px 0;
  background: #3b82f6;
  color: #fff;
  padding: 0.5rem 1rem;
}

/* ── Log ──────────────────────────────────────────────────────────────────── */

.log-area {
  font-size: 0.8rem;
  color: #6b7280;
  max-height: 100px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  #app { padding: 1rem; }
  header h1 { font-size: 1.5rem; }
  .card { padding: 1rem; }
}
