:root {
  --bg-deep: #0b0f17;
  --bg-elev-1: #131a26;
  --bg-elev-2: #1b2330;
  --bg-elev-3: #232c3d;
  --border: #2a3447;
  --border-strong: #3a4561;
  --text: #eef2f8;
  --text-muted: #8b9bb4;
  --accent: #4e8cff;
  --accent-hover: #6ea4ff;
  --accent-soft: rgba(78, 140, 255, 0.18);
  --danger: #f56565;
  --success: #38d39f;
  --whatsapp: #25d366;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.32);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(78, 140, 255, 0.22), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(56, 211, 159, 0.12), transparent 55%),
    var(--bg-deep);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-6px); }
  40%,80% { transform: translateX(6px); }
}
.fade-in { animation: fadeUp 360ms ease-out both; }
.shake { animation: shake 360ms ease-in-out; }

/* ---------- Shell ---------- */
.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  gap: 28px;
}

.welcome {
  text-align: center;
  width: 100%;
  max-width: 720px;
}
.welcome-title {
  font-size: 2rem;
  margin: 0 0 6px 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.welcome-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--bg-elev-1) 0%, var(--bg-elev-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.brand-logo {
  width: 140px;
  height: auto;
  margin-bottom: 22px;
  filter: drop-shadow(0 8px 24px rgba(78, 140, 255, 0.42));
}

.card-title {
  font-size: 1.55rem;
  margin: 0 0 6px 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-subtitle {
  margin: 0 0 28px 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
}

input[type="text"], input[type="password"] {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-with-icon { position: relative; }
.input-with-icon input { padding-right: 44px; }
.eye-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  cursor: pointer;
  user-select: none;
}
.checkbox-row input { accent-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease, box-shadow 140ms ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, #3a78f0 100%);
  color: #fff;
  margin-top: 4px;
  box-shadow: 0 6px 16px rgba(78, 140, 255, 0.30);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(78, 140, 255, 0.36); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; transform: none; }

.btn-secondary {
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); background: var(--bg-elev-3); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease;
}
.icon-btn:hover { color: var(--text); background: var(--bg-elev-3); }

.error-msg {
  color: var(--danger);
  background: rgba(245, 101, 101, 0.10);
  border: 1px solid rgba(245, 101, 101, 0.35);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  margin-top: 4px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  width: 100%;
  background: rgba(11, 15, 23, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
}
.topbar-logo { height: 28px; }
.topbar-title { font-weight: 600; letter-spacing: -0.01em; }
.topbar-spacer { flex: 1; }
.topbar-user {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-elev-3);
  border-radius: 999px;
}

/* ---------- Dashboard ---------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  width: 100%;
  max-width: 880px;
}

.action-card h2 {
  font-size: 1.18rem;
  margin: 8px 0 8px 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.action-card p {
  color: var(--text-muted);
  margin: 0 0 18px 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.action-card #join-form {
  flex-direction: row;
  gap: 10px;
}
.action-card #join-form input { flex: 1; }

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  margin-bottom: 4px;
}
.icon-join { color: var(--success); background: rgba(56, 211, 159, 0.16); }

/* ---------- Share card ---------- */
.share-card {
  width: 100%;
  max-width: 880px;
  border-color: var(--border-strong);
}
.share-card h3 { margin: 0 0 14px 0; font-size: 1.08rem; }
.share-row { display: flex; gap: 10px; margin-bottom: 14px; }
.share-row input { flex: 1; }
.share-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
  font-family: inherit;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.whatsapp { color: var(--whatsapp); }
.chip-btn.whatsapp:hover { border-color: var(--whatsapp); background: rgba(37, 211, 102, 0.10); }
.chip-btn.email:hover { background: rgba(78, 140, 255, 0.10); }

.qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 16px;
  background: var(--bg-deep);
  border-radius: 12px;
  border: 1px dashed var(--border);
}
#qr-code img, #qr-code canvas { display: block; border-radius: 6px; background: #fff; padding: 6px; }
.qr-help { color: var(--text-muted); font-size: 0.82rem; margin: 0; }

/* ---------- History ---------- */
.history-card { width: 100%; max-width: 880px; }
.history-card h3 { margin: 0; font-size: 1.05rem; }
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.btn-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.84rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
}
.btn-link:hover { color: var(--danger); background: rgba(245, 101, 101, 0.10); }
.history-del { color: var(--text-muted); }
.history-del:hover { color: var(--danger); background: rgba(245, 101, 101, 0.10); }
#history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#history-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
}
#history-list .room-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.94rem;
}
#history-list .room-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}
#history-list a, #history-list button {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.84rem;
  font-family: inherit;
}
#history-list a:hover { text-decoration: underline; }

/* ---------- Room (iframe full-screen) ---------- */
.room-body {
  margin: 0;
  background: var(--bg-deep);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.room-topbar {
  position: relative;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  z-index: 15;
}
.room-topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
}
.room-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  transition: color 120ms ease, background 120ms ease;
}
.room-back:hover { color: var(--text); background: var(--bg-elev-3); }
.room-logo { height: 22px; }
.room-title { font-weight: 600; font-size: 0.95rem; }
.room-id {
  color: var(--text-muted);
  font-size: 0.84rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--bg-elev-3);
  padding: 4px 10px;
  border-radius: 999px;
}

#jitsi-container {
  flex: 1;
  width: 100%;
  position: relative;
}
#jitsi-container iframe { border: none; width: 100%; height: 100%; }

#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 280ms ease;
}
.loading-inner {
  text-align: center;
  color: var(--text-muted);
}
.loading-logo {
  width: 96px;
  margin-bottom: 12px;
  filter: drop-shadow(0 8px 24px rgba(78, 140, 255, 0.42));
  animation: fadeUp 360ms ease-out both;
}

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
  .auth-card { padding: 28px 22px; }
  .topbar-inner, .room-topbar-inner { padding: 10px 12px; }
  .topbar-user { display: none; }
  .room-id { display: none; }
  .welcome-title { font-size: 1.6rem; }
}
