/* Nello AI assistant — pill button, drawer, chat UI.
 * Loaded from layouts/layout.ejs alongside the other dashboard CSS.
 * Uses --kat-* variables from the existing katalyst-theme. */

/* ─── Topbar pill (replaces app-search) ───────────────────────────────── */
.nello-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  margin: 13px 16px 13px 24px;
  border-radius: 999px;
  background: var(--kat-bg-elevated, #15151f);
  color: var(--kat-text, #e2e8f0);
  font-size: .86rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  isolation: isolate;
  border: 1px solid transparent;
  transition: transform .15s, color .15s;
  min-width: 240px;
  max-width: 360px;
}
.nello-pill:hover { color: var(--kat-text-strong, #fff); transform: translateY(-1px); }
.nello-pill:focus-visible { outline: 2px solid var(--kat-gold, #d6b37f); outline-offset: 3px; }

/* Animated gradient border. We animate the gradient angle via a registered
   custom property (@property) instead of rotating the element itself —
   rotating a wide pill-shaped rectangle visibly sweeps outside its bounds.
   Keeping the element static and only sweeping the gradient angle keeps
   the highlight contained inside the pill at all times. */
@property --nello-pill-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
.nello-pill::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1.5px;
  border-radius: 999px;
  background: conic-gradient(from var(--nello-pill-angle),
    rgba(214,179,127,.0)  0deg,
    rgba(214,179,127,.55) 30deg,
    rgba(232,205,170,.95) 90deg,
    rgba(214,179,127,.55) 150deg,
    rgba(214,179,127,.0)  200deg,
    rgba(214,179,127,.0)  360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  animation: nello-pill-spin 3.5s linear infinite;
  pointer-events: none;
  z-index: -1;
}
.nello-pill::after {
  content: '';
  position: absolute;
  inset: 1.5px;
  border-radius: 999px;
  background: var(--kat-bg-elevated, #15151f);
  z-index: -1;
}
.nello-pill:hover::after { background: var(--kat-bg-hover, #1d1d2c); }

@keyframes nello-pill-spin {
  to { --nello-pill-angle: 360deg; }
}

.nello-pill__glyph {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d6b37f 0%, #b89460 100%);
  color: #1a1408;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(214,179,127,.5);
}
.nello-pill__text {
  flex: 1;
  text-align: left;
  color: var(--kat-text-muted, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nello-pill:hover .nello-pill__text { color: var(--kat-text-strong, #fff); }

.nello-pill__kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .68rem;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255,255,255,.06);
  color: var(--kat-text-muted, #94a3b8);
  border: 1px solid var(--kat-border, rgba(255,255,255,.08));
  letter-spacing: .04em;
}

/* Status modifiers — set by nello.js to reflect key + quota state. */
.nello-pill--ok    .nello-pill__glyph { box-shadow: 0 0 18px rgba(16,185,129,.55); background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #022c22; }
.nello-pill--warn  .nello-pill__glyph { box-shadow: 0 0 18px rgba(245,158,11,.55); background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); color: #422006; }
.nello-pill--limit .nello-pill__glyph { box-shadow: 0 0 18px rgba(239,68,68,.55); background: linear-gradient(135deg, #fca5a5 0%, #ef4444 100%); color: #450a0a; }
.nello-pill--ok    .nello-pill__text { color: var(--kat-text, #e2e8f0); }
.nello-pill--warn  .nello-pill__text,
.nello-pill--limit .nello-pill__text { color: var(--kat-text-strong, #fff); }

/* Mobile: just an icon button */
.nello-pill--mobile {
  width: 42px; height: 42px;
  min-width: 0; max-width: none;
  padding: 0;
  margin: 0 4px;
  justify-content: center;
}
.nello-pill--mobile .nello-pill__glyph,
.nello-pill--mobile .nello-pill__text,
.nello-pill--mobile .nello-pill__kbd { display: none; }
.nello-pill--mobile i { font-size: 1.25rem; color: var(--kat-gold, #d6b37f); }

/* ─── Backdrop + drawer chrome ────────────────────────────────────────── */
.nello-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1090;
  opacity: 0;
  transition: opacity .2s;
}
.nello-backdrop.is-open { opacity: 1; }

.nello-drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 480px;
  max-width: 100vw;
  background: var(--kat-bg, #0b0b12);
  border-left: 1px solid var(--kat-border, rgba(255,255,255,.08));
  box-shadow: -24px 0 60px rgba(0,0,0,.6);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease-out;
}
.nello-drawer.is-open { transform: translateX(0); }

@media (max-width: 540px) {
  .nello-drawer { width: 100vw; }
}

.nello-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--kat-border, rgba(255,255,255,.06));
  flex-shrink: 0;
}
.nello-drawer__brand { display: flex; align-items: center; gap: 12px; }
.nello-drawer__brand-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #d6b37f 0%, #b89460 100%);
  color: #1a1408; font-size: 1.1rem;
  box-shadow: 0 0 22px rgba(214,179,127,.45);
}
.nello-drawer__title {
  font-size: 1rem; font-weight: 600;
  color: var(--kat-text-strong, #fff);
}
.nello-drawer__subtitle {
  font-size: .74rem;
  color: var(--kat-text-muted, #94a3b8);
}
.nello-drawer__head-actions { display: flex; gap: 4px; }

.nello-icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--kat-text-muted, #94a3b8);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 1.1rem;
  transition: background .15s, color .15s, border-color .15s;
}
.nello-icon-btn:hover {
  background: var(--kat-bg-hover, #1d1d2c);
  color: var(--kat-text-strong, #fff);
  border-color: var(--kat-border, rgba(255,255,255,.08));
}

/* ─── No-key empty state ──────────────────────────────────────────────── */
.nello-drawer__nokey {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 30px 36px;
}
.nello-drawer__nokey-icon {
  font-size: 3rem;
  color: var(--kat-gold, #d6b37f);
  margin-bottom: 14px;
}
.nello-drawer__nokey h5 {
  font-size: 1.1rem; font-weight: 600;
  color: var(--kat-text-strong, #fff);
  margin: 0 0 8px;
}
.nello-drawer__nokey p {
  font-size: .85rem;
  color: var(--kat-text-muted, #94a3b8);
  line-height: 1.55;
  margin: 0 0 20px;
}
.nello-drawer__nokey p a { color: var(--kat-gold, #d6b37f); text-decoration: none; }
.nello-drawer__nokey p a:hover { text-decoration: underline; }

/* ─── History list ────────────────────────────────────────────────────── */
.nello-drawer__history {
  position: absolute; inset: 0;
  background: var(--kat-bg, #0b0b12);
  z-index: 5;
  display: flex; flex-direction: column;
}
.nello-drawer__history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--kat-border, rgba(255,255,255,.06));
}
.nello-drawer__history-head h6 {
  font-size: 1rem; font-weight: 600;
  color: var(--kat-text-strong, #fff);
  margin: 0;
}
.nello-drawer__history-list { flex: 1; overflow-y: auto; padding: 8px 12px; }

.nello-history-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--kat-bg-elevated, #15151f);
  border: 1px solid var(--kat-border, rgba(255,255,255,.06));
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.nello-history-row:hover { background: var(--kat-bg-hover, #1d1d2c); border-color: var(--kat-gold, #d6b37f); }
.nello-history-row__title {
  flex: 1;
  font-size: .86rem; font-weight: 500;
  color: var(--kat-text-strong, #fff);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.nello-history-row__time {
  font-size: .72rem;
  color: var(--kat-text-muted, #94a3b8);
  flex-shrink: 0;
}
.nello-history-row__del {
  background: transparent;
  border: 0;
  color: var(--kat-text-dim, #64748b);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 2px;
}
.nello-history-row__del:hover { color: #fca5a5; }

/* ─── Message stream ──────────────────────────────────────────────────── */
.nello-drawer__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.nello-drawer__messages::-webkit-scrollbar { width: 6px; }
.nello-drawer__messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 999px; }

.nello-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.nello-msg__avatar {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1rem;
}
.nello-msg__avatar--bot {
  background: linear-gradient(135deg, #d6b37f 0%, #b89460 100%);
  color: #1a1408;
}
.nello-msg__avatar--user {
  background: var(--kat-bg-hover, #1d1d2c);
  color: var(--kat-text-muted, #94a3b8);
}
.nello-msg__avatar--system {
  background: rgba(16,185,129,.18);
  color: #6ee7b7;
}
.nello-msg__bubble {
  background: var(--kat-bg-elevated, #15151f);
  border: 1px solid var(--kat-border, rgba(255,255,255,.06));
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .88rem;
  color: var(--kat-text, #e2e8f0);
  line-height: 1.55;
  max-width: 100%;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.nello-msg--user .nello-msg__bubble {
  background: rgba(214,179,127,.08);
  border-color: rgba(214,179,127,.2);
  color: var(--kat-text-strong, #fff);
}
.nello-msg--system .nello-msg__bubble {
  background: rgba(16,185,129,.08);
  border-color: rgba(16,185,129,.25);
  color: #d1fae5;
  font-size: .82rem;
}

/* Proposal confirmation card — shown when Nello returned a pending action */
.nello-proposal {
  margin-top: 8px;
  background: rgba(214,179,127,.06);
  border: 1px solid rgba(214,179,127,.3);
  border-radius: 10px;
  padding: 12px 14px;
}
.nello-proposal__head {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--kat-gold, #d6b37f);
  font-weight: 700;
  margin-bottom: 6px;
}
.nello-proposal__summary {
  font-size: .88rem;
  color: var(--kat-text-strong, #fff);
  margin: 0 0 12px;
  line-height: 1.45;
}
.nello-proposal__details {
  background: var(--kat-bg, #0b0b12);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-family: ui-monospace, monospace;
  font-size: .72rem;
  color: var(--kat-text-muted, #94a3b8);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.nello-proposal__actions { display: flex; gap: 8px; }
.nello-proposal__btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.nello-proposal__btn--confirm { background: var(--kat-gold, #d6b37f); color: #1a1408; }
.nello-proposal__btn--confirm:hover { background: var(--kat-gold-soft, #b89460); }
.nello-proposal__btn--cancel  {
  background: transparent;
  color: var(--kat-text-muted, #94a3b8);
  border-color: var(--kat-border, rgba(255,255,255,.08));
}
.nello-proposal__btn--cancel:hover { color: #fca5a5; border-color: rgba(239,68,68,.4); }

.nello-typing {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 4px 0;
}
.nello-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--kat-gold, #d6b37f);
  animation: nello-typing 1.2s ease-in-out infinite;
}
.nello-typing span:nth-child(2) { animation-delay: .15s; }
.nello-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes nello-typing {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40%           { opacity: 1;  transform: translateY(-3px); }
}

.nello-empty {
  text-align: center;
  padding: 30px 14px;
  font-size: .85rem;
  color: var(--kat-text-muted, #94a3b8);
}

/* ─── Composer ────────────────────────────────────────────────────────── */
.nello-drawer__composer {
  flex-shrink: 0;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--kat-border, rgba(255,255,255,.06));
}
.nello-drawer__composer-row {
  display: flex; gap: 8px;
  align-items: flex-end;
  background: var(--kat-bg-elevated, #15151f);
  border: 1px solid var(--kat-border, rgba(255,255,255,.06));
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color .15s;
}
.nello-drawer__composer-row:focus-within { border-color: var(--kat-gold, #d6b37f); }

.nello-drawer__input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  color: var(--kat-text-strong, #fff);
  font-size: .9rem;
  font-family: inherit;
  line-height: 1.5;
  max-height: 160px;
  min-height: 24px;
}
.nello-drawer__input::placeholder { color: var(--kat-text-dim, #64748b); }

.nello-drawer__send {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 0;
  background: var(--kat-gold, #d6b37f);
  color: #1a1408;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: opacity .15s, transform .15s;
}
.nello-drawer__send:hover:not(:disabled) { transform: translateY(-1px); }
.nello-drawer__send:disabled { opacity: .4; cursor: not-allowed; }

.nello-drawer__hints {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 10px;
}
.nello-chip {
  font-size: .74rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--kat-bg-elevated, #15151f);
  border: 1px solid var(--kat-border, rgba(255,255,255,.06));
  color: var(--kat-text-muted, #94a3b8);
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.nello-chip:hover { color: var(--kat-gold, #d6b37f); border-color: var(--kat-gold, #d6b37f); }

/* ─── Generate-Image button + modal (used beside file inputs) ─────────── */
.nello-genimg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(214,179,127,.12);
  border: 1px solid rgba(214,179,127,.35);
  color: var(--kat-gold, #d6b37f);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s, transform .12s, border-color .15s;
}
.nello-genimg:hover { background: rgba(214,179,127,.2); transform: translateY(-1px); }
.nello-genimg:disabled { opacity: .55; cursor: not-allowed; transform: none; }
/* Blocked state — set by nello.js when there's no Gemini key or quota is
   exhausted. Visually distinct from a transient "loading" disable. */
.nello-genimg--blocked { opacity: .45; cursor: not-allowed; }
.nello-genimg--blocked:hover { background: rgba(214,179,127,.12); transform: none; }
.nello-genimg i { font-size: 1rem; }

.nello-genimg-preview {
  margin-top: 8px;
  display: none;
  position: relative;
}
.nello-genimg-preview.is-active { display: block; }
.nello-genimg-preview img {
  max-width: 100%; max-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--kat-border, rgba(255,255,255,.08));
}
.nello-genimg-preview__pill {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.55);
  color: var(--kat-gold, #d6b37f);
  font-size: .68rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
