/* ════════════════════════════════
   CRYSTAL AI SYSTEMS — MAIN CSS
   Font: Space Grotesk + Syne
   Core: variables, reset, base, buttons, sections, modal, badge, toast, chat, newsletter
════════════════════════════════ */

:root {
  --bg0: #010108;
  --bg1: #05050f;
  --bg2: #0a0a1a;
  --bg3: #0e0e22;
  --bg4: #12122a;
  --blue: #00d4ff;
  --purple: #8b5cf6;
  --violet: #7c3aed;
  --pink: #ec4899;
  --green: #22c55e;
  --gold: #f6c90e;
  --red: #ef4444;
  --ab: rgba(0,212,255,.1);
  --ap: rgba(139,92,246,.1);
  --b1: rgba(255,255,255,.06);
  --b2: rgba(0,212,255,.25);
  --b3: rgba(139,92,246,.25);
  --t1: #f0f4ff;
  --t2: #8892b0;
  --t3: #4a5568;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 8px 32px rgba(0,0,0,.5);
  --font-head: 'Syne', sans-serif;
  --font-body: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── LIGHT THEME OVERRIDES ── */
body.light-theme {
  --bg0: #f4f6ff;
  --bg1: #eceffe;
  --bg2: #e2e6fa;
  --bg3: #d8dcf5;
  --bg4: #cdd2ef;
  --b1: rgba(0,0,0,.09);
  --b2: rgba(0,100,210,.22);
  --b3: rgba(100,0,200,.22);
  --t1: #0a0a2a;
  --t2: #353a60;
  --t3: #6a7090;
  --ab: rgba(0,100,210,.08);
  --ap: rgba(100,0,200,.08);
  --shadow: 0 8px 32px rgba(0,0,50,.12);
}
body.light-theme nav {
  background: rgba(235,238,255,.92);
  border-bottom-color: var(--b1);
}
body.light-theme .mob-nav { background: var(--bg1); color: var(--t1); }
body.light-theme .mob-nav a { color: var(--t1) !important; }
body.light-theme ::-webkit-scrollbar-track { background: var(--bg1); }

/* Light theme — cards, panels, inputs */
body.light-theme .login-card,
body.light-theme .admin-card,
body.light-theme .post-card,
body.light-theme .feed-user-card,
body.light-theme .prod-card,
body.light-theme .sidebar-widget {
  background: #fff;
  border-color: rgba(0,0,150,.12);
  color: var(--t1);
}
body.light-theme .login-card input,
body.light-theme .login-card textarea,
body.light-theme .login-card select,
body.light-theme .form-field input,
body.light-theme .form-field textarea,
body.light-theme .form-field select,
body.light-theme .post-textarea,
body.light-theme .comment-input {
  background: #fff;
  color: var(--t1);
  border-color: rgba(0,0,150,.15);
}
body.light-theme .login-title { color: var(--t1); }
body.light-theme .login-sub   { color: var(--t2); }
body.light-theme .admin-sidebar { background: var(--bg1); border-color: var(--b1); }
body.light-theme .admin-panel { background: transparent; }
body.light-theme .modal-box { background: #fff; color: var(--t1); }
body.light-theme .modal-box input,
body.light-theme .modal-box textarea,
body.light-theme .modal-box select {
  background: var(--bg2); color: var(--t1); border-color: var(--b1);
}
body.light-theme .divider { color: var(--t3); }
body.light-theme .divider::before,
body.light-theme .divider::after { background: var(--b1); }
body.light-theme .btn-ghost { border-color: var(--b2); color: var(--t2); }
body.light-theme .btn-ghost:hover { background: var(--bg2); }
body.light-theme .post-act-btn { color: var(--t2); }
body.light-theme .post-act-btn:hover { background: var(--bg2); color: var(--t1); }
body.light-theme .comment-bubble { background: var(--bg2); }
body.light-theme .feed-right,
body.light-theme .feed-left { color: var(--t1); }
body.light-theme .trending-item { border-color: var(--b1); }
body.light-theme .admin-row { background: #fff; border-color: rgba(0,0,150,.1); }
body.light-theme .admin-stat-card { background: #fff; border-color: rgba(0,0,150,.1); }
body.light-theme .prod-cat-btn { background: var(--bg2); color: var(--t2); border-color: var(--b1); }
body.light-theme .prod-cat-btn.active { background: var(--violet); color: #fff; }
body.light-theme .email-domain-drop { background: #fff; border-color: rgba(0,0,150,.15); }
body.light-theme .email-domain-opt:hover { background: var(--bg2); }
body.light-theme .email-split-wrap { border-color: rgba(0,0,150,.15); background: #fff; }
body.light-theme .email-user-input { color: var(--t1); }
body.light-theme .email-domain-selected { color: var(--t1); }

/* ── Light theme — Logo fix (white text invisible on light bg) ── */
body.light-theme .logo-crystal {
  background: linear-gradient(135deg, #0a0a2a 30%, var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body.light-theme .logo-ai {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Light theme — Hero title fix ── */
body.light-theme .hero-title .line1 {
  background: linear-gradient(135deg, #0a0a2a 30%, var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body.light-theme .hero-title .line2 {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg0);
  color: var(--t1);
  overflow-x: hidden;
  font-size: 15px;
  line-height: 1.6;
}
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg0); }
::-webkit-scrollbar-thumb { background: var(--violet); border-radius: 2px; }

/* ── BUTTONS ── */
.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--blue));
  border: none;
  color: #fff;
  padding: 0.45rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.25s;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--b2);
  color: var(--blue);
  padding: 0.45rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.25s;
}
.btn-ghost:hover { background: var(--ab); }
.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.76rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  border: none;
}
.btn-sm.pri { background: linear-gradient(135deg, var(--violet), var(--blue)); color: #fff; }
.btn-sm.pri:hover { opacity: 0.88; }
.btn-sm.gho { background: transparent; border: 1px solid var(--b2); color: var(--blue); }
.btn-sm.gho:hover { background: var(--ab); }
.btn-sm.red { background: transparent; border: 1px solid rgba(239,68,68,.3); color: var(--red); }
.btn-sm.red:hover { background: rgba(239,68,68,.1); }

/* ── PAGES ── */
.page {
  display: none;
  min-height: 100vh;
  padding-top: 146px;
  animation: pageIn 0.3s ease;
}
.page.active { display: block; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SECTIONS ── */
.sec { padding: 5rem 2rem; }
.sec-inner { max-width: 1180px; margin: 0 auto; }
.sec-hd { text-align: center; margin-bottom: 3.5rem; }
.sec-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--blue);
  border: 1px solid rgba(0,212,255,.25);
  border-radius: 2rem;
  padding: 0.28rem 1rem;
  margin-bottom: 0.85rem;
  background: rgba(0,212,255,.04);
}
.sec-title {
  font-family: var(--font-head);
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--t1), var(--t2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sec-sub { color: var(--t2); font-size: 0.92rem; max-width: 480px; margin: 0 auto; }

/* ── CARDS ── */
.card {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: var(--radius-lg);
  transition: 0.25s;
}
.card:hover { border-color: var(--b2); transform: translateY(-4px); box-shadow: var(--shadow); }

/* ── FORM ── */
.form-box {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: var(--radius-lg);
  padding: 2rem;
}
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 1rem; }
.form-field label { font-size: 0.7rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--t3); }
.form-field input,
.form-field textarea,
.form-field select {
  background: var(--bg1);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 0.72rem 1rem;
  color: var(--t1);
  font-family: var(--font-body);
  font-size: 0.93rem;
  outline: none;
  transition: 0.2s;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus { border-color: var(--b2); }
.form-field textarea { resize: vertical; min-height: 90px; }
.form-field select option { background: var(--bg2); }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(12px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn { from{opacity:0;transform:scale(.96) translateY(16px)} to{opacity:1;transform:scale(1) translateY(0)} }
.modal-close {
  position: absolute; top: 1.2rem; right: 1.2rem;
  background: var(--bg3); border: 1px solid var(--b1); color: var(--t2);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  z-index: 3; transition: 0.2s;
}
.modal-close:hover { border-color: var(--blue); color: var(--blue); }

/* ── BADGE / STATUS ── */
.badge { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; padding: 2px 9px; border-radius: 2rem; }
.badge.ok  { background: rgba(34,197,94,.12); color: #22c55e; }
.badge.pend{ background: rgba(234,179,8,.12); color: #eab308; }
.badge.hot { background: rgba(239,68,68,.12);  color: #ef4444; }
.badge.info{ background: var(--ab); color: var(--blue); }
.badge.purple { background: var(--ap); color: var(--purple); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 5.5rem; right: 2rem;
  background: var(--bg3);
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 12px;
  padding: 0.8rem 1.2rem;
  font-size: 0.84rem;
  color: var(--t1);
  z-index: 3000;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transform: translateX(130%);
  transition: transform 0.35s cubic-bezier(.4,0,.2,1);
  max-width: 320px;
}
.toast.show { transform: translateX(0); }
.toast::before {
  content: '✓';
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(34,197,94,.18);
  color: #22c55e;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; flex-shrink: 0;
}

/* ── CHAT ── */
.chat-widget { position: fixed; bottom: 2rem; right: 2rem; z-index: 800; }
.chat-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  border: none; cursor: pointer; font-size: 1.4rem;
  box-shadow: 0 6px 24px rgba(124,58,237,.45);
  transition: 0.25s; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.chat-btn:hover { transform: scale(1.08); }
.chat-badge {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 0.62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg0);
}
.chat-window {
  position: absolute; bottom: 70px; right: 0;
  width: 320px; background: var(--bg2);
  border: 1px solid var(--b1); border-radius: 16px;
  overflow: hidden; display: none;
  box-shadow: var(--shadow);
}
.chat-window.open { display: block; animation: pageIn 0.25s ease; }
.chat-header {
  background: linear-gradient(135deg, var(--violet), var(--blue));
  padding: 1rem; display: flex; align-items: center; gap: 10px;
}
.chat-av {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.chat-name { font-size: 0.88rem; font-weight: 700; color: #fff; }
.chat-status { font-size: 0.68rem; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: 4px; }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; animation: blink 1.4s infinite; }
.chat-close { margin-left: auto; background: transparent; border: none; color: rgba(255,255,255,.7); cursor: pointer; font-size: 1rem; }
.chat-messages {
  height: 240px; overflow-y: auto;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem;
  background: var(--bg1);
}
.msg {
  max-width: 80%; padding: 0.6rem 0.85rem;
  border-radius: 12px; font-size: 0.83rem; line-height: 1.5;
}
.msg.bot { background: var(--bg3); border: 1px solid var(--b1); color: var(--t2); align-self: flex-start; border-radius: 4px 12px 12px 12px; }
.msg.user { background: linear-gradient(135deg, var(--violet), var(--blue)); color: #fff; align-self: flex-end; border-radius: 12px 4px 12px 12px; }

/* Quick-reply chips */
.chat-chips { display: flex; flex-wrap: wrap; gap: 5px; align-self: flex-start; max-width: 96%; }
.chat-chip {
  background: var(--bg4); border: 1px solid var(--b2); border-radius: 20px;
  padding: 4px 11px; font-size: 0.75rem; color: var(--blue); cursor: pointer;
  font-family: var(--font-body); font-weight: 600; transition: all 0.15s; white-space: nowrap;
}
.chat-chip:hover { background: var(--ab); border-color: var(--blue); }

/* Typing indicator (3 bouncing dots) */
.chat-typing { display: flex; align-items: center; gap: 4px; padding: 10px 14px !important; }
.chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); display: inline-block;
  animation: chatDot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

.chat-input-row { display: flex; gap: 7px; padding: 0.7rem; border-top: 1px solid var(--b1); }
.chat-input-row input { flex: 1; background: var(--bg3); border: 1px solid var(--b1); border-radius: 8px; padding: 0.48rem 0.75rem; color: var(--t1); font-family: var(--font-body); font-size: 0.83rem; outline: none; }
.chat-input-row input:focus { border-color: var(--b2); }
.chat-input-row button { background: linear-gradient(135deg, var(--violet), var(--blue)); border: none; color: #fff; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }

/* ── NEWSLETTER ── */
.newsletter-box {
  background: linear-gradient(135deg, var(--ap), rgba(0,212,255,.04));
  border: 1px solid rgba(139,92,246,.2);
  border-radius: var(--radius-lg);
  padding: 3rem; text-align: center;
  max-width: 600px; margin: 0 auto;
  position: relative; overflow: hidden;
}
.nl-form { display: flex; gap: 1rem; margin-top: 1.5rem; justify-content: center; flex-wrap: wrap; }
.nl-input {
  background: var(--bg3); border: 1px solid var(--b1);
  border-radius: 8px; padding: 0.7rem 1rem;
  color: var(--t1); font-family: var(--font-body); font-size: 0.93rem;
  outline: none; min-width: 240px; transition: 0.2s;
}
.nl-input:focus { border-color: var(--b2); }

/* Shared fadeIn animation used across components */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
