/* ui-theme.css — Stint Speech Studio shared design system
 * Brand: #4474B9 · #4E8ACE · #75C4F3 · #0F6199 · #FFFFFF */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ─── Tokens: Light ─── */
:root {
  --brand-primary: #4474B9;
  --brand-mid:     #4E8ACE;
  --brand-light:   #75C4F3;
  --brand-deep:    #0F6199;

  --bg:            #edf3fb;
  --panel:         #ffffff;
  --panel-alt:     #f4f8fd;
  --surface:       #ffffff;
  --surface-alt:   #f4f8fd;
  --surface-inset: #eaf1f9;
  --editor-bg:     #f7faff;

  --ink:           #0d1b2e;
  --muted:         #5c7a9b;

  --accent:        #4474B9;
  --accent-hover:  #0F6199;
  --accent-soft:   rgba(68, 116, 185, 0.10);
  --accent-glow:   rgba(68, 116, 185, 0.22);
  --accent-light:  #eef3fa;

  --danger:        #c53030;
  --danger-soft:   rgba(197, 48, 48, 0.10);
  --danger-light:  #fdf0f0;
  --success:       #1a7a3f;
  --success-light: #eaf5ef;
  --warn:          #a16207;
  --warn-light:    #fef9ec;

  --line:          #c4d6eb;
  --line-subtle:   #dce9f5;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  --shadow-sm: 0 1px 3px rgba(15, 97, 153, 0.06);
  --shadow:    0 2px 8px rgba(15, 97, 153, 0.08), 0 1px 3px rgba(15, 97, 153, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 97, 153, 0.10), 0 2px 6px rgba(15, 97, 153, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 97, 153, 0.14), 0 4px 12px rgba(15, 97, 153, 0.08);
}

/* ─── Tokens: Dark — supports [data-theme="dark"] (index) and html.dark (agent) ─── */
[data-theme="dark"], html.dark {
  --bg:            #0a1420;
  --panel:         #0f1a2b;
  --panel-alt:     #142030;
  --surface:       #0f1a2b;
  --surface-alt:   #142030;
  --surface-inset: #0d1826;
  --editor-bg:     #152438;

  --ink:           #e6f0fa;
  --muted:         #7a9ab8;

  --accent:        #75C4F3;
  --accent-hover:  #4E8ACE;
  --accent-soft:   rgba(117, 196, 243, 0.12);
  --accent-glow:   rgba(117, 196, 243, 0.26);
  --accent-light:  rgba(117, 196, 243, 0.10);

  --danger:        #e05252;
  --danger-soft:   rgba(224, 82, 82, 0.13);
  --danger-light:  rgba(224, 82, 82, 0.10);
  --success:       #2ecc71;
  --success-light: rgba(46, 204, 113, 0.10);
  --warn:          #e6a817;
  --warn-light:    rgba(230, 168, 23, 0.10);

  --line:          #1d334e;
  --line-subtle:   #162840;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow:    0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.50);
}

/* ─── Animations ─── */
@keyframes shimmer   { 0%   { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes btn-spin  { to   { transform: rotate(360deg); } }
@keyframes spin      { to   { transform: rotate(360deg); } }
@keyframes pulse     { 0%, 100% { transform: scale(1); opacity: 0.55; } 50% { transform: scale(1.55); opacity: 1; } }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Buttons ─── */
.btn {
  height: 38px; border-radius: var(--radius-sm); border: none; padding: 0 18px;
  font-weight: 600; font-size: 13px; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap; position: relative; text-decoration: none;
  -webkit-font-smoothing: antialiased;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 14px var(--accent-glow); }

.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); color: var(--ink); border-color: var(--muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a82020; box-shadow: 0 4px 12px var(--danger-soft); }

.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover:not(:disabled) { background: #8a5106; }

.btn-sm  { height: 30px; font-size: 12px; padding: 0 12px; border-radius: 6px; }
.btn-xs  { height: 24px; font-size: 11px; padding: 0 9px;  border-radius: 5px; }

.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn svg, .btn-icon svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

.btn.loading { pointer-events: none; }
.btn.loading::after {
  content: ""; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.30); border-top-color: #fff;
  border-radius: 50%; animation: btn-spin 0.55s linear infinite; margin-left: 4px;
}
.btn-ghost.loading::after { border-color: rgba(0,0,0,0.12); border-top-color: var(--muted); }

/* ─── Forms ─── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
select {
  height: 38px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  padding: 0 12px; font-family: inherit; font-size: 14px;
  background: var(--surface); color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ─── Cards ─── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--ink); }

/* ─── Stat Cards ─── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-light));
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-card .stat-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-top: 6px; font-weight: 600;
}

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px;
  border-bottom: 2px solid var(--line); background: var(--surface-alt); position: sticky; top: 0;
}
td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--line-subtle); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-soft); }
.actions-cell { display: flex; gap: 4px; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-invited  { background: var(--warn-light);    color: var(--warn); }
.badge-disabled { background: var(--danger-light);  color: var(--danger); }
.badge-admin    { background: var(--accent-light);  color: var(--accent); }
.badge-neutral  { background: var(--surface-alt);   color: var(--muted); border: 1px solid var(--line); }

/* ─── Filter Bar ─── */
.filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar input, .filter-bar select { height: 34px; font-size: 13px; }

.filter-active-indicator {
  display: none; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-glow); border-radius: 6px;
  font-size: 12px; font-weight: 600; margin-bottom: 12px;
}
.filter-active-indicator.visible { display: inline-flex; }
.filter-active-indicator svg { width: 14px; height: 14px; fill: currentColor; }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.55; }
.empty-state-text { font-size: 14px; line-height: 1.6; }

/* ─── Skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--line-subtle) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 6px; height: 18px; margin: 6px 0;
}
.skeleton-card { height: 82px; border-radius: var(--radius); }
.skeleton-row  { height: 36px; border-radius: 4px; margin: 4px 0; }

/* ─── Toast ─── */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  color: #fff; box-shadow: var(--shadow-lg); animation: toast-in 0.25s ease;
  pointer-events: auto; max-width: 360px; line-height: 1.4;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--accent); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.50);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px; width: 92%; max-width: 480px;
  box-shadow: var(--shadow-lg); animation: slideDown 0.2s ease;
}
.modal.modal-lg { max-width: 720px; }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal p  { color: var(--muted); font-size: 14px; margin-bottom: 20px; line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Shared Login Field ─── */
.login-field { display: grid; gap: 6px; margin-bottom: 16px; }
.login-field label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.login-error { min-height: 20px; font-size: 13px; color: var(--danger); margin-bottom: 8px; }

.login-divider, .divider {
  display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 12px;
}
.login-divider::before, .login-divider::after,
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.google-btn {
  width: 100%; height: 46px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 15px;
  cursor: pointer; font-family: inherit; display: flex; align-items: center;
  justify-content: center; gap: 10px; transition: border-color 0.2s, box-shadow 0.2s;
}
.google-btn:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

/* ─── Auth Card (admin login) ─── */
.auth-screen {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--muted); margin-bottom: 24px; font-size: 14px; }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ─── Bulk Bar ─── */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--accent); color: #fff; border-radius: var(--radius-sm);
  margin-bottom: 12px; font-size: 13px; font-weight: 500;
}
.bulk-bar .btn-sm { background: rgba(255,255,255,0.18); color: #fff; border: 1px solid rgba(255,255,255,0.28); }
.bulk-bar .btn-sm:hover { background: rgba(255,255,255,0.32); border-color: rgba(255,255,255,0.5); }
.bulk-bar .btn-sm.btn-deselect { background: rgba(220,50,50,0.5); border-color: rgba(220,50,50,0.7); }
.bulk-bar .btn-sm.btn-deselect:hover { background: rgba(220,50,50,0.7); }

/* ─── Toggle Row ─── */
.toggle-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.toggle-row input[type="checkbox"] { height: auto; width: auto; accent-color: var(--accent); }

/* ─── Utilities ─── */
.hidden  { display: none !important; }
.mono    { font-variant-numeric: tabular-nums; font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 12px; }

.copyable { cursor: pointer; position: relative; transition: color 0.15s; }
.copyable:hover { color: var(--accent); }
.copy-tooltip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 3px 8px; border-radius: 4px;
  font-size: 10px; white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity 0.15s; margin-bottom: 4px;
}
.copyable:hover .copy-tooltip { opacity: 1; }
