/* ═══════════════════════════════════════════════════════
   NEXUS UX UPGRADE — nexus-ux.css
   Carregado APÓS nexus-life.css.
   ═══════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────
   1. OCULTAR NOMES NAS MENSAGENS
───────────────────────────────────────── */
.msg-sndr {
  display: none;
}
.msg-meta {
  margin-bottom: 3px;
}

/* ─────────────────────────────────────────
   2. EMPTY STATE — corrige nexus-life.css
   que usa gradiente quase transparente e
   cores hardcoded brancas (somem no light).
───────────────────────────────────────── */
.empty-icon {
  background: linear-gradient(135deg, #5B8DEF 0%, #E8974B 100%) !important;
  border: none !important;
  box-shadow: 0 8px 40px rgba(91,141,239,.35) !important;
  animation: nx-icon-float 4s ease-in-out infinite !important;
}
[data-theme="light"] .empty-icon {
  background: linear-gradient(135deg, #3B6FD4 0%, #C4742A 100%) !important;
  box-shadow: 0 6px 24px rgba(59,111,212,.25) !important;
}

[data-theme="light"] .empty-title {
  background: linear-gradient(135deg, #0D1117 20%, #374151 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}
[data-theme="light"] .empty-sub {
  color: #4B5563 !important;
}

/* ─────────────────────────────────────────
   3. LIGHT THEME — sidebar
───────────────────────────────────────── */
[data-theme="light"] .conv-title {
  color: #1a1d2e;
}
[data-theme="light"] .conv-item.active .conv-title {
  color: #0D1117;
  font-weight: 600;
}
[data-theme="light"] .grp-label {
  color: rgba(26,29,46,.45);
}
[data-theme="light"] .btn-new {
  color: #1a1d2e !important;
  background: linear-gradient(135deg, rgba(59,107,224,.12), rgba(59,107,224,.05)) !important;
  border-color: rgba(59,107,224,.22) !important;
}
[data-theme="light"] .btn-new:hover {
  background: linear-gradient(135deg, rgba(59,107,224,.2), rgba(59,107,224,.1)) !important;
  border-color: rgba(59,107,224,.38) !important;
  color: #0D1117 !important;
}
[data-theme="light"] .sb-search input {
  color: #1a1d2e;
}
[data-theme="light"] .sb-search input::placeholder {
  color: rgba(26,29,46,.4);
}

/* ─────────────────────────────────────────
   4. LIGHT THEME — mode pills (40% → 65%)
───────────────────────────────────────── */
[data-theme="light"] .mode-spec-pill {
  color: rgba(26,29,46,.65) !important;
  border-color: rgba(0,0,0,.13) !important;
}
[data-theme="light"] .mode-spec-pill:hover {
  color: #1a1d2e !important;
  background: rgba(59,107,224,.08) !important;
  border-color: rgba(59,107,224,.25) !important;
}
[data-theme="light"] .mode-spec-pill.active {
  color: #3B6BE0 !important;
  background: rgba(59,107,224,.12) !important;
  border-color: rgba(59,107,224,.3) !important;
}

/* ─────────────────────────────────────────
   5. LIGHT THEME — input e ferramentas
───────────────────────────────────────── */
[data-theme="light"] #chat-input {
  color: #0D1117;
}
[data-theme="light"] #chat-input::placeholder {
  color: rgba(26,29,46,.38);
}
[data-theme="light"] .disclaimer {
  color: rgba(26,29,46,.38);
}
[data-theme="light"] .tool-btn {
  color: rgba(26,29,46,.5);
}
[data-theme="light"] .tool-btn:hover {
  color: #1a1d2e;
  background: rgba(0,0,0,.06);
}
[data-theme="light"] .mode-pill {
  color: rgba(26,29,46,.55);
  border-color: rgba(0,0,0,.1);
}
[data-theme="light"] kbd {
  color: rgba(26,29,46,.55);
  background: rgba(0,0,0,.06);
  border-color: rgba(0,0,0,.12);
}
[data-theme="light"] #char-count {
  color: rgba(26,29,46,.45);
}

/* ─────────────────────────────────────────
   6. TEXTAREA AUTO-CRESCENTE
───────────────────────────────────────── */
#chat-input {
  resize: none;
  overflow-y: hidden;
  min-height: 26px;
  max-height: 240px;
  line-height: 1.65;
  transition: height .1s ease;
}
#chat-input.overflowing {
  overflow-y: auto;
}

/* ─────────────────────────────────────────
   7. ANIMAÇÕES DE ENTRADA DE MENSAGENS
───────────────────────────────────────── */
@keyframes msg-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes msg-slide-right {
  from { opacity: 0; transform: translateX(8px) translateY(6px); }
  to   { opacity: 1; transform: translateX(0) translateY(0); }
}
@keyframes av-pop {
  from { transform: scale(.55); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.msg.assistant {
  animation: msg-slide-in .3s cubic-bezier(.22,.68,0,1.1) both !important;
}
.msg.user {
  animation: msg-slide-right .28s cubic-bezier(.22,.68,0,1.1) both !important;
}
.msg .msg-av {
  animation: av-pop .3s cubic-bezier(.34,1.56,.64,1) both;
  animation-delay: .05s;
}

/* ─────────────────────────────────────────
   8. SKELETON LOADER
───────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -500px 0; }
  100% { background-position:  500px 0; }
}
.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 2px 0;
  min-width: 180px;
  max-width: 420px;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-surface)  50%,
    var(--bg-elevated) 75%
  );
  background-size: 500px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-line:nth-child(1) { width: 85%; }
.skeleton-line:nth-child(2) { width: 68%; animation-delay: .12s; }
.skeleton-line:nth-child(3) { width: 52%; animation-delay: .24s; }

/* ─────────────────────────────────────────
   9. CURSOR DE STREAMING
───────────────────────────────────────── */
.cursor-blink {
  display: inline-block;
  width: 2px;
  height: .88em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: cblink .7s step-end infinite;
}
@keyframes cblink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ─────────────────────────────────────────
   10. SYNTAX HIGHLIGHT (highlight.js)
───────────────────────────────────────── */
.code-body code.hljs,
.code-body code {
  background: transparent;
  font-family: var(--ff-m);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--tx-1);
}
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: #7AA3F5; }
.hljs-string, .hljs-attr                          { color: #86efac; }
.hljs-number, .hljs-literal                       { color: #F4A261; }
.hljs-comment, .hljs-quote                        { color: var(--tx-3); font-style: italic; }
.hljs-function .hljs-title, .hljs-title           { color: #c4b5fd; }
.hljs-variable, .hljs-params                      { color: #F2F4FC; }
.hljs-type                                        { color: #67e8f9; }
.hljs-attribute                                   { color: #F4A261; }
.hljs-meta                                        { color: var(--tx-3); }
.hljs-strong                                      { font-weight: 700; }
.hljs-emphasis                                    { font-style: italic; }

[data-theme="light"] .hljs-keyword               { color: #2563eb; }
[data-theme="light"] .hljs-string                { color: #16a34a; }
[data-theme="light"] .hljs-number                { color: #b45309; }
[data-theme="light"] .hljs-function .hljs-title,
[data-theme="light"] .hljs-title                 { color: #7c3aed; }
[data-theme="light"] .hljs-comment               { color: #9ca3af; }
[data-theme="light"] .hljs-variable,
[data-theme="light"] .hljs-params                { color: #1a1d2e; }

/* ─────────────────────────────────────────
   11. MARKDOWN — melhorias gerais
───────────────────────────────────────── */
.msg-cnt h1 { font-size: 1.15rem; font-weight: 800; margin: 1em 0 .4em; }
.msg-cnt h2 { font-size: 1.02rem; font-weight: 700; margin: .9em 0 .35em; }
.msg-cnt h3 { font-size: .93rem;  font-weight: 700; color: var(--accent-h); margin: .8em 0 .3em; }
.msg-cnt ul, .msg-cnt ol { margin: .5em 0 .5em 1.3em; line-height: 1.7; }
.msg-cnt li { margin: .2em 0; }
.msg-cnt li::marker { color: var(--accent); }
.msg-cnt blockquote {
  border-left: 3px solid var(--accent-g2);
  padding: .4em .85em;
  margin: .65em 0;
  color: var(--tx-3);
  font-style: italic;
  background: var(--bg-surface);
  border-radius: 0 var(--r-s) var(--r-s) 0;
}
.msg-cnt hr { border: none; border-top: 1px solid var(--bd); margin: .9em 0; }
.msg-cnt a {
  color: var(--accent-h);
  text-decoration: underline;
  text-decoration-color: rgba(122,163,245,.3);
  text-underline-offset: 3px;
}
.msg-cnt a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ─────────────────────────────────────────
   12. SCROLL SUAVE
───────────────────────────────────────── */
#chat-wrap { scroll-behavior: smooth; }

/* ─────────────────────────────────────────
   14. BOTÃO DELETAR CONVERSA
───────────────────────────────────────── */
.conv-item {
  position: relative;
}
.conv-del {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--tx-3);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: background .14s, color .14s;
}
.conv-item:hover .conv-del,
.conv-item:focus-within .conv-del {
  display: flex;
}
.conv-del:hover {
  background: rgba(239,83,80,.15);
  color: #ef5350;
}
[data-theme="light"] .conv-del:hover {
  background: rgba(208,56,74,.12);
  color: #d0384a;
}

/* ─────────────────────────────────────────
   15. CHECKOUT / PLANS MODAL — mobile fix
   No mobile o modal cobre a tela toda sem
   possibilidade de fechar.
───────────────────────────────────────── */
.plans-modal-box {
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  /* Ocupa a tela toda como bottom-sheet */
  #plans-modal {
    align-items: flex-end;
    padding: 0;
  }
  .plans-modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px 32px;
  }
  /* Alinha planos em coluna no mobile */
  .plans-cards {
    flex-direction: column;
  }
  /* Handle de arraste visual */
  .plans-modal-box::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--bd-m);
    border-radius: 2px;
    margin: 0 auto 16px;
  }
  /* Garante que o botão fechar é visível */
  .modal-hdr {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 1;
    padding-bottom: 12px;
    margin-bottom: 4px;
  }
  .btn-icon[onclick="closePlans()"] {
    width: 32px;
    height: 32px;
    background: var(--bg-elevated);
  }
}

/* ─────────────────────────────────────────
   16. LIGHT THEME — modal e overlay
───────────────────────────────────────── */
[data-theme="light"] .modal {
  background: var(--bg-base);
  border-color: var(--bd);
}
[data-theme="light"] .modal-hdr {
  background: var(--bg-base);
}
[data-theme="light"] .modal-ttl {
  color: var(--tx-1);
}
[data-theme="light"] .plans-modal-sub {
  color: var(--tx-2);
}
[data-theme="light"] .plan-card {
  background: var(--bg-surface);
  border-color: var(--bd);
}
[data-theme="light"] .plan-name,
[data-theme="light"] .plan-price {
  color: var(--tx-1);
}
[data-theme="light"] .plan-desc,
[data-theme="light"] .plan-feats li {
  color: var(--tx-2);
}

/* ─────────────────────────────────────────
   17. PLANS MODAL — CAROUSEL MOBILE
───────────────────────────────────────── */

/* Modal base — compacto */
.plans-modal-box {
  max-width: 860px;
  width: 95vw;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-xl, 20px);
}

/* Header fixo ao scrollar */
.plans-hdr-sticky {
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 2;
  padding-bottom: 10px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--bd);
}

/* Botão fechar bem visível */
.plans-close-btn {
  width: 34px !important;
  height: 34px !important;
  background: var(--bg-elevated) !important;
  border-radius: 50% !important;
  flex-shrink: 0;
}

/* Dots de navegação — só no mobile */
.plans-dots {
  display: none;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 4px;
}
.plans-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--bd-m);
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.plans-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* Carousel container */
.plans-carousel {
  overflow: hidden;
}

/* Desktop: grid normal */
.plans-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 4px 0 8px;
}

/* ── MOBILE ── */
@media (max-width: 640px) {
  /* Modal como bottom-sheet */
  #plans-modal {
    align-items: flex-end;
    padding: 0;
  }
  .plans-modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    padding: 16px 16px 28px;
  }
  /* Handle visual */
  .plans-modal-box::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--bd-m);
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  /* Dots visíveis */
  .plans-dots { display: flex; }

  /* Carousel horizontal com scroll snap */
  .plans-carousel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .plans-carousel::-webkit-scrollbar { display: none; }

  .plans-cards {
    display: flex;
    gap: 12px;
    padding: 4px 4px 8px;
    width: max-content;
  }

  /* Cada card ocupa ~85vw — cabe 1 por vez, dá hint do próximo */
  .plan-card {
    width: calc(100vw - 56px);
    max-width: 320px;
    scroll-snap-align: center;
    flex-shrink: 0;
  }
}
