/**
 * ANIMA — Companion Virtual Personal | diaspora.ro
 * Copyright (c) 2026 IGNATIUC Cosmin Florian
 * Toate drepturile rezervate.
 */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #09090f;
  --surface: #111118;
  --surface2: #18181f;
  --surface3: #1f1f2a;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --accent: #7c3aed;
  --accent2: #a855f7;
  --accent3: #ec4899;
  --accent4: #f59e0b;
  --green: #10b981;
  --blue: #3b82f6;
  --text: #f0eeff;
  --text2: #c4b5fd;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --glow: 0 0 40px rgba(124,58,237,0.25);
  --glow2: 0 0 20px rgba(236,72,153,0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --surface2: #ede9fe;
  --surface3: #ddd6fe;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.14);
  --text: #1e1b4b;
  --text2: #5b21b6;
  --muted: #6b7280;
  --muted2: #4b5563;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.3); border-radius: 3px; }

/* ── Header ──────────────────────────────────────── */
.anima-header {
  position: sticky; top: 0; z-index: 200;
  background: rgba(9,9,15,0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  height: 60px;
}

.anima-logo {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900; font-size: 1.35rem;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #7c3aed 0%, #ec4899 60%, #f59e0b 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex; flex-direction: column;
}

.anima-logo small {
  font-size: 0.55rem; letter-spacing: 1px; font-family: 'Inter', sans-serif;
  -webkit-text-fill-color: var(--muted); color: var(--muted); font-weight: 400;
  margin-top: -3px;
}

.header-actions { display: flex; gap: 10px; align-items: center; }

.btn-icon {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border2); background: var(--surface2);
  color: var(--muted2); cursor: pointer; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover { color: var(--text); border-color: var(--accent); }

.back-link {
  font-size: 0.8rem; color: var(--muted); text-decoration: none;
  display: flex; align-items: center; gap: 4px; transition: var(--transition);
}
.back-link:hover { color: var(--text2); }

/* ── Layout ──────────────────────────────────────── */
.anima-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 60px);
}

/* ── Sidebar ─────────────────────────────────────── */
.anima-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  padding: 16px 14px;
  gap: 12px;
}

/* Avatar block */
.avatar-block {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  position: relative; overflow: hidden;
}

.avatar-block::before {
  content: '';
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  width: 100px; height: 100px;
  background: radial-gradient(circle, rgba(124,58,237,0.25) 0%, transparent 70%);
}

.avatar-ring {
  width: 82px; height: 82px; border-radius: 50%;
  background: conic-gradient(#7c3aed, #ec4899, #f59e0b, #7c3aed);
  padding: 3px; animation: spin 10s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

.companion-name {
  font-family: 'Orbitron', sans-serif; font-weight: 700;
  font-size: 1rem; text-align: center; color: var(--text);
  letter-spacing: 1px;
}

.companion-stage {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 12px; border-radius: 20px;
  background: linear-gradient(135deg,rgba(124,58,237,.18),rgba(236,72,153,.18));
  border: 1px solid rgba(124,58,237,0.3);
  color: var(--accent2);
}

/* XP */
.xp-wrap { width: 100%; }
.xp-header {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--muted); margin-bottom: 5px;
}
.xp-track {
  height: 5px; background: var(--border2);
  border-radius: 3px; overflow: hidden;
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #ec4899);
  border-radius: 3px; transition: width 0.6s ease;
}

/* Stats grid */
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; width: 100%; }
.stat-box {
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 4px; text-align: center;
}
.stat-val { font-family: 'Orbitron', sans-serif; font-size: 1rem; font-weight: 700; color: var(--accent2); }
.stat-lbl { font-size: 0.58rem; color: var(--muted); margin-top: 2px; }

/* Nav */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 0.65rem; font-weight: 600; letter-spacing: 1.5px; color: var(--muted); padding: 4px 8px; text-transform: uppercase; }

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: none; background: transparent;
  color: var(--muted2); cursor: pointer;
  font-size: 0.83rem; font-family: 'Inter', sans-serif;
  transition: var(--transition); text-align: left; width: 100%;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active {
  background: linear-gradient(135deg,rgba(124,58,237,.15),rgba(236,72,153,.08));
  color: var(--accent2);
  border: 1px solid rgba(124,58,237,0.25);
}
.nav-icon { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.65rem; color: var(--muted); line-height: 1.6; text-align: center;
}

/* ── Main ────────────────────────────────────────── */
.anima-main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.tab-panel { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.tab-panel.active { display: flex; }

/* ── Chat ────────────────────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
}

.msg { display: flex; gap: 10px; max-width: 80%; animation: msgIn .25s ease; }
@keyframes msgIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
}
.msg-av.u { background: linear-gradient(135deg, #1e40af, #3b82f6); }

.msg-bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 0.875rem; line-height: 1.55; word-break: break-word; max-width: 100%;
}
.msg.assistant .msg-bubble {
  background: var(--surface); border: 1px solid var(--border2);
  border-bottom-left-radius: 4px;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white; border-bottom-right-radius: 4px;
}

.msg-meta { font-size: 0.65rem; color: var(--muted); margin-top: 3px; text-align: right; }

/* Stage change banner */
.stage-banner {
  align-self: center;
  background: linear-gradient(135deg,rgba(124,58,237,.2),rgba(236,72,153,.2));
  border: 1px solid rgba(124,58,237,0.35);
  border-radius: 20px; padding: 8px 18px;
  font-size: 0.8rem; color: var(--accent2); text-align: center;
  animation: msgIn .3s ease;
}

/* Typing */
.typing { display: flex; gap: 4px; padding: 11px 14px; }
.t-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent2); animation: bounce 1.2s infinite; }
.t-dot:nth-child(2) { animation-delay: .2s; }
.t-dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,60%,100% { transform:translateY(0); opacity:.4; } 30% { transform:translateY(-6px); opacity:1; } }

/* Input */
.chat-input-area {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex; gap: 10px; align-items: flex-end;
}
.chat-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 14px; padding: 10px 14px;
  color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.875rem;
  resize: none; outline: none; max-height: 110px; line-height: 1.5;
  transition: border-color .2s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--muted); }

.send-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #a855f7); color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: var(--transition);
}
.send-btn:hover { transform: scale(1.05); box-shadow: var(--glow); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Memories ────────────────────────────────────── */
.memories-area { flex: 1; overflow-y: auto; padding: 20px; }
.section-title {
  font-family: 'Orbitron', sans-serif; font-size: 0.9rem;
  color: var(--accent2); margin-bottom: 16px;
}

.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-btn {
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border2);
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.75rem; font-family: 'Inter', sans-serif; transition: var(--transition);
}
.filter-btn:hover, .filter-btn.active {
  background: rgba(124,58,237,0.15); border-color: rgba(124,58,237,0.4); color: var(--accent2);
}

.memories-grid { display: grid; gap: 8px; }
.memory-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  animation: msgIn .25s ease;
  transition: var(--transition);
}
.memory-card:hover { border-color: rgba(124,58,237,0.3); }
.mem-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mem-cat {
  font-size: 0.62rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; padding: 2px 9px; border-radius: 10px;
  background: rgba(124,58,237,0.15); color: var(--accent2);
}
.mem-date { font-size: 0.68rem; color: var(--muted); margin-left: auto; }
.mem-text { font-size: 0.83rem; line-height: 1.5; color: var(--text); }
.mem-emotion { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }

/* ── Preferences ─────────────────────────────────── */
.prefs-area { flex: 1; overflow-y: auto; padding: 20px; }

.pref-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.pref-section h3 { font-size: 0.82rem; font-weight: 600; color: var(--text2); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.78rem; color: var(--muted2); margin-bottom: 6px; font-weight: 500; }
.form-input, .form-select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 9px 12px;
  color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.84rem;
  outline: none; transition: border-color .2s;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-select { appearance: none; cursor: pointer; }

.tag-input-wrap { display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 40px; cursor: text; }
.tag {
  display: flex; align-items: center; gap: 4px;
  background: rgba(124,58,237,0.18); border: 1px solid rgba(124,58,237,0.3);
  color: var(--accent2); border-radius: 14px; padding: 2px 10px;
  font-size: 0.75rem; font-weight: 500;
}
.tag-remove { cursor: pointer; color: var(--muted); transition: color .15s; line-height: 1; }
.tag-remove:hover { color: #f87171; }
.tag-bare-input { flex: 1; min-width: 80px; background: none; border: none; outline: none; color: var(--text); font-size: 0.82rem; font-family: 'Inter', sans-serif; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.toggle-lbl { font-size: 0.83rem; color: var(--text); }
.toggle-sub { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.toggle {
  position: relative; width: 40px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--surface3);
  border: 1px solid var(--border2); border-radius: 11px; cursor: pointer; transition: .3s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: white; }

.save-btn {
  width: 100%; padding: 11px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, #7c3aed, #a855f7); color: white;
  font-family: 'Inter', sans-serif; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); letter-spacing: .3px;
}
.save-btn:hover { transform: translateY(-1px); box-shadow: var(--glow); }
.save-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Stats/Evolution ─────────────────────────────── */
.stats-area { flex: 1; overflow-y: auto; padding: 20px; }

.evo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.evo-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.evo-val { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--accent2); }
.evo-lbl { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

.interests-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.interests-bar h3 { font-size: 0.82rem; color: var(--text2); margin-bottom: 14px; }
.interest-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.interest-name { font-size: 0.78rem; color: var(--muted2); width: 90px; flex-shrink: 0; }
.interest-track { flex: 1; height: 5px; background: var(--border2); border-radius: 3px; overflow: hidden; }
.interest-fill { height: 100%; background: linear-gradient(90deg, #7c3aed, #ec4899); border-radius: 3px; }
.interest-count { font-size: 0.72rem; color: var(--muted); width: 30px; text-align: right; }

.stages-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stage-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 8px; text-align: center;
}
.stage-box.current { border-color: rgba(124,58,237,0.45); background: rgba(124,58,237,0.08); }
.stage-emoji { font-size: 1.8rem; margin-bottom: 6px; }
.stage-name { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.stage-xp { font-size: 0.65rem; color: var(--muted); margin-top: 2px; }

.ethics-box {
  background: rgba(16,185,129,0.05); border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius); padding: 16px; margin-top: 12px;
}
.ethics-box h3 { font-size: 0.82rem; color: var(--green); margin-bottom: 10px; }
.ethics-box ul { list-style: none; font-size: 0.8rem; color: var(--muted2); line-height: 2; }

.copyright-box {
  margin-top: 14px; text-align: center; padding: 10px;
  font-size: 0.7rem; color: var(--muted); line-height: 1.7;
  border-top: 1px solid var(--border);
}

/* ── Setup ───────────────────────────────────────── */
.setup-wrap {
  display: flex; align-items: center; justify-content: center;
  flex: 1; padding: 24px; overflow-y: auto;
}
.setup-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 28px; width: 100%; max-width: 460px;
  display: flex; flex-direction: column; gap: 18px;
}
.setup-hero { text-align: center; }
.setup-emoji { font-size: 3rem; display: block; margin-bottom: 8px; }
.setup-title {
  font-family: 'Orbitron', sans-serif; font-size: 1.2rem; font-weight: 700;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.setup-sub { font-size: 0.82rem; color: var(--muted); margin-top: 6px; max-width: 340px; margin-inline: auto; line-height: 1.6; }

.gender-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.gender-opt {
  padding: 12px 6px; border-radius: var(--radius-sm);
  border: 2px solid var(--border2); background: var(--surface2);
  color: var(--muted); cursor: pointer; text-align: center;
  font-family: 'Inter', sans-serif; font-size: 0.78rem;
  transition: var(--transition);
}
.gender-opt .g-em { font-size: 1.4rem; display: block; margin-bottom: 4px; }
.gender-opt:hover, .gender-opt.sel {
  border-color: var(--accent); background: rgba(124,58,237,0.1); color: var(--accent2);
}

.stages-info {
  background: rgba(124,58,237,0.06); border: 1px solid rgba(124,58,237,0.18);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 0.78rem; color: var(--muted); line-height: 1.8;
}
.stages-info strong { color: var(--accent2); }

.primary-btn {
  padding: 12px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white; font-family: 'Inter', sans-serif; font-size: 0.9rem;
  font-weight: 600; cursor: pointer; transition: var(--transition); letter-spacing: .4px;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: var(--glow); }
.primary-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.setup-note { font-size: 0.72rem; color: var(--muted); text-align: center; line-height: 1.6; }
.setup-note a { color: var(--accent2); text-decoration: none; }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  padding: 11px 18px; background: var(--surface);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  font-size: 0.83rem; box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: toastIn .28s ease; pointer-events: none;
}
@keyframes toastIn { from { transform:translateX(80px); opacity:0; } to { transform:translateX(0); opacity:1; } }
.toast.success { border-color: rgba(16,185,129,.4); color: var(--green); }
.toast.error { border-color: rgba(239,68,68,.4); color: #f87171; }
.toast.info { border-color: rgba(124,58,237,.4); color: var(--accent2); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 860px) {
  .anima-layout { grid-template-columns: 1fr; }
  .anima-sidebar { display: none; }
  .anima-sidebar.mob-open {
    display: flex; position: fixed;
    top: 60px; left: 0; right: 0; bottom: 0; z-index: 150; width: 100%;
  }
  .mob-menu-btn { display: flex; }
  .back-link span { display: none; }
}
