@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500&family=Playfair+Display:ital@1&display=swap');

:root {
  --bg:       #0d0d0d;
  --surface:  #141414;
  --surface-2:#1c1c1c;
  --border:   #222;
  --border-2: #2a2a2a;
  --text:     #f0f0ee;
  --text-2:   #999;
  --text-3:   #666;
  --green:    #52b788;
  --amber:    #d4a853;
  --red:      #c0392b;
}

*, *::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, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Brand name italic */
.brand { font-family: 'Playfair Display', serif; font-style: italic; font-weight: 400; }

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: #222; border-color: #333; }
button:active, .btn:active { background: #282828; }

.btn--primary { background: var(--green); border-color: var(--green); color: #0d0d0d; font-weight: 500; }
.btn--primary:hover { background: #5dcf9a; border-color: #5dcf9a; }

.btn--danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn--danger:hover { background: var(--red); color: #fff; }

.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { color: var(--text); background: var(--surface-2); }

.btn--full { width: 100%; justify-content: center; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--icon { padding: 7px; border-radius: 6px; }

/* Inputs */
input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: #444; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 80px; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
}

.field { margin-bottom: 16px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
}

.auth-title {
  font-size: 22px;
  font-weight: 300;
  margin-bottom: 28px;
  color: var(--text);
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

/* Dashboard */
.dash-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.dash-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-logo {
  padding: 8px 12px;
  font-size: 18px;
  margin-bottom: 16px;
}

.dash-nav-btn {
  background: transparent;
  border: none;
  padding: 9px 12px;
  border-radius: 7px;
  text-align: left;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.dash-nav-btn:hover { background: var(--surface-2); color: var(--text); }
.dash-nav-btn.active { background: var(--surface-2); color: var(--text); }

.dash-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dash-section-title {
  font-size: 16px;
  font-weight: 400;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Pipeline card */
.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pipeline-card__title {
  font-size: 15px;
  font-weight: 500;
}

.pipeline-card__desc {
  font-size: 13px;
  color: var(--text-2);
  flex: 1;
}

.pipeline-card__passcode {
  font-size: 12px;
  color: var(--text-3);
}

.pipeline-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Brand card */
.brand-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-2);
}

.brand-logo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
}

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

/* Studio */
.studio-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.studio-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.studio-header__title { flex: 1; font-size: 14px; font-weight: 500; text-align: center; }
.studio-header__brands { display: flex; gap: 8px; align-items: center; }
.studio-header__brand-logo { height: 28px; border-radius: 4px; }

.studio-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.studio-video-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.studio-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.studio-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.studio-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 0;
  justify-content: center;
}
.studio-tab.active {
  color: var(--text);
  border-bottom-color: var(--green);
}

.studio-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
}
.studio-tab-content.active { display: flex; flex-direction: column; gap: 8px; }

/* Video grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  align-content: start;
}

.video-tile {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.video-tile.speaking { border-color: var(--green); }

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

.video-tile__name {
  position: absolute;
  bottom: 8px;
  left: 10px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.video-tile__avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
}

.video-tile__avatar-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-2);
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.ctrl-btn:hover { background: #282828; }
.ctrl-btn.active { background: var(--green); border-color: var(--green); color: #0d0d0d; }
.ctrl-btn.danger { background: var(--red); border-color: var(--red); color: #fff; }

/* Guest list items */
.guest-waiting-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.guest-waiting-card__name { font-size: 13px; margin-bottom: 8px; }
.guest-waiting-card__actions { display: flex; gap: 6px; }

.guest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.guest-item:last-child { border-bottom: none; }
.guest-item__name { flex: 1; font-size: 13px; }
.guest-item__icon { color: var(--text-3); }
.guest-item__icon.on { color: var(--text-2); }

/* Section header */
.section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  margin-top: 4px;
}

/* Chat */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.chat-msg { font-size: 13px; }
.chat-msg__name { font-weight: 500; color: var(--text-2); margin-right: 6px; }
.chat-msg__text { color: var(--text); }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input { flex: 1; }

/* Link row */
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.link-row:last-child { border-bottom: none; }
.link-row__label { color: var(--text-3); width: 80px; flex-shrink: 0; }
.link-row__url { flex: 1; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.status-pill--live { background: rgba(82,183,136,0.15); color: var(--green); }
.status-pill--connecting { background: rgba(212,168,83,0.15); color: var(--amber); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Live page */
.gate-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.gate-brands {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.gate-brand-logo {
  height: 36px;
  border-radius: 6px;
  object-fit: contain;
}

.waiting-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
  text-align: center;
  padding: 24px;
}

.waiting-screen.visible { display: flex; }
.waiting-title { font-size: 18px; font-weight: 300; }
.waiting-sub { color: var(--text-2); font-size: 14px; }

.call-layout {
  display: none;
  flex-direction: column;
  height: 100vh;
}
.call-layout.visible { display: flex; }

.call-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.call-header__title { flex: 1; font-size: 14px; font-weight: 500; text-align: center; }

/* Chat panel slide-in */
.chat-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 50;
}
.chat-panel.open { transform: translateX(0); }
.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chat-panel__title { font-size: 14px; font-weight: 500; }

.unread-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { border-color: var(--red); color: var(--red); }
.toast--success { border-color: var(--green); color: var(--green); }

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

/* Checkbox list (brand selector) */
.check-list { display: flex; flex-direction: column; gap: 8px; max-height: 160px; overflow-y: auto; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-item input[type=checkbox] { width: auto; }

/* Connecting placeholder */
.connecting-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-3);
  height: 100%;
}

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

/* View page */
.view-page {
  background: #000;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.view-video-full {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.view-grid {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.view-grid video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* Upload overlay */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,13,13,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
}
.upload-overlay.hidden { display: none; }
.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.upload-card__title { font-size: 16px; font-weight: 400; margin-bottom: 8px; }
.upload-card__sub { font-size: 13px; color: var(--text-2); margin-bottom: 24px; }
.upload-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}
.upload-progress__bar {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.upload-pct { font-size: 12px; color: var(--text-2); }

/* Recording row in dashboard */
.rec-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.rec-row:last-child { border-bottom: none; }
.rec-row__name { flex: 1; font-weight: 500; }
.rec-row__meta { color: var(--text-2); font-size: 12px; white-space: nowrap; }

/* Device picker modal */
.device-picker { display: flex; flex-direction: column; gap: 12px; }
.device-picker select { margin-top: 4px; }

/* Recording indicator */
.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: recblink 1s ease-in-out infinite;
}
@keyframes recblink { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }

/* Mobile */
@media (max-width: 700px) {
  /* Dashboard */
  .dash-layout { flex-direction: column; }
  .dash-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  .dash-logo { padding: 4px 8px; font-size: 16px; margin-bottom: 0; flex-shrink: 0; }
  .dash-nav-btn { padding: 6px 10px; font-size: 12px; }
  .dash-main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }

  /* Studio */
  .studio-body { flex-direction: column; }
  .studio-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 240px;
  }
  .studio-video-area { padding: 8px; }
  .video-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .controls-bar { padding: 10px 12px; gap: 8px; }
  .ctrl-btn { width: 38px; height: 38px; }
  .studio-header { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .studio-header__title { font-size: 12px; }

  /* Call layout (live.html) */
  .call-header { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .call-header__title { font-size: 12px; }
  .chat-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); }

  /* Gate card */
  .gate-card { padding: 24px 20px; }

  /* Modals */
  .modal-overlay { padding: 12px; }
  .modal { padding: 20px; }

  /* Link rows — stack on small screens */
  .link-row { flex-wrap: wrap; gap: 6px; }
  .link-row__url { width: 100%; }
}
