/* web/public/style.css */
/* Tema: dark por defecto, light toggle. Paleta: indigo/violeta. */

/* ─── Custom Properties ──────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:          #0f0f13;
  --surface:     #1a1a24;
  --surface-2:   #222233;
  --border:      #2a2a3a;
  --primary:     #6366f1;
  --primary-h:   #4f46e5;
  --primary-dim: rgba(99,102,241,.15);
  --text:        #e2e2f0;
  --text-muted:  #888895;
  --text-faint:  #555566;
  --success:     #22c55e;
  --error:       #ef4444;
  --error-bg:    rgba(239,68,68,.12);
  --radius:      12px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
}

[data-theme="light"] {
  --bg:          #f4f4fa;
  --surface:     #ffffff;
  --surface-2:   #f0f0f8;
  --border:      #e0e0ee;
  --primary:     #6366f1;
  --primary-h:   #4f46e5;
  --primary-dim: rgba(99,102,241,.10);
  --text:        #1a1a2e;
  --text-muted:  #6b6b8a;
  --text-faint:  #a0a0b8;
  --success:     #16a34a;
  --error:       #dc2626;
  --error-bg:    rgba(220,38,38,.08);
  --shadow:      0 4px 24px rgba(0,0,0,.08);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .2s, color .2s;
}

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

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.main-content { flex: 1; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  font-size: 22px;
  color: var(--primary);
  line-height: 1;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: 64px;
}

.footer-text {
  font-size: 12px;
  color: var(--text-faint);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-h); }

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

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
}
.btn-danger:hover:not(:disabled) { opacity: .88; }
.btn-danger:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }
[data-theme="light"] .icon-sun { display: inline; }
[data-theme="light"] .icon-moon { display: none; }

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

.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.card-icon {
  display: block;
  font-size: 36px;
  margin-bottom: 12px;
  line-height: 1;
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.card-sub {
  font-size: 14px;
  color: var(--text-muted);
}

.card-title-sm {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .3px;
}

.form-hint {
  font-weight: 400;
  color: var(--text-faint);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.form-input::placeholder { color: var(--text-faint); }

.form-input-code {
  font-family: 'Courier New', monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 10px;
  text-align: center;
  padding: 14px;
}

.form-actions { display: flex; justify-content: flex-end; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(239,68,68,.25);
}

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  background: var(--primary-dim);
  color: var(--primary);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  padding: 80px 0 64px;
  text-align: center;
}

.hero-title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.1;
}

.hero-sub {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 32px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ─── Section ────────────────────────────────────────────────────────────── */
.section { padding: 0 0 64px; }

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Rooms Grid ─────────────────────────────────────────────────────────── */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color .15s, transform .15s;
}

.room-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.room-card-id {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 6px;
  font-family: 'Courier New', monospace;
}

.room-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.room-card-topic {
  display: block;
  width: 100%;
  height: 22px;
  background: #fff;
}

a.room-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.empty-state {
  color: var(--text-faint);
  font-size: 14px;
  padding: 20px 0;
}

/* ─── Auth Pages ─────────────────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  text-align: center;
  margin-top: 20px;
}

.auth-sep {
  color: var(--text-faint);
  font-size: 12px;
}

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

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  padding-top: 36px;
  padding-bottom: 64px;
  align-items: start;
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 80px;
}

.sidebar-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.sidebar-email {
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }

.sidebar-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}

.sidebar-link:hover, .sidebar-link.active {
  background: var(--primary-dim);
  color: var(--primary);
  text-decoration: none;
}

.dashboard-main { display: flex; flex-direction: column; gap: 20px; }

.page-header { margin-bottom: 4px; }

.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
}

.section-card { }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td { background: var(--surface-2); }

.td-mono { font-family: 'Courier New', monospace; color: var(--primary); font-weight: 600; }

.room-id-badge {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  letter-spacing: .5px;
  user-select: all;
}
.td-empty { color: var(--text-faint); text-align: center; padding: 24px; }

/* ─── Danger Zone ────────────────────────────────────────────────────────── */
.danger-zone { border-color: var(--error) !important; }
.danger-title { color: var(--error) !important; }

/* ─── Error Pages ────────────────────────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
  text-align: center;
  padding: 40px;
}

.error-code {
  font-size: 96px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -4px;
  line-height: 1;
  margin-bottom: 16px;
  opacity: .8;
}

.error-msg {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ─── Scripts Page ───────────────────────────────────────────────────────── */
.scripts-list { display: flex; flex-direction: column; gap: 16px; }

.script-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.script-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.script-card-name {
  font-family: 'Courier New', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.data-section { margin-top: 4px; }

.data-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.progress-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .3s;
}

.files-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}

.file-row-name {
  flex: 1;
  font-family: 'Courier New', monospace;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row-size { color: var(--text-faint); white-space: nowrap; }

.empty-state-sm { color: var(--text-faint); font-size: 13px; margin-bottom: 10px; }

.badge-ok  { background: rgba(34,197,94,.15); color: var(--success); }
.badge-warn { background: rgba(234,179,8,.15);  color: #ca8a04; }

.mono-id {
  font-family: 'Courier New', monospace;
  color: var(--primary);
}

.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .hero { padding: 48px 0 40px; }
}

@media (max-width: 480px) {
  .header-inner { gap: 12px; }
  .user-email { display: none; }
  .card { padding: 20px; }
}
