/* Light Up Media Portal — clean modern light theme. Self-contained, no external CSS. */

:root {
  --primary: #2563EB;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --bg: #f6f8fb;
  --bg-card: #ffffff;
  --bg-muted: #f1f5f9;
  --bg-hover: #f8fafc;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --error: #dc2626;
  --error-soft: #fef2f2;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --nav-h: 60px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ── Brand logo (text wordmark) ── */
.brand-logo {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--primary);
  white-space: nowrap;
}
.brand-logo::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  vertical-align: middle;
}
.brand-logo-lg { font-size: 22px; }

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

.top-nav {
  height: var(--nav-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-left { display: flex; align-items: center; }
.nav-logo { display: flex; align-items: center; }
.nav-logo:hover { text-decoration: none; }
.nav-logo .brand-logo { font-size: 18px; }

.nav-center { flex: 1; display: flex; }
.nav-items { display: flex; gap: var(--space-2); }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-base);
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-muted); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item-icon { display: inline-flex; }
.nav-item-icon svg { width: 18px; height: 18px; }

.nav-right { display: flex; align-items: center; position: relative; }
.nav-user { position: relative; }
.nav-user-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-family: inherit;
}
.nav-user-btn:hover { background: var(--bg-muted); }
.nav-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--text-sm);
}
.nav-user-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.nav-user-name { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.nav-user-loc { font-size: var(--text-xs); color: var(--text-muted); }
.nav-user-chevron svg { width: 16px; height: 16px; color: var(--text-muted); }

.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: 60;
}
.nav-dropdown-header { padding: var(--space-2) var(--space-3); }
.nav-dropdown-name { font-weight: 600; font-size: var(--text-sm); }
.nav-dropdown-loc { font-size: var(--text-xs); color: var(--text-muted); }
.nav-dropdown-divider { height: 1px; background: var(--border); margin: var(--space-2) 0; }
.nav-dropdown-item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none; background: none;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: var(--text-sm);
  color: var(--text); text-align: left; cursor: pointer;
}
.nav-dropdown-item:hover { background: var(--bg-muted); text-decoration: none; }
.nav-dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }

.nav-hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--text); }

.main-content { flex: 1; }
.content-body { max-width: 1180px; margin: 0 auto; padding: var(--space-8) var(--space-6); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-title { font-size: var(--text-xl); }
.page-subtitle { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-4); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-muted); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--error); border-color: var(--border); }
.btn-danger:hover { background: var(--error-soft); border-color: var(--error); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-muted); }
.btn-sm { padding: 6px 11px; font-size: var(--text-sm); }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ── Forms ── */
.field { margin-bottom: var(--space-4); }
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}
.field-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }
.input, .textarea, .select {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.input-color { padding: 4px; height: 38px; width: 56px; cursor: pointer; }
.input-with-color { display: flex; gap: var(--space-2); align-items: center; }
.input-with-color .input { flex: 1; }

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 38px; height: 22px;
  background: var(--border-strong);
  border-radius: 11px;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff; border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle-label { font-size: var(--text-sm); }

/* ── Sections / fieldsets in editor ── */
.editor-section { margin-bottom: var(--space-6); }
.editor-section-title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.field-row { display: flex; gap: var(--space-3); }
.field-row > * { flex: 1; }

.locked-note {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); color: var(--text-faint);
  background: var(--bg-muted); padding: 2px 8px; border-radius: 20px;
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: 600;
  padding: 2px 9px; border-radius: 20px;
  background: var(--bg-muted); color: var(--text-muted);
}
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--bg-muted); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }

/* ── Tabs ── */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); }
.tab {
  padding: var(--space-3) var(--space-4);
  border: none; background: none;
  border-bottom: 2px solid transparent;
  font-family: inherit; font-size: var(--text-sm); font-weight: 500;
  color: var(--text-muted); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── List rows (forms, templates) ── */
.list-row {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  margin-bottom: var(--space-3);
}
.list-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-weight: 600; font-size: var(--text-base); display: flex; align-items: center; gap: var(--space-2); }
.list-row-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.list-row-actions { display: flex; gap: var(--space-2); align-items: center; flex-shrink: 0; }
.url-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--mono); font-size: var(--text-xs);
  background: var(--bg-muted); padding: 3px 8px; border-radius: var(--radius-sm);
  color: var(--text-muted); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.group-title { font-size: var(--text-sm); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: var(--space-6) 0 var(--space-3); }
.group-title:first-child { margin-top: 0; }

/* ── Split editor layout ── */
.split-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.split-pane { min-width: 0; }
.split-pane-config { max-height: calc(100vh - 180px); overflow-y: auto; padding-right: var(--space-2); }
.preview-frame-wrap {
  position: sticky; top: calc(var(--nav-h) + var(--space-5));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.preview-frame-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
  font-size: var(--text-xs); color: var(--text-muted);
}
.preview-frame { width: 100%; height: calc(100vh - 240px); border: none; display: block; background: #fff; }

/* ── Chat (AI editor / Pluto) ── */
.chat-panel { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); overflow: hidden; }
.chat-head { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--bg-muted); display: flex; align-items: center; justify-content: space-between; }
.chat-head-title { font-weight: 600; font-size: var(--text-sm); }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); min-height: 200px; }
.chat-bubble { max-width: 85%; padding: var(--space-3) var(--space-4); border-radius: var(--radius); font-size: var(--text-sm); line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.chat-bubble-user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble-assistant { align-self: flex-start; background: var(--bg-muted); color: var(--text); border-bottom-left-radius: 3px; }
.chat-bubble strong { font-weight: 600; }
.chat-thinking { align-self: flex-start; color: var(--text-muted); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); }
.chat-input-row { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--border); background: var(--bg-card); }
.chat-input { flex: 1; resize: none; min-height: 40px; max-height: 120px; }
.chat-actions { display: flex; gap: var(--space-2); padding: 0 var(--space-3) var(--space-3); }

.dot-pulse { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: dot-pulse 1s infinite ease-in-out; }
@keyframes dot-pulse { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.changed-paths { font-size: var(--text-xs); color: var(--text-muted); padding: var(--space-2) var(--space-3); background: var(--primary-soft); border-radius: var(--radius-sm); margin: var(--space-2) 0; }
.changed-paths code { font-family: var(--mono); color: var(--primary); }

/* ── Collapsible panel ── */
.collapsible { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-4); overflow: hidden; }
.collapsible-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4); cursor: pointer; background: var(--bg-card);
  font-weight: 600; font-size: var(--text-sm); user-select: none;
}
.collapsible-head:hover { background: var(--bg-hover); }
.collapsible-head .chevron { transition: transform 0.15s; color: var(--text-muted); }
.collapsible.open .collapsible-head .chevron { transform: rotate(90deg); }
.collapsible-body { display: none; padding: var(--space-4); border-top: 1px solid var(--border); }
.collapsible.open .collapsible-body { display: block; }

/* ── Versions / submissions tables ── */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.03em; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.data-table td { padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }

/* ── Skeleton loaders ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, #e9eef5 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-row { height: 64px; margin-bottom: var(--space-3); }
.skeleton-line { height: 14px; margin-bottom: var(--space-2); }

/* ── Empty states ── */
.empty-state { text-align: center; padding: var(--space-8) var(--space-6); color: var(--text-muted); }
.empty-state-icon { width: 48px; height: 48px; margin: 0 auto var(--space-4); color: var(--text-faint); }
.empty-state-title { font-size: var(--text-lg); font-weight: 600; color: var(--text); margin-bottom: var(--space-2); }
.empty-state-desc { font-size: var(--text-sm); max-width: 420px; margin: 0 auto var(--space-5); }

/* ── Toast / banners ── */
.toast-wrap { position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 9999; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  min-width: 240px; max-width: 380px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--text); color: #fff;
  font-size: var(--text-sm); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: var(--space-2);
  animation: toast-in 0.18s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.banner { padding: var(--space-3) var(--space-4); border-radius: var(--radius); font-size: var(--text-sm); margin-bottom: var(--space-4); }
.banner-error { background: var(--error-soft); color: var(--error); border: 1px solid #fecaca; }
.banner-warn { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }
.banner-info { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-border); }
.banner-success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.banner ul { margin: var(--space-2) 0 0; padding-left: var(--space-5); }

/* ── Standalone (no-shell) message — used when iframe has no session ── */
.standalone-msg {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: var(--space-8); text-align: center;
}
.standalone-card { max-width: 440px; }
.standalone-card .brand-logo { font-size: 24px; margin-bottom: var(--space-5); display: inline-block; }
.standalone-card h2 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
.standalone-card p { color: var(--text-muted); font-size: var(--text-base); }

/* ── Login page ── */
.login-body { background: var(--bg); }
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--space-4); }
.login-card { width: 100%; max-width: 440px; text-align: center; }
.login-brand { margin-bottom: var(--space-6); }
.login-title { font-size: var(--text-xl); margin-bottom: var(--space-4); }
.login-text { color: var(--text); font-size: var(--text-base); margin: 0 0 var(--space-4); }
.login-text:last-child { margin-bottom: 0; }

/* ── Auth-expired overlay ── */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.overlay .card { max-width: 360px; text-align: center; }

/* ── Spinner ── */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 900px) {
  .split-editor { grid-template-columns: 1fr; }
  .preview-frame-wrap { position: static; }
  .preview-frame { height: 520px; }
  .split-pane-config { max-height: none; overflow: visible; }
}
@media (max-width: 720px) {
  .top-nav { padding: 0 var(--space-4); gap: var(--space-3); }
  .nav-hamburger { display: block; order: -1; }
  .nav-center {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: var(--space-3); display: none;
    box-shadow: var(--shadow);
  }
  .nav-center.nav-center-open { display: flex; }
  .nav-items { flex-direction: column; width: 100%; }
  .nav-item { width: 100%; }
  .nav-user-info { display: none; }
  .content-body { padding: var(--space-5) var(--space-4); }
  .list-row { flex-wrap: wrap; }
  .list-row-actions { width: 100%; justify-content: flex-end; }
}
