/* DeckVox self-hosted fonts — see apps/site/src/styles/fonts.css for the source rules */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-800.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}

:root {
  /* DeckVox UI Tokens — docs/brand/PLAYBOOK.md */
  --dv-indigo: #4f46e5;
  --dv-violet: #6d28d9;
  --dv-iris: #8b5cf6;
  --dv-midnight: #0d0b1e;
  --dv-slate: #191636;
  --dv-border-dark: #2d285e;
  --dv-ghost: #f8f7fc;
  --dv-emerald: #10b981;
  --dv-gradient: linear-gradient(135deg, #4f46e5 0%, #6d28d9 100%);
  --dv-bg-light: #f8f7fc;
  --dv-surface-light: #ffffff;
  --dv-border-light: #e4e2f2;
  --dv-text-primary: #0d0b1e;
  --dv-text-secondary: #524e72;
  --dv-ready: #10b981;
  --dv-font-display: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  --dv-font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  /* App panel semantic slots, mapped onto DeckVox tokens */
  --bg: var(--dv-bg-light);
  --surface: var(--dv-surface-light);
  --border: var(--dv-border-light);
  --text: var(--dv-text-primary);
  --text-muted: var(--dv-text-secondary);
  --brand: var(--dv-violet);
  --brand-dark: var(--dv-indigo);
  --accent: var(--dv-indigo);
  --danger: #e0245e;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  font-family: var(--dv-font-body);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

h1, h2, h3, .brand, .login-card h1 {
  font-family: var(--dv-font-display);
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.btn:hover { border-color: #c9cdd3; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover { background: var(--brand-dark); }

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

.btn-small { padding: 5px 10px; font-size: 12px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field { margin-bottom: 14px; }

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 16px;
  padding: 8px 10px 18px;
  display: flex;
  align-items: center;
}

.sidebar .brand img { height: 28px; width: auto; display: block; }

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

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}

.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: #ede9fe; color: var(--brand-dark); }

.sidebar .sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.locale-switch { display: flex; gap: 4px; }
.locale-switch button {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
}
.locale-switch button.active { background: var(--text); color: #fff; border-color: var(--text); }

.main-content {
  flex: 1;
  min-width: 0;
  padding: 20px 24px;
}

.page-header { margin-bottom: 18px; }
.page-header h1 { margin: 0 0 4px; font-size: 20px; }
.page-header p { margin: 0; color: var(--text-muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.grid { display: grid; gap: 14px; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 11px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--bg); color: var(--text-muted); }
.badge-success { background: #d1fae5; color: var(--dv-ready); }
.badge-danger { background: #fdeaef; color: var(--danger); }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); animation: toast-in 0.2s ease-out; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--dv-midnight), var(--dv-slate) 50%, var(--dv-violet)); }
.login-card { width: 360px; background: var(--surface); border-radius: var(--radius); padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { height: 32px; width: auto; display: block; margin: 0 0 18px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p.subtitle { margin: 0 0 24px; color: var(--text-muted); }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--text-muted); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-meta { width: 100%; background: #1877f2; border-color: #1877f2; color: #fff; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }
.login-error { background: #fdeaef; color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.login-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }
.login-footer a { color: var(--text-muted); text-decoration: none; }
.login-footer a:hover { color: var(--text); text-decoration: underline; }
.login-footer .locale-switch button { flex: none; min-width: 40px; cursor: pointer; }
@media (max-width: 420px) { .login-card { width: auto; margin: 16px; padding: 24px; } }

/* ---------- Dashboard ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 426px minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
}

.conv-list { overflow-y: auto; max-height: calc(100vh - 96px); }
.conv-item { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 8px; cursor: pointer; }
.conv-item:hover { background: var(--bg); }
.conv-item.selected { background: #ede9fe; }
.conv-avatar { width: 38px; height: 38px; border-radius: 50%; background: #d8dce1; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: var(--accent); flex-shrink: 0; }
.conv-meta { flex: 1; min-width: 0; }
.conv-name-row { display: flex; justify-content: space-between; gap: 6px; }
.conv-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.conv-dot { width: 8px; height: 8px; border-radius: 50%; background: #c9cdd3; flex-shrink: 0; }
.conv-dot.open { background: var(--brand); }
.conv-unread { background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }


.details-column { display: flex; flex-direction: column; gap: 12px; }
.details-column .card h3 { margin: 0 0 10px; font-size: 13px; }
.details-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
.details-row span:first-child { color: var(--text-muted); }
.ai-placeholder { text-align: center; color: var(--text-muted); font-size: 12px; padding: 18px 8px; }

/* ---------- Media grid ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.media-card .thumb { height: 110px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-card .meta { padding: 8px; }
.media-card .meta .title { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.media-card .meta .cat { font-size: 11px; color: var(--text-muted); }
.media-card .actions { display: flex; justify-content: flex-end; padding: 6px 8px; gap: 6px; }

.record-btn { width: 86px; height: 86px; border-radius: 50%; background: var(--danger); border: none; color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.record-timer { text-align: center; font-size: 20px; font-weight: 700; margin: 12px 0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 20px; width: 420px; max-width: 92vw; max-height: 86vh; overflow-y: auto; }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.token-value { font-family: monospace; font-size: 13px; background: var(--bg); padding: 8px 10px; border-radius: 6px; word-break: break-all; }

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

/* ---------- Combos ---------- */
.combo-item-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.combo-item-row { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.combo-item-icon { font-size: 18px; flex-shrink: 0; }
.combo-item-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.combo-item-preview textarea, .combo-item-preview input { width: 100%; }
.combo-item-thumb { max-width: 100%; max-height: 90px; border-radius: 6px; object-fit: cover; }
.combo-item-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.combo-add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

@media (max-width: 1000px) {
  .dashboard-grid { grid-template-columns: 1fr; height: auto; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar .sidebar-footer { flex-direction: row; border-top: none; }
}


.ai-assistant { padding: 8px 12px; border-top: 1px solid currentColor; font-size: .85rem; }
.ai-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-assistant p { margin: 4px 0; max-height: 5em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-assistant [hidden] { display: none; }

#wa-action[hidden] { display: none; }
