/* ============ FolioForge app theme ============ */
:root {
  --bg: #05060f;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-solid: #0c0e1e;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e9ebf8;
  --muted: #8b90ad;
  --violet: #7c3aed;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --grad: linear-gradient(135deg, #7c3aed, #22d3ee);
  --radius: 16px;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

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

/* the hidden attribute must win over any display rule below */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Floating background orbs */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: drift 24s ease-in-out infinite alternate;
}
.orb-a { width: 480px; height: 480px; top: -160px; left: -120px;
  background: radial-gradient(circle, #7c3aed, transparent 70%); }
.orb-b { width: 420px; height: 420px; bottom: -140px; right: -100px;
  background: radial-gradient(circle, #22d3ee, transparent 70%); animation-delay: -8s; }
.orb-c { width: 300px; height: 300px; top: 45%; left: 60%;
  background: radial-gradient(circle, #f472b6, transparent 70%);
  opacity: 0.18; animation-delay: -16s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(60px, 40px) scale(1.15); }
}
/* ============ brand ============ */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.25rem;
  color: var(--text); text-decoration: none; letter-spacing: -0.02em;
}
.brand em { font-style: normal; background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { width: 30px; height: 30px; filter: drop-shadow(0 0 12px rgba(124, 58, 237, 0.6)); }
.admin-tag {
  font: 600 0.65rem var(--font-body); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--cyan); border: 1px solid rgba(34, 211, 238, 0.4);
  padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle;
}

/* ============ auth pages ============ */
.auth-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  animation: card-in 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.auth-card .brand { margin-bottom: 28px; }
.auth-card h1 {
  font-family: var(--font-head); font-size: 1.7rem; letter-spacing: -0.02em; margin-bottom: 6px;
}
.auth-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; }
.auth-card label {
  display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 16px 0 6px;
}
.auth-card input {
  width: 100%; padding: 13px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font: inherit; font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-card input:focus {
  outline: none; border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);
}
.btn-primary {
  width: 100%; margin-top: 24px; padding: 14px;
  background: var(--grad); border: none; border-radius: 12px;
  color: #fff; font: 600 1rem var(--font-head); letter-spacing: 0.01em;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(124, 58, 237, 0.5); }
.btn-primary:active { transform: translateY(0); }
.form-error {
  background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af; padding: 11px 14px; border-radius: 12px; font-size: 0.88rem;
}
.auth-switch { margin-top: 22px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.auth-switch a { color: var(--cyan); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ============ app header ============ */
.app-header {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 6, 15, 0.7); backdrop-filter: blur(16px);
}
.header-right { display: flex; align-items: center; gap: 14px; }
.user-chip { color: var(--muted); font-size: 0.9rem; }
.btn-ghost {
  color: var(--text); text-decoration: none; font-size: 0.88rem; font-weight: 500;
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 14px;
  transition: border-color 0.2s, background 0.2s;
}
.btn-ghost:hover { border-color: var(--violet); background: rgba(124, 58, 237, 0.12); }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; }
.status-pill.online .status-dot {
  background: #34d399; box-shadow: 0 0 10px rgba(52, 211, 153, 0.8);
  animation: pulse-dot 2s infinite;
}
.status-pill.online { color: #a7f3d0; border-color: rgba(52, 211, 153, 0.35); }
@keyframes pulse-dot { 50% { box-shadow: 0 0 3px rgba(52, 211, 153, 0.4); } }

/* ============ client chat ============ */
.chat-wrap {
  position: relative; z-index: 1;
  height: calc(100vh - 61px); display: flex; justify-content: center; padding: 20px;
}
.chat-panel {
  width: 100%; max-width: 800px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); backdrop-filter: blur(20px); overflow: hidden;
}
.messages { flex: 1; overflow-y: auto; padding: 26px 22px 10px; scroll-behavior: smooth; }
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-icon { font-size: 2.6rem; margin-bottom: 14px; filter: drop-shadow(0 0 18px rgba(124, 58, 237, 0.55)); }
.empty-state h2 { font-family: var(--font-head); color: var(--text); margin-bottom: 8px; letter-spacing: -0.02em; }
.empty-state p { max-width: 420px; margin: 0 auto 22px; font-size: 0.93rem; line-height: 1.6; }
.chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chip {
  background: rgba(124, 58, 237, 0.12); border: 1px solid rgba(124, 58, 237, 0.4);
  color: var(--text); border-radius: 999px; padding: 9px 16px;
  font: 500 0.85rem var(--font-body); cursor: pointer; transition: all 0.2s;
}
.chip:hover { background: rgba(124, 58, 237, 0.28); transform: translateY(-2px); }

.day-sep {
  text-align: center; color: var(--muted); font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em; margin: 18px 0 10px;
}
.msg { display: flex; margin-bottom: 10px; animation: msg-in 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.msg .bubble {
  max-width: 72%; padding: 11px 15px; border-radius: 18px;
  font-size: 0.94rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.msg .stamp { display: block; font-size: 0.68rem; opacity: 0.6; margin-top: 5px; }
.msg.mine { justify-content: flex-end; }
.msg.mine .bubble {
  background: var(--grad); color: #fff; border-bottom-right-radius: 6px;
  box-shadow: 0 6px 22px rgba(124, 58, 237, 0.3);
}
.msg.theirs .bubble {
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.typing-indicator {
  padding: 4px 24px 8px; color: var(--muted); font-size: 0.8rem;
  display: flex; align-items: center; gap: 8px;
}
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--cyan);
  animation: bounce 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 30% { transform: translateY(-5px); } 60% { transform: none; } }

.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 16px; border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 16px; color: var(--text);
  font: 0.95rem var(--font-body); line-height: 1.45;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer textarea:focus {
  outline: none; border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.22);
}
.btn-send {
  width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--grad); border: none; border-radius: 14px; color: #fff;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}
.btn-send:hover { transform: translateY(-2px) scale(1.04); }
.btn-send:disabled { opacity: 0.45; cursor: default; transform: none; }

.conn-banner {
  text-align: center; font-size: 0.78rem; padding: 6px;
  background: rgba(251, 191, 36, 0.12); color: #fcd34d;
  border-top: 1px solid rgba(251, 191, 36, 0.3);
}

/* ============ admin ============ */
.admin-wrap {
  position: relative; z-index: 1;
  height: calc(100vh - 61px); display: flex;
}
.sidebar {
  width: 330px; flex-shrink: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02); backdrop-filter: blur(14px);
}
.sidebar-head { padding: 18px 18px 12px; }
.sidebar-head h2 { font-family: var(--font-head); font-size: 1.15rem; margin-bottom: 12px; letter-spacing: -0.01em; }
.sidebar-head input {
  width: 100%; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font: 0.88rem var(--font-body);
}
.sidebar-head input:focus { outline: none; border-color: var(--violet); }
.conv-list { list-style: none; overflow-y: auto; flex: 1; }
.conv-item {
  display: flex; gap: 12px; align-items: center;
  padding: 13px 18px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}
.conv-item:hover { background: rgba(255, 255, 255, 0.045); }
.conv-item.active { background: rgba(124, 58, 237, 0.14); border-left-color: var(--violet); }
.avatar {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  font: 600 0.9rem var(--font-head); color: #fff;
}
.avatar .online-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #34d399; border: 2px solid var(--panel-solid); display: none;
}
.avatar.online .online-dot { display: block; }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-top strong { font-size: 0.92rem; font-weight: 600; }
.conv-time { font-size: 0.7rem; color: var(--muted); flex-shrink: 0; }
.conv-preview {
  font-size: 0.82rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.conv-item.unread .conv-preview { color: var(--text); font-weight: 500; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--grad); color: #fff; font-size: 0.7rem; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.conv-empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 0.88rem; line-height: 1.7; }

.convo { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; }
.convo-placeholder {
  flex: 1; display: grid; place-content: center; text-align: center;
  color: var(--muted); gap: 10px;
}
.convo-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.convo-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.convo-meta { display: flex; flex-direction: column; }
.convo-meta strong { font-size: 0.96rem; }
.convo-sub { font-size: 0.76rem; color: var(--muted); }
.btn-back {
  display: none; background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem;
}

@media (max-width: 760px) {
  .admin-wrap { position: relative; }
  .sidebar { width: 100%; border-right: none; }
  .convo { position: absolute; inset: 0; background: var(--bg); z-index: 3;
    display: none; }
  .admin-wrap.convo-open .convo { display: flex; }
  .admin-wrap.convo-open .sidebar { display: none; }
  .btn-back { display: grid; place-items: center; }
  .msg .bubble { max-width: 85%; }
  .status-pill { display: none; }
  .user-chip { display: none; }
}
