/* ============================================================
   OneStepAhead — unified sidebar
   Aligned to the design system (tokens.css):
   brand indigo/violet/teal, Sora, "magic" gestures.
   Class structure kept stable for sidebar.js.
   ============================================================ */

/* ---- Overlay (mobile / off-canvas) ---- */
.osa-sb-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 14, 26, .45);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
  z-index: 9998;
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur-base, .2s) var(--ease-out, ease),
              visibility var(--dur-base, .2s);
}
.osa-sb-overlay.open { opacity: 1; visibility: visible; }

/* ---- Shell ---- */
.osa-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 272px; z-index: 9999;
  display: flex; flex-direction: column;
  background: var(--bg-0, #fff);
  border-right: 1px solid var(--line, rgba(11,14,26,.08));
  box-shadow: var(--shadow-3, 0 12px 32px rgba(11,14,26,.10));
  transform: translateX(-100%);
  transition: transform .28s var(--ease-out, cubic-bezier(.16,1,.3,1));
  font-family: var(--font-sans, "Inter", system-ui, sans-serif);
}
.osa-sidebar.open { transform: translateX(0); }

/* ---- Logo header ---- */
.osa-sb-logo {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  min-height: 68px; flex-shrink: 0;
  border-bottom: 1px solid var(--line, rgba(11,14,26,.08));
}
.osa-sb-logo .osa-mark {
  width: 32px; height: 32px; flex-shrink: 0; display: block;
  filter: drop-shadow(0 4px 12px rgba(107, 91, 255, .30));
}
.osa-sb-logo .osa-wm {
  font-family: var(--font-display, "Sora", sans-serif);
  font-weight: 600; font-size: 18px; letter-spacing: -.025em;
  color: var(--fg-1, #0B0E1A); line-height: 1;
}

/* ---- Nav scroller ---- */
.osa-sb-nav {
  flex: 1; padding: 8px 12px 6px;
  overflow-y: auto; overflow-x: hidden;
}
.osa-sb-nav::-webkit-scrollbar { width: 8px; }
.osa-sb-nav::-webkit-scrollbar-thumb {
  background: var(--bg-3, #E5E5EF);
  border-radius: 8px;
  border: 2px solid var(--bg-0, #fff);
}

/* ---- Section label ---- */
.osa-sb-section {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-sans, "Inter", sans-serif);
  font-weight: 700; font-size: 10.5px;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--fg-4, #9097A8);
  padding: 16px 10px 6px;
}
.osa-sb-nav > .osa-sb-section:first-child { padding-top: 4px; }
.osa-sb-section .osa-sec-spark {
  width: 11px; height: 11px; flex-shrink: 0;
  color: var(--brand-violet, #8B5BFF);
  filter: drop-shadow(0 1px 3px rgba(139, 91, 255, .45));
}

/* ---- Nav item ---- */
.osa-sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 10px;
  border-radius: var(--r-2, 8px);
  font-size: 13.5px; font-weight: 600;
  color: var(--fg-2, #3D4356);
  text-decoration: none; cursor: pointer;
  margin-bottom: 2px; position: relative;
  transition: background var(--dur-fast, .12s) var(--ease-out, ease),
              color var(--dur-fast, .12s);
}
.osa-sb-item:hover { background: var(--bg-2, #EFEFF6); color: var(--fg-1, #0B0E1A); }

.osa-sb-item.active {
  background: color-mix(in srgb, var(--brand-indigo, #5B4FE9) 9%, transparent);
  color: var(--fg-1, #0B0E1A); font-weight: 700;
}
.osa-sb-item.active::before {
  content: ""; position: absolute; left: -6px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 3px;
  background: var(--grad-spark, linear-gradient(135deg, #5B4FE9, #00E5C7));
}

/* ---- Icon chip ---- */
.osa-sb-ic {
  width: 34px; min-width: 34px; height: 34px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
  transition: background var(--dur-fast, .12s) var(--ease-out, ease),
              box-shadow var(--dur-fast, .12s),
              transform var(--dur-fast, .12s);
}
.osa-sb-ic svg { width: 23px; height: 23px; display: block; overflow: visible; }
.osa-sb-item:hover .osa-sb-ic {
  background: var(--bg-0, #fff);
  box-shadow: var(--shadow-1, 0 1px 2px rgba(11,14,26,.06));
  transform: translateY(-1px);
}
.osa-sb-item.active .osa-sb-ic {
  background: var(--bg-0, #fff);
  box-shadow: var(--shadow-2, 0 2px 8px rgba(11,14,26,.10));
  border: 1px solid var(--line, rgba(11,14,26,.08));
}

/* AI-section items get a violet aura behind the chip — "the magic" */
.osa-sb-item.is-ai .osa-sb-ic {
  background: color-mix(in srgb, var(--brand-violet, #8B5BFF) 12%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand-violet, #8B5BFF) 18%, transparent);
}
.osa-sb-item.is-ai:hover .osa-sb-ic,
.osa-sb-item.is-ai.active .osa-sb-ic {
  background: var(--bg-0, #fff);
  box-shadow: var(--shadow-1, 0 1px 2px rgba(11,14,26,.06)),
              0 0 0 1px color-mix(in srgb, var(--brand-violet, #8B5BFF) 24%, transparent);
}

/* ---- Label + NEW badge ---- */
.osa-sb-lbl {
  flex: 1; min-width: 0;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden;
}
.new-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: var(--r-pill, 999px);
  background: var(--grad-spark, linear-gradient(135deg, #5B4FE9, #00E5C7));
  color: #fff; font-size: 8.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  box-shadow: 0 1px 5px color-mix(in srgb, var(--brand-indigo, #5B4FE9) 38%, transparent);
}

/* ---- Icon paint classes (used by inline SVGs) ---- */
.osa-sidebar .osa-icon-line {
  fill: none; stroke: var(--fg-1, #172033);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.osa-sidebar .osa-icon-white-line {
  fill: none; stroke: #fff;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.osa-sidebar .osa-icon-soft  { fill: var(--osa-icon-soft, #eaf2ff); }
.osa-sidebar .osa-icon-accent { fill: var(--osa-icon-accent, #5B4FE9); }
.osa-sidebar .osa-icon-accent-line {
  fill: none; stroke: var(--osa-icon-accent, #5B4FE9);
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.osa-sidebar .osa-icon-white { fill: #fff; }

/* ============================================================
   AI magic launcher — pinned CTA above the user footer
   ============================================================ */
.osa-sb-magic { padding: 8px 12px 2px; flex-shrink: 0; }
.osa-magic-btn {
  width: 100%; cursor: pointer; border: none;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r-3, 12px);
  text-align: left; position: relative; overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #6B5BFF 0%, #8B5BFF 46%, #00E5C7 128%);
  box-shadow: 0 6px 22px color-mix(in srgb, var(--brand-indigo, #5B4FE9) 32%, transparent),
              inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform var(--dur-fast, .12s) var(--ease-out, ease),
              filter var(--dur-fast, .12s);
}
.osa-magic-btn::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 88% -10%, rgba(255,255,255,.30), transparent 55%);
}
.osa-magic-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.osa-magic-btn:active { transform: translateY(0); }

.osa-magic-avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.18);
  display: grid; place-items: center;
  position: relative; color: #fff;
}
.osa-magic-avatar svg { width: 19px; height: 19px; position: relative; z-index: 1; }
.osa-magic-avatar::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 13px;
  border: 2px solid rgba(255,255,255,.55);
  animation: osaMagicRing 2.6s var(--ease-soft, ease) infinite;
}
@keyframes osaMagicRing {
  0%, 100% { transform: scale(1); opacity: .6; }
  50%      { transform: scale(1.2); opacity: 0; }
}

.osa-magic-tx {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  position: relative; z-index: 1;
}
.osa-magic-tx .t1 {
  font-family: var(--font-display, "Sora", sans-serif);
  font-weight: 600; font-size: 13.5px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.osa-magic-tx .t2 {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 500; opacity: .92;
}
.osa-magic-tx .t2 .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #fff;
  animation: osaMagicDot 2.4s ease-in-out infinite;
}
@keyframes osaMagicDot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,255,255,.30); }
  50%      { box-shadow: 0 0 0 6px rgba(255,255,255,.05); }
}
.osa-magic-arrow { flex-shrink: 0; opacity: .9; position: relative; z-index: 1; }
.osa-magic-arrow svg { width: 18px; height: 18px; display: block; }

/* ============================================================
   User footer
   ============================================================ */
.osa-sb-footer {
  padding: 8px 12px 14px; flex-shrink: 0;
  margin-top: 2px;
}
.osa-sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  background: var(--bg-1, #F7F7FB);
  border: 1px solid var(--line, rgba(11,14,26,.08));
  border-radius: var(--r-3, 12px);
}
.osa-sb-avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 10px;
  background: var(--grad-aether, linear-gradient(135deg, #6B5BFF, #8B5BFF 45%, #00E5C7));
  display: grid; place-items: center;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 15px; font-weight: 700; color: #fff;
  background-size: cover; background-position: center;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-indigo, #5B4FE9) 30%, transparent);
}
.osa-sb-userinfo { flex: 1; min-width: 0; overflow: hidden; }
.osa-sb-name {
  font-size: 13px; font-weight: 600; color: var(--fg-1, #0B0E1A);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.osa-sb-role {
  font-size: 11px; color: var(--fg-3, #6B7186);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.osa-logout-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  border: none; background: none; cursor: pointer;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--fg-3, #6B7186);
  transition: background var(--dur-fast, .12s), color var(--dur-fast, .12s);
}
.osa-logout-btn:hover { background: var(--danger-bg, #FBE7E7); color: var(--danger, #C73E3E); }
.osa-logout-btn svg { width: 20px; height: 20px; display: block; }

@media (prefers-reduced-motion: reduce) {
  .osa-sidebar *, .osa-magic-avatar::after { animation: none !important; }
}

/* ============================================================
   Anna Vidova — Chat Modal
   ============================================================ */
.anna-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .24s ease, visibility .24s;
}
.anna-modal.open { opacity: 1; visibility: visible; pointer-events: auto; }

.anna-modal-overlay {
  position: absolute; inset: 0;
  background: rgba(11, 14, 26, .55);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}

.anna-modal-panel {
  position: relative; z-index: 1;
  width: 94vw; max-width: 480px;
  height: 85vh; max-height: 680px;
  background: var(--bg-0, #fff);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(11,14,26,.22), 0 0 0 1px rgba(11,14,26,.06);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(.97);
  transition: transform .28s cubic-bezier(.16,1,.3,1);
}
.anna-modal.open .anna-modal-panel { transform: translateY(0) scale(1); }

/* ---- Header ---- */
.anna-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, rgba(11,14,26,.08));
  background: linear-gradient(135deg, rgba(107,91,255,.06), rgba(0,229,199,.04));
  flex-shrink: 0;
}
.anna-header-left { display: flex; align-items: center; gap: 10px; }
.anna-avatar-sm {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px;
  background: linear-gradient(135deg, #6B5BFF, #8B5BFF 45%, #00E5C7);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(107,91,255,.3);
}
.anna-avatar-sm svg { width: 18px; height: 18px; }
.anna-name {
  font-family: var(--font-display, "Sora", sans-serif);
  font-weight: 600; font-size: 14px; color: var(--fg-1, #0B0E1A);
}
.anna-role { font-size: 11px; color: var(--fg-3, #6B7186); }
.anna-close {
  width: 32px; height: 32px; border: none; background: none; cursor: pointer;
  border-radius: 8px; display: grid; place-items: center;
  color: var(--fg-3, #6B7186); transition: background .12s, color .12s;
}
.anna-close:hover { background: var(--bg-2, #EFEFF6); color: var(--fg-1, #0B0E1A); }
.anna-close svg { width: 18px; height: 18px; }

/* ---- Messages ---- */
.anna-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.anna-messages::-webkit-scrollbar { width: 6px; }
.anna-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 6px; }

.anna-welcome {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 12px; padding: 32px 8px 16px;
}
.anna-welcome-icon svg { width: 36px; height: 36px; }
.anna-welcome-text {
  font-size: 14px; color: var(--fg-2, #3D4356); line-height: 1.55;
}
.anna-hints {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding-top: 4px;
}
.anna-hint {
  border: 1px solid var(--line, rgba(11,14,26,.1));
  background: var(--bg-1, #F7F7FB); border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; cursor: pointer; color: var(--fg-2, #3D4356);
  transition: background .12s, border-color .12s;
  font-family: inherit; white-space: nowrap;
}
.anna-hint:hover {
  background: var(--bg-2, #EFEFF6);
  border-color: var(--brand-indigo, #5B4FE9);
  color: var(--fg-1, #0B0E1A);
}

/* ---- Message bubbles ---- */
.anna-msg {
  max-width: 88%; padding: 10px 14px;
  font-size: 13.5px; line-height: 1.55;
  border-radius: 14px; word-break: break-word;
}
.anna-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #5B4FE9, #7B5BFF);
  color: #fff; border-bottom-right-radius: 4px;
}
.anna-msg-assistant {
  align-self: flex-start;
  background: var(--bg-1, #F7F7FB);
  color: var(--fg-1, #0B0E1A);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--line, rgba(11,14,26,.06));
}
.anna-msg-assistant strong { font-weight: 700; }

/* code blocks inside assistant messages */
pre.anna-code {
  background: #1e1e2e; color: #cdd6f4;
  border-radius: 8px; padding: 10px 12px;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11.5px; line-height: 1.5;
  overflow-x: auto; margin: 6px 0 2px; white-space: pre;
}
code.anna-inline-code {
  background: rgba(11,14,26,.07); padding: 1px 5px; border-radius: 4px;
  font-family: "JetBrains Mono", monospace; font-size: 12px;
}

/* ---- Typing indicator ---- */
.anna-typing {
  display: inline-flex; gap: 5px; padding: 12px 18px !important;
  min-width: 52px;
}
.anna-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg-4, #9097A8);
  animation: annaDotBounce .9s ease-in-out infinite;
}
.anna-dot:nth-child(2) { animation-delay: .15s; }
.anna-dot:nth-child(3) { animation-delay: .3s; }
@keyframes annaDotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- Input area ---- */
.anna-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line, rgba(11,14,26,.08));
  flex-shrink: 0;
}
.anna-input {
  flex: 1; resize: none; border: 1px solid var(--line, rgba(11,14,26,.12));
  border-radius: 12px; padding: 10px 14px;
  font-family: inherit; font-size: 13.5px; line-height: 1.4;
  background: var(--bg-1, #F7F7FB); color: var(--fg-1, #0B0E1A);
  outline: none; max-height: 100px; overflow-y: auto;
  transition: border-color .15s, box-shadow .15s;
}
.anna-input:focus {
  border-color: var(--brand-indigo, #5B4FE9);
  box-shadow: 0 0 0 3px rgba(91,79,233,.12);
}
.anna-input::placeholder { color: var(--fg-4, #9097A8); }
.anna-send {
  width: 38px; height: 38px; flex-shrink: 0;
  border: none; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, #5B4FE9, #8B5BFF);
  color: #fff; display: grid; place-items: center;
  transition: filter .12s, transform .12s;
  box-shadow: 0 4px 12px rgba(91,79,233,.3);
}
.anna-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.anna-send:active { transform: translateY(0); }
.anna-send:disabled { opacity: .5; cursor: default; filter: none; transform: none; }
.anna-send svg { width: 16px; height: 16px; }

/* Mobile full screen */
@media (max-width: 520px) {
  .anna-modal-panel {
    width: 100vw; height: 100vh; max-height: 100vh;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0;
  }
  .anna-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  }
  .anna-input-wrap {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  }
}

/* ---- Markdown elements inside assistant messages ---- */
.anna-msg-assistant .anna-h {
  font-weight: 700; margin: 4px 0 2px;
}
.anna-msg-assistant .anna-h1 { font-size: 16px; }
.anna-msg-assistant .anna-h2 { font-size: 15px; }
.anna-msg-assistant .anna-h3 { font-size: 14px; }
.anna-msg-assistant .anna-h4 { font-size: 13.5px; }
.anna-msg-assistant .anna-hr {
  border: none; border-top: 1px solid var(--line, rgba(11,14,26,.12));
  margin: 8px 0;
}
.anna-msg-assistant .anna-li {
  padding-left: 14px; position: relative; margin: 2px 0;
}
.anna-msg-assistant .anna-li::before {
  content: "•"; position: absolute; left: 2px;
  color: var(--brand-indigo, #5B4FE9); font-weight: 700;
}
.anna-msg-assistant .anna-spacer { height: 8px; }
