/* ── Theme Generator app — component styles only ──────────────────────────── */
/* Colour system, fonts and nav/footer come from the shared style.css          */
/* (JabJabWeb). Page-shell components (.site-main, .card, .btn-secondary,     */
/* .form-group, etc.) are re-declared per-app, same convention stickers.css   */
/* and blog use — this file follows it exactly for the same reason: each app  */
/* is a standalone FastAPI mount, not a shared component bundle.              */

:root {
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

/* ── Background glow (matches xmpp.tel hero) ─────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 70% 20%, rgba(124,58,237,.15) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 20% 80%, rgba(99,102,241,.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Page layout ──────────────────────────────────────────────────────────── */
.site-main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.footer, .dedication { position: relative; z-index: 1; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-header > div { flex: 1; min-width: 0; }
.page-header h1 { font-size: 1.8rem; margin-bottom: .25rem; }
.page-subtitle { color: var(--text-muted); font-size: .9rem; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.muted-inline { font-weight: 400; color: var(--text-muted); font-size: .8rem; }

/* ── Buttons (secondary/ghost — .btn/.btn-primary come from shared style.css) */
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; padding: .7rem 1.6rem; border-radius: var(--radius-md);
  font-size: .95rem; font-weight: 600; white-space: nowrap; min-height: 44px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  cursor: pointer;
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-secondary:disabled { opacity: .6; cursor: default; }

.btn-ghost {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 8px 16px; font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: border-color .2s, color .2s, background .2s;
}
.btn-ghost:hover { border-color: rgba(124,58,237,.4); color: var(--text); background: var(--surface-2); }

/* ── Controls row (preset / name / reset) ────────────────────────────────── */
.controls-card { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.field-select, .field-text {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: .875rem;
}
.field-select:focus, .field-text:focus { outline: none; border-color: var(--accent); }
.field-text { width: 160px; }

/* ── Forms (submit card) ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .3rem; color: var(--text); }
.form-group input[type="text"] {
  width: 100%; max-width: 380px; padding: .55rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
  font-size: .95rem; font-family: inherit; transition: border-color .2s;
}
.form-group input[type="text"]:focus { outline: none; border-color: var(--accent); }
.required { color: #f87171; }
.form-actions { display: flex; gap: .75rem; margin-top: .25rem; flex-wrap: wrap; }
.token-hint { font-size: .875rem; color: var(--text-muted); margin-bottom: .75rem; }

.error-message { background: rgba(220,38,38,.12); color: #fca5a5; border: 1px solid rgba(220,38,38,.4); border-radius: var(--radius-sm); padding: .6rem 1rem; font-size: .875rem; margin-bottom: .75rem; }
.success-message { background: rgba(16,185,129,.1); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); border-radius: var(--radius-sm); padding: .6rem 1rem; font-size: .875rem; margin-bottom: .75rem; }

/* ── Error page (matches stickers/blog convention) ───────────────────────── */
.error-page { text-align: center; padding: 5rem 1rem; }
.error-code { font-size: 6rem; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: .5rem; }
.error-detail { font-size: 1.2rem; color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Mockup previews ──────────────────────────────────────────────────────── */
.previews { display: flex; gap: 3.5rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1.25rem; }
.preview-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mode-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }

.phone-wrap { position: relative; }
.phone-glow {
  position: absolute; inset: -34px;
  background: radial-gradient(circle, rgba(124,58,237,.35) 0%, transparent 70%);
  filter: blur(32px); z-index: 0; pointer-events: none;
}
.phone {
  position: relative; z-index: 1;
  width: 280px; border-radius: 36px;
  background: #0a0a14; border: 2px solid #2a2a3e;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.04) inset, 0 1px 0 rgba(255,255,255,.08) inset;
  overflow: hidden;
}
.phone::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 92px; height: 22px; background: #0a0a14; border-radius: 0 0 16px 16px; z-index: 10;
}

.p-statusbar { height: 30px; padding: 0 20px 6px; display: flex; align-items: flex-end; justify-content: space-between; }
.p-statusbar .time { font-size: 11px; font-weight: 600; }
.p-statusbar .dots { font-size: 9px; letter-spacing: 1px; opacity: .8; }

.p-toolbar { padding: 8px 14px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid; }

.tappable { cursor: pointer; transition: filter .15s, box-shadow .15s; position: relative; }
.tappable:hover { filter: brightness(1.08); }
.tappable:focus-visible, .tappable.is-active-target {
  box-shadow: 0 0 0 2px var(--bg, #0F172A), 0 0 0 4px var(--accent);
}

.back.tappable { font-size: 17px; line-height: 1; border-radius: 6px; padding: 2px 4px; }
.p-avatar.tappable {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.p-toolbar .title { font-size: 13px; font-weight: 700; letter-spacing: -.01em; }
.p-toolbar .subtitle { font-size: 10px; display: flex; align-items: center; gap: 4px; }
.p-toolbar .subtitle::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--success); display: block; }

.p-chat { padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 6px; min-height: 400px; }

.bubble.tappable { max-width: 76%; padding: 7px 11px; border-radius: 15px; font-size: 11px; line-height: 1.4; }
.bubble.r { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.s { align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .meta { font-size: 9px; opacity: .55; text-align: right; margin-top: 3px; }
.bubble .msg-text.tappable { border-radius: 4px; }
.bubble .msg-text.tappable:hover { filter: brightness(1.25); }

.p-bottom { display: flex; align-items: center; gap: 8px; padding: 8px 12px 14px; }
.p-input-field.tappable { flex: 1; border-radius: 20px; padding: 7px 13px; font-size: 11px; }
.p-input-field .placeholder-text.tappable:hover { filter: brightness(1.25); }
.p-send-btn.tappable {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.p-send-btn .send-icon.tappable { border-radius: 50%; }

/* ── Overflow tokens strip ────────────────────────────────────────────────── */
.overflow-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.overflow-item { display: flex; align-items: center; gap: 6px; }
.overflow-item .token-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.mini-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.mini-swatch:hover { transform: scale(1.15); box-shadow: 0 0 0 3px rgba(124,58,237,.25); }
.mini-swatch.is-active-target { box-shadow: 0 0 0 3px var(--accent); }

/* ── XML panel ────────────────────────────────────────────────────────────── */
.xml-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.xml-header h2 { margin-bottom: 0; }
.xml-scroll { background: var(--bg, #0F172A); border: 1px solid var(--border); border-radius: var(--radius-sm); }
#out_all {
  display: block;
  width: 100%; height: 220px; min-height: 100%; padding: 12px 16px;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.8;
  color: #a5d6a7; background: transparent; border: none; resize: none; outline: none;
  white-space: pre; box-sizing: border-box; overflow: auto;
}
.copy-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 16px;
  font-size: .8rem; font-weight: 600; cursor: pointer; transition: border-color .2s;
}
.copy-btn:hover { border-color: rgba(124,58,237,.45); }
.copy-btn.ok { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.4); color: #6ee7b7; }

/* ── Color picker popover ─────────────────────────────────────────────────── */
.picker-popover {
  position: fixed; z-index: 1000; width: 268px;
  background: var(--surface);
  border: 1px solid rgba(124,58,237,.4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(124,58,237,.08), 0 0 24px rgba(124,58,237,.18);
  padding: 14px;
  display: none;
  animation: themePopIn .12s cubic-bezier(.2,1,.3,1);
  max-width: calc(100vw - 24px);
}
.picker-popover.is-open { display: block; }
@keyframes themePopIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.picker-token-name {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  margin-bottom: 10px; word-break: break-word;
}

.picker-sv-wrap { position: relative; width: 100%; height: 130px; border-radius: 8px; overflow: hidden; cursor: crosshair; }
#svCanvas { display: block; width: 100%; height: 100%; }
.picker-cursor {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 1px 4px rgba(0,0,0,.4);
  transform: translate(-50%, -50%); pointer-events: none;
}
.picker-hue-wrap { position: relative; width: 100%; height: 14px; margin-top: 10px; border-radius: 99px; overflow: hidden; cursor: pointer; }
#hueCanvas { display: block; width: 100%; height: 100%; }
.picker-hue-cursor {
  position: absolute; top: -2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,.3); box-shadow: 0 1px 4px rgba(0,0,0,.4);
  transform: translateX(-50%); pointer-events: none;
}
.picker-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.picker-swatch-preview { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.15); }
.picker-hex-field { flex: 1; min-width: 0; display: flex; align-items: center; background: var(--bg, #0F172A); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 10px; }
.picker-hex-field span { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }
.picker-hex-field input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
  padding: 8px 0 8px 2px; text-transform: uppercase; letter-spacing: .03em;
}
.picker-eyedropper {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-sm);
  background: var(--bg, #0F172A); border: 1px solid var(--border); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .2s, color .2s, background .2s;
}
.picker-eyedropper:hover { border-color: var(--accent); color: var(--accent); background: rgba(124,58,237,.1); }
.picker-eyedropper svg { width: 16px; height: 16px; }
.picker-recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.picker-recent-chip { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); cursor: pointer; transition: transform .12s; }
.picker-recent-chip:hover { transform: scale(1.15); }
.picker-recent-empty { font-size: 10px; color: var(--text-dim); opacity: .6; }

/* ── Theme XML + Submit side-by-side row ─────────────────────────────────── */
.xml-submit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: stretch;
}
.xml-submit-row .card { margin-bottom: 0; display: flex; flex-direction: column; height: 100%; }
.xml-submit-row .xml-panel .xml-scroll { flex: 1; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .previews { flex-direction: column; gap: 2.5rem; }
  .xml-submit-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .phone { width: 240px; }
  .field-text { width: 120px; }
}
@media (max-width: 380px) {
  .phone { width: 210px; }
}
