/* AStreamLabs — shared styles */

:root {
  --bg-base: #0b1020;
  --bg-elev: #131a32;
  --bg-elev-2: #1b2342;
  --border: #283155;
  --text: #e6e9f5;
  --text-dim: #8a93b8;
  --accent: #7c5cff;
  --accent-2: #48cae4;
  --warn: #f9c74f;
  --danger: #ff5c7a;
  --ok: #2dd4bf;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --radius-sm: 10px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(72, 202, 228, 0.14), transparent 60%),
    var(--bg-base);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 0;
}

input {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #0b1020;
  font-size: 18px;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: transform 0.05s, filter 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1020;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }

.btn-success {
  background: linear-gradient(135deg, #2dd4bf, #48cae4);
  color: #0b1020;
}
.btn-success:hover { filter: brightness(1.08); }

.error-msg {
  background: rgba(255, 92, 122, 0.12);
  border: 1px solid rgba(255, 92, 122, 0.35);
  color: #ffb6c1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.error-msg.show { display: block; }

.muted { color: var(--text-dim); font-size: 13px; }

/* ---------- App shell ---------- */
.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  background: rgba(11, 16, 32, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand { margin-bottom: 0; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }

.connection-pill {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.connection-pill::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.connection-pill.connected { background: rgba(45, 212, 191, 0.15); color: var(--ok); }
.connection-pill.disconnected { background: rgba(255, 92, 122, 0.15); color: var(--danger); }

.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 580px) 1fr;
  gap: 22px;
  padding: 22px;
  min-height: 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}
.card-header .title { color: var(--text); }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Stream view ---------- */
.stage {
  position: relative;
  background: #000;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.stage-empty {
  position: absolute;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}
.stage-empty .icon {
  font-size: 38px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.stage-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.stage-controls .meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- Chat ---------- */
.chat-card { min-height: 0; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg .author {
  font-weight: 700;
  flex-shrink: 0;
}
.chat-msg.avatar .author { color: var(--accent-2); }
.chat-msg.comment .author { color: var(--warn); }
.chat-msg.system { color: var(--text-dim); font-style: italic; font-size: 13px; }
.chat-msg.system .author { color: var(--text-dim); }

.composer {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.composer input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}
.composer input.name { width: 130px; flex-shrink: 0; }
.composer input.text { flex: 1; min-width: 0; }

.empty-chat {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 30px 20px;
}

/* ---------- Mobile ---------- */
@media (max-width: 880px) {
  .app-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding: 12px;
    gap: 12px;
  }
  .topbar { padding: 10px 14px; }
  .stage-controls { padding: 12px 14px; flex-wrap: wrap; }
  .composer { padding: 12px 14px; }
  .composer input.name { width: 100px; }
  .chat-card { min-height: 320px; }
}

/* ---------- Tiny utilities ---------- */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
