/* ============================================
   Persona — Main Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600&family=DM+Sans:wght@300;400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0c0c0e;
  --bg2:     #131316;
  --bg3:     #1a1a1f;
  --bg4:     #222228;
  --accent:  #e8c97e;
  --accent2: #c9a85c;
  --text:    #f0ede8;
  --muted:   #7a7570;
  --border:  rgba(232,201,126,0.13);
  --r:       10px;
  --sidebar: 256px;
  --imgpanel: 340px;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT ── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  grid-column: 1 / -1;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 19px;
  letter-spacing: 1px;
  color: var(--accent);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.conn-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.conn-pill:hover { border-color: var(--accent); color: var(--text); }
.conn-pill.icon-only { padding: 5px 10px; }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s;
}
.dot.ok  { background: #4ade80; }
.dot.err { background: #f87171; }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); }

.s-sec {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
}

.s-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* character cards */
.char-card {
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg3);
  padding: 10px 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.char-card:hover  { background: var(--bg4); border-color: var(--accent); }
.char-card.active { background: rgba(232,201,126,0.07); border-color: var(--accent); }

.char-emo {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg4);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
  transition: border-color 0.15s;
}
.char-card.active .char-emo { border-color: var(--accent); }

.char-nm   { font-size: 13px; font-weight: 500; }
.char-ps   { font-size: 11px; color: var(--muted); }
.char-seed { font-size: 10px; color: var(--accent); margin-top: 2px; font-family: monospace; }

.char-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.char-card:hover .char-actions { opacity: 1; }
.char-del {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer; font-size: 14px;
  padding: 2px 4px; border-radius: 4px;
  transition: color 0.15s;
}
.char-del:hover { color: #f87171; }

.add-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color 0.15s, color 0.15s;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* pose buttons */
.pose-btn {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
}
.pose-btn:hover,
.pose-btn.active {
  background: rgba(232,201,126,0.08);
  border-color: var(--accent);
  color: var(--accent);
}
.pose-btn i { font-size: 14px; flex-shrink: 0; }

/* ── MAIN GRID ── */
.main {
  display: grid;
  grid-template-columns: var(--imgpanel) 1fr;
  overflow: hidden;
}

/* ── IMAGE PANEL ── */
.img-panel {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.img-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.img-scroll::-webkit-scrollbar { width: 3px; }
.img-scroll::-webkit-scrollbar-thumb { background: var(--border); }

.portrait-frame {
  width: 240px; height: 320px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg3);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.portrait-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 11px;
}

.img-placeholder {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  color: var(--muted);
}
.img-placeholder i    { font-size: 36px; opacity: 0.3; }
.img-placeholder span { font-size: 12px; }

.gen-overlay {
  position: absolute; inset: 0;
  background: rgba(12,12,14,0.88);
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; border-radius: 11px;
}
.gen-overlay.show { display: flex; }

.spinner {
  width: 30px; height: 30px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-lbl {
  font-size: 11px;
  color: var(--accent);
  text-align: center;
  padding: 0 16px;
  line-height: 1.5;
}

/* seed row */
.seed-row {
  width: 240px;
  display: flex; justify-content: space-between; align-items: center;
}
.seed-info { font-size: 10px; color: var(--muted); font-family: monospace; }
.lock-btn {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer; font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  display: flex; align-items: center; gap: 4px;
  transition: color 0.2s;
  padding: 0;
}
.lock-btn:hover  { color: var(--accent); }
.lock-btn.locked { color: var(--accent); }

/* field blocks */
.field-block { width: 240px; }
.field-label {
  display: block;
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}

textarea, input[type="text"], input[type="number"], select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
textarea::placeholder, input::placeholder { color: var(--muted); }
textarea { resize: none; line-height: 1.5; }
select option { background: var(--bg2); }

/* gen controls */
.gen-row {
  width: 240px;
  display: flex; gap: 8px;
}
.btn-generate {
  flex: 1;
  background: var(--accent);
  color: #0c0c0e;
  border: none; border-radius: 8px;
  padding: 9px;
  font-size: 13px; font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.2s;
}
.btn-generate:hover    { background: var(--accent2); }
.btn-generate:disabled { background: var(--bg4); color: var(--muted); cursor: not-allowed; }

.icon-btn {
  width: 37px; height: 37px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer; color: var(--muted); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* prompt preview */
.prompt-preview-box {
  width: 240px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 11px;
}
.prompt-text {
  font-size: 10px; color: var(--muted);
  line-height: 1.6; font-family: monospace;
  word-break: break-word;
}

/* ── GALLERY STRIP ── */
.gallery-strip {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.gal-label {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.gal-row {
  display: flex; gap: 7px;
  overflow-x: auto; padding-bottom: 2px;
}
.gal-row::-webkit-scrollbar { height: 2px; }
.gal-row::-webkit-scrollbar-thumb { background: var(--border); }

.gal-thumb {
  width: 52px; height: 68px;
  border-radius: 6px; flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg3);
  overflow: hidden; cursor: pointer;
  transition: border-color 0.2s;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 16px;
}
.gal-thumb:hover { border-color: var(--accent); }
.gal-thumb img   { width: 100%; height: 100%; object-fit: cover; }
.gal-thumb.empty { cursor: default; }

/* ── CHAT PANEL ── */
.chat-panel {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat-hdr {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.chat-av {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(232,201,126,0.1);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.chat-nm { font-size: 14px; font-weight: 500; }
.chat-ps { font-size: 11px; color: var(--muted); }

.online-ind {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: #4ade80;
  margin-left: auto;
}
.online-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

.msgs {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.msgs::-webkit-scrollbar { width: 3px; }
.msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg {
  max-width: 82%;
  padding: 9px 13px;
  font-size: 13px; line-height: 1.6;
  animation: fup 0.2s ease;
}
@keyframes fup {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.ai {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 3px;
  align-self: flex-start;
}
.msg.user {
  background: rgba(232,201,126,0.08);
  border: 1px solid rgba(232,201,126,0.18);
  border-radius: 12px 12px 3px 12px;
  align-self: flex-end;
}
.msg-who { font-size: 10px; color: var(--muted); margin-bottom: 3px; letter-spacing: 0.5px; }

.typing { display: flex; gap: 4px; align-items: center; padding: 3px 0; }
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: bop 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bop {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

.chat-input-row {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  display: flex; gap: 8px; align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  max-height: 90px; min-height: 36px;
}
.send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--accent); border: none; border-radius: 8px;
  cursor: pointer; color: #0c0c0e; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.send-btn:hover    { background: var(--accent2); }
.send-btn:disabled { background: var(--bg4); color: var(--muted); cursor: not-allowed; }

/* ── MODALS ── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 480px; max-width: 100%;
  max-height: 88vh; overflow-y: auto;
}
.modal::-webkit-scrollbar { width: 3px; }
.modal::-webkit-scrollbar-thumb { background: var(--border); }

.modal h3 {
  font-family: 'Playfair Display', serif;
  font-size: 17px; color: var(--accent);
  margin-bottom: 18px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.hint code {
  font-family: monospace; font-size: 11px;
  background: var(--bg4); border-radius: 3px;
  padding: 1px 5px; color: var(--text);
}

.section-divider {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin: 16px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}

.modal-acts {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 18px;
}
.btn-sec {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 16px;
  color: var(--muted); cursor: pointer;
  font-size: 13px; font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s, color 0.15s;
}
.btn-sec:hover { border-color: var(--accent); color: var(--accent); }
.btn-pri {
  background: var(--accent); color: #0c0c0e;
  border: none; border-radius: 8px;
  padding: 7px 16px; cursor: pointer;
  font-size: 13px; font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s;
}
.btn-pri:hover { background: var(--accent2); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px;
  font-size: 13px; color: var(--text);
  z-index: 999; opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: #4ade80; color: #4ade80; }
.toast.error   { border-color: #f87171; color: #f87171; }
