/* =========================================================================
   RandomTalk — main stylesheet
   Original design system: dark, modern, mobile-first.
   ========================================================================= */

:root {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --transition: 180ms ease;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ---------- Nav ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav-links { display: flex; align-items: center; gap: 18px; }
.nav-links a { color: var(--text-muted); font-weight: 500; }
.nav-links a:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), opacity var(--transition);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-icon { width: 52px; height: 52px; border-radius: 50%; padding: 0; font-size: 1.2rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-google {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  font-weight: 600;
}
.btn-google:hover { background: #f7f7f7; }
.btn-google svg { width: 20px; height: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Landing hero ---------- */
.hero {
  text-align: center;
  padding: 90px 20px 60px;
}
.hero h1 { font-size: 2.6rem; margin-bottom: 14px; line-height: 1.15; }
.hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 560px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; padding: 40px 0 80px; }
.feature { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; }
.feature .icon { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); margin-bottom: 16px; }
.feature .icon svg { width: 32px; height: 32px; color: var(--accent); }
.feature h3 { margin: 6px 0; font-size: 1.15rem; }
.feature p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card p { color: var(--text-muted); margin-bottom: 28px; }
.auth-error {
  background: rgba(255, 92, 108, 0.12);
  border: 1px solid rgba(255, 92, 108, 0.3);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.legal-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 22px; }

/* ---------- Dashboard ---------- */
.dash-hero { text-align: center; padding: 60px 20px 20px; }
.dash-hero img.avatar-lg { width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 16px; border: 3px solid var(--accent); }
.stats-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; padding: 30px 0 60px; }
.stat-card { min-width: 150px; text-align: center; }
.stat-card .num { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-card .label { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Chat page ---------- */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  height: calc(100vh - 60px);
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
}

@media (max-width: 600px) {
  .hero { padding: 50px 20px 40px; }
  .hero h1 { font-size: 2rem; }
  .features { gap: 16px; padding: 20px 0 60px; grid-template-columns: 1fr; }
  .feature { padding: 20px; }
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 0.9rem; }
}

.video-stage {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 60vh;
}
.video-stage video#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05060a;
}
.local-preview {
  position: absolute;
  bottom: 96px;
  right: 16px;
  width: 130px;
  height: 174px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  background: #05060a;
  z-index: 10;
}
.local-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.status-pill {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

.remote-user-tag {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.match-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14,17,23,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 20;
  text-align: center;
  padding: 20px;
}
.spinner {
  width: 46px; height: 46px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.controls-bar .btn-icon.off { background: var(--danger); color: #fff; }

.side-panel {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side-tabs { display: flex; border-bottom: 1px solid var(--border); }
.side-tabs button {
  flex: 1;
  padding: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.side-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 0.9rem; word-wrap: break-word; }
.chat-msg.mine { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.theirs { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg.system { align-self: center; color: var(--text-muted); font-size: 0.78rem; background: none; }

.chat-input-row { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border); }
.chat-input-row input {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 999px; font-size: 0.9rem;
}
.chat-input-row input:focus { outline: none; border-color: var(--accent); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; text-align: left; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text-muted); }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 420px; }
.modal h2 { margin-top: 0; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Toasts / empty states ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border); padding: 12px 20px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 300; font-size: 0.9rem;
}
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ---------- Admin ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px; background: var(--bg-elevated); border-right: 1px solid var(--border);
  padding: 20px 0; flex-shrink: 0;
}
.admin-sidebar a { display: block; padding: 12px 24px; color: var(--text-muted); font-weight: 500; }
.admin-sidebar a.active, .admin-sidebar a:hover { color: var(--text); background: var(--accent-soft); }
.admin-content { flex: 1; padding: 32px; overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; }
table.admin-table th, table.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; }
table.admin-table th { color: var(--text-muted); font-weight: 600; background: var(--bg-elevated); }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-active { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-suspended { background: rgba(245,166,35,0.15); color: var(--warning); }
.badge-banned { background: rgba(255,92,108,0.15); color: var(--danger); }
.badge-open { background: rgba(245,166,35,0.15); color: var(--warning); }
.badge-resolved { background: rgba(46,204,113,0.15); color: var(--success); }

footer.site-footer { text-align: center; padding: 30px 20px; color: var(--text-muted); font-size: 0.82rem; border-top: 1px solid var(--border); }
footer.site-footer a { color: var(--text-muted); margin: 0 8px; }

.flag { font-size: 1.1rem; }
