/* ============================================================
   Pitchpilot — Close deals in the DMs.
   Design system: warm canvas, deep-ink chrome, electric violet
   ============================================================ */

:root {
  /* Palette */
  --ink-900: #14101f;
  --ink-800: #1c1730;
  --ink-700: #272040;
  --ink-600: #352c54;

  --canvas: #f6f4fb;
  --surface: #ffffff;
  --surface-2: #faf9fe;
  --line: #ece8f6;
  --line-strong: #ddd6ee;

  --txt-900: #1a1530;
  --txt-700: #4a4365;
  --txt-500: #786f95;
  --txt-300: #6f6687;

  /* Accent — electric violet */
  --violet-600: #6b3df5;
  --violet-500: #7c4dff;
  --violet-400: #9a72ff;
  --violet-100: #ece4ff;
  --violet-50: #f5f1ff;

  --mint: #08765e;
  --mint-bg: #e2f8f1;
  --amber: #f5a524;
  --amber-bg: #fdf1da;
  --rose: #bd2448;
  --rose-bg: #fde3e9;
  --blue: #3b82f6;
  --sky-bg: #e4eefe;

  /* Channel colors */
  --c-ig: #e1306c;
  --c-x: #111827;
  --c-li: #0a66c2;
  --c-wa: #25d366;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(26, 21, 48, .06), 0 1px 3px rgba(26, 21, 48, .04);
  --shadow-md: 0 4px 16px rgba(26, 21, 48, .08), 0 1px 4px rgba(26, 21, 48, .04);
  --shadow-lg: 0 18px 48px rgba(40, 28, 90, .18), 0 4px 12px rgba(26, 21, 48, .08);
  --shadow-violet: 0 8px 24px rgba(107, 61, 245, .32);

  --font-display: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;

  --sidebar-w: 76px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--txt-900);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

::selection { background: var(--violet-100); color: var(--violet-600); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid #5b2de0;
  outline-offset: 2px;
}
.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--txt-300); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  width: 100vw;
}

/* ---- Rail / sidebar ---- */
.rail {
  background: var(--ink-900);
  background-image: radial-gradient(120% 80% at 50% -10%, rgba(124, 77, 255, .22), transparent 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 16px;
  gap: 6px;
  position: relative;
  z-index: 20;
}

.rail-logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--violet-500), var(--violet-400));
  display: grid; place-items: center;
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 19px;
  box-shadow: var(--shadow-violet);
  margin-bottom: 14px;
  letter-spacing: -.5px;
  overflow: hidden;
}
.rail-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.rail-nav { display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }

.rail-btn {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  color: #8b82a8;
  position: relative;
  transition: color .2s, background .2s;
}
.rail-btn svg { width: 21px; height: 21px; }
.rail-btn:hover { color: #fff; background: rgba(255,255,255,.06); }
.rail-btn.active { color: #fff; background: rgba(124,77,255,.18); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--violet-400);
}
.rail-btn .tip {
  position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%) translateX(-6px);
  background: var(--ink-700); color: #fff; padding: 6px 11px; border-radius: 8px;
  font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s, transform .15s; z-index: 50;
  box-shadow: var(--shadow-md);
}
.rail-btn .tip::before {
  content:''; position:absolute; left:-4px; top:50%; transform:translateY(-50%) rotate(45deg);
  width:8px; height:8px; background: var(--ink-700);
}
.rail-btn:hover .tip { opacity: 1; transform: translateY(-50%) translateX(0); }

.rail-spacer { flex: 1; }
.rail-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #ffb86b, #ff6b9d);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  border: 2px solid rgba(255,255,255,.15);
  cursor: pointer;
}

/* ---- Main ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.topbar {
  height: 64px; flex: 0 0 64px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.topbar h1 {
  font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -.4px;
}
.topbar .sub { color: var(--txt-500); font-size: 13px; font-weight: 500; }
.topbar-spacer { flex: 1; }

.searchbox {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px 13px; width: 280px; position: relative;
  color: var(--txt-500); transition: border-color .2s, box-shadow .2s;
}
.searchbox:focus-within { border-color: var(--violet-400); box-shadow: 0 0 0 3px var(--violet-50); }
.searchbox input { border: none; background: none; outline: none; flex: 1; min-width: 0; font-size: 13.5px; color: var(--txt-900); }
.searchbox svg { width: 17px; height: 17px; flex: 0 0 auto; }
.searchbox kbd {
  font-family: var(--font-body); font-size: 11px; font-weight: 600; color: var(--txt-300);
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}

/* ---- global search results ---- */
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 13px;
  box-shadow: var(--shadow-lg); padding: 6px; display: none; max-height: 60vh; overflow: auto;
}
.search-results.open { display: block; animation: pop .14s var(--ease); }
.sr-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 9px; border-radius: 9px; transition: background .12s;
}
.sr-item:hover, .sr-item.active { background: var(--violet-50); }
.sr-body { flex: 1; min-width: 0; }
.sr-name { font-weight: 700; font-size: 13px; color: var(--txt-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 11.5px; color: var(--txt-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-tag { font-size: 10px; font-weight: 700; color: var(--violet-600); background: var(--violet-50); border-radius: 99px; padding: 2px 8px; flex: 0 0 auto; }
.sr-empty { padding: 16px 12px; text-align: center; color: var(--txt-500); font-size: 13px; font-weight: 500; }

/* ---- popmenu (sort) ---- */
.popmenu {
  position: fixed; z-index: 200; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s var(--ease);
}
.popmenu-title { font-size: 11px; font-weight: 700; color: var(--txt-300); text-transform: uppercase; letter-spacing: .04em; padding: 6px 9px 4px; }
.popmenu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 8px 9px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--txt-700); }
.popmenu-item:hover { background: var(--surface-2); }
.popmenu-item.active { color: var(--violet-600); background: var(--violet-50); }
.popmenu-item svg { width: 14px; height: 14px; }

/* ---- emoji picker ---- */
.emoji-pop {
  position: fixed; z-index: 200; width: 220px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 8px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px;
  animation: pop .14s var(--ease);
}
.emoji-btn { font-size: 19px; padding: 5px 0; border-radius: 8px; line-height: 1; }
.emoji-btn:hover { background: var(--violet-50); }

@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

.content { flex: 1; min-height: 0; overflow: hidden; }

/* ============================================================
   Buttons & chips
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 600; font-size: 13.5px;
  padding: 9px 15px; border-radius: 10px;
  transition: transform .12s var(--ease), box-shadow .2s, background .2s, border-color .2s;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--violet-600); color: #fff; box-shadow: var(--shadow-violet); }
.btn-primary:hover { background: var(--violet-500); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line-strong); color: var(--txt-700); }
.btn-ghost:hover { border-color: var(--txt-300); background: var(--surface-2); }
.btn-soft { background: var(--violet-50); color: var(--violet-600); }
.btn-soft:hover { background: var(--violet-100); }
.btn-icon {
  width: 38px; height: 38px; border-radius: 10px; padding: 0; display: grid; place-items: center;
  color: var(--txt-500); border: 1px solid transparent;
}
.btn-icon:hover { background: var(--surface-2); color: var(--txt-900); border-color: var(--line); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  letter-spacing: .2px;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; }

.badge {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px;
  background: var(--violet-600); color: #fff; font-size: 11px; font-weight: 800;
  display: inline-grid; place-items: center;
}

/* ============================================================
   Channel avatars
   ============================================================ */
.avatar {
  position: relative; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
  background-size: cover;
}
.avatar.sz-44 { width: 44px; height: 44px; font-size: 15px; }
.avatar.sz-40 { width: 40px; height: 40px; font-size: 14px; }
.avatar.sz-36 { width: 36px; height: 36px; font-size: 13px; }
.avatar.sz-32 { width: 32px; height: 32px; font-size: 12px; }
.avatar.sz-28 { width: 28px; height: 28px; font-size: 11px; }

.ch-badge {
  position: absolute; right: -3px; bottom: -3px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
  color: #fff;
}
.ch-badge svg { width: 10px; height: 10px; }
.ch-ig { background: linear-gradient(135deg, #f9ce34, #ee2a7b 45%, #6228d7); }
.ch-x  { background: var(--c-x); }
.ch-li { background: var(--c-li); }
.ch-wa { background: var(--c-wa); }

.toast-wrap { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: var(--ink-800); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-weight: 600; font-size: 13.5px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px;
  animation: toastIn .35s var(--ease);
}
.toast svg { width: 17px; height: 17px; color: var(--mint); }
.toast.fade { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
