/* ============================================================
   Salão AI — Modal de Ajuda Contextual
   Paleta gold/beige integrada ao style-unified.css
   ============================================================ */

/* ── Overlay (backdrop) ───────────────────────────────────── */
/* PATCH #1 — backdrop puro, sem flex container; opacity fade. */
.ajuda-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  opacity: 0;
  transition: opacity .2s ease;
}
body.ajuda-aberta .ajuda-overlay {
  display: block;
  opacity: 1;
}

/* ── Drawer lateral (padrão Finance) ──────────────────────── */
/* PATCH #2 — drawer fixed right, slide-in via transform. */
.ajuda-modal {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  background: var(--surface, #fff);
  border-left: 1px solid var(--border, #E8DCC0);
  box-shadow: -2px 0 24px rgba(0, 0, 0, .18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  font-size: .88rem;
  color: var(--text, #2C1810);
  overflow: hidden;
}

/* PATCH #3 — drawer slide-in suave ao abrir */
body.ajuda-aberta .ajuda-modal {
  transform: translateX(0);
}

/* PATCH #5 — mobile (<640px): drawer vira full-screen */
@media (max-width: 640px) {
  .ajuda-modal {
    width: 100vw;
    border-left: 0;
  }
}

/* ── Header ───────────────────────────────────────────────── */
.ajuda-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: linear-gradient(135deg, var(--brand-light, #F8F1E4), var(--brand-ultra, #FCF8F1));
  border-bottom: 1px solid var(--border, #E8DCC0);
}

.ajuda-titulo-wrap {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-weight: 700;
  font-size: .9rem;
  color: var(--brand-dark, #2C1810);
}

.ajuda-icone {
  font-size: 1rem;
  filter: drop-shadow(0 1px 1px rgba(184,149,79,.3));
}

.ajuda-close {
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-3, #8B7355);
  padding: .25rem .5rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.ajuda-close:hover {
  background: rgba(184, 149, 79, .12);
  color: var(--brand-dark, #2C1810);
}

/* ── Abas ─────────────────────────────────────────────────── */
.ajuda-abas {
  display: flex;
  border-bottom: 1px solid var(--border, #E8DCC0);
  background: var(--surface-2, #FAF6EE);
}
.ajuda-aba {
  flex: 1;
  padding: .6rem .5rem;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-3, #8B7355);
  transition: color .15s, border-color .15s, background .15s;
}
.ajuda-aba:hover {
  color: var(--text, #2C1810);
  background: rgba(184, 149, 79, .06);
}
.ajuda-aba-ativa {
  color: var(--brand, #B8954F);
  border-bottom-color: var(--brand, #B8954F);
  font-weight: 700;
  background: var(--surface, #fff);
}

/* ── Body ─────────────────────────────────────────────────── */
.ajuda-body {
  flex: 1;
  overflow-y: auto;
  padding: .8rem 1rem;
  background: var(--surface, #fff);
}

.ajuda-section-title {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-3, #8B7355);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
  padding-bottom: .3rem;
  border-bottom: 1px dashed var(--border, #E8DCC0);
}

/* ── FAQ items ────────────────────────────────────────────── */
.ajuda-faq-item {
  border: 1px solid var(--border, #E8DCC0);
  border-radius: 8px;
  margin-bottom: .4rem;
  padding: .55rem .75rem;
  font-size: .8rem;
  background: var(--surface, #fff);
  transition: border-color .15s, box-shadow .15s;
}
.ajuda-faq-item[open] {
  border-color: var(--brand, #B8954F);
  box-shadow: 0 2px 8px rgba(184, 149, 79, .08);
}
.ajuda-faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text, #2C1810);
  outline: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.ajuda-faq-item summary::-webkit-details-marker { display: none; }
.ajuda-faq-item summary::before {
  content: '›';
  font-size: 1.05rem;
  color: var(--brand, #B8954F);
  transition: transform .2s;
  display: inline-block;
}
.ajuda-faq-item[open] summary::before { transform: rotate(90deg); }
.ajuda-faq-item p {
  margin: .45rem 0 0 1rem;
  color: var(--text-2, #4A3520);
  line-height: 1.45;
}
.ajuda-faq-hist summary {
  font-weight: 500;
  color: var(--text-2, #4A3520);
}

/* ── Estados vazios ───────────────────────────────────────── */
.ajuda-empty {
  text-align: center;
  padding: 1.25rem .5rem;
  color: var(--text-3, #8B7355);
  font-size: .85rem;
  font-style: italic;
  background: var(--surface-2, #FAF6EE);
  border-radius: 8px;
}
.ajuda-spinner {
  text-align: center;
  padding: 1rem;
  color: var(--text-3, #8B7355);
  font-size: .82rem;
}

.ajuda-hint {
  text-align: center;
  padding: 1.1rem 1rem;
  color: var(--text-2, #4A3520);
  font-size: .82rem;
  line-height: 1.5;
}
.ajuda-hint small {
  display: block;
  margin-top: .5rem;
  color: var(--text-3, #8B7355);
  font-size: .74rem;
}

/* ── Feedback (👍/👎) ─────────────────────────────────────── */
.ajuda-feedback {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .6rem;
  padding-top: .5rem;
  border-top: 1px dashed var(--border, #E8DCC0);
  flex-wrap: wrap;
}
.ajuda-feedback-label {
  font-size: .72rem;
  color: var(--text-3, #8B7355);
  font-weight: 600;
}
.ajuda-fb-btn {
  background: transparent;
  border: 1px solid var(--border, #E8DCC0);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: .9rem;
  transition: background .12s, border-color .12s;
}
.ajuda-fb-btn:hover { background: var(--surface-2, #FAF6EE); }
.ajuda-fb-ok { background: #ECFDF5; border-color: #10B981; }
.ajuda-fb-no { background: #FEE2E2; border-color: #EF4444; }

.ajuda-badge-fonte {
  margin-left: auto;
  font-size: .65rem;
  background: var(--surface-2, #FAF6EE);
  color: var(--text-3, #8B7355);
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}
.ajuda-badge-llm {
  background: rgba(184, 149, 79, .15);
  color: var(--brand-dark, #2C1810);
}
.ajuda-badge-util {
  font-size: .68rem;
  color: #059669;
  font-weight: 600;
  margin-left: .25rem;
}

/* ── Pergunte: input ──────────────────────────────────────── */
.ajuda-input-wrap {
  display: flex;
  gap: .65rem;
  align-items: flex-end;
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--border, #E8DCC0);
  background: var(--surface-2, #FAF6EE);
}
.ajuda-input-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .3rem;
  min-width: 0;
}
.ajuda-input {
  width: 100%;
  padding: .5rem .7rem;
  font-size: .82rem;
  border: 1px solid var(--border, #E8DCC0);
  border-radius: 6px;
  resize: none;
  font-family: inherit;
  background: var(--surface, #fff);
  color: var(--text, #2C1810);
  transition: border-color .15s, box-shadow .15s;
}
.ajuda-input:focus {
  outline: none;
  border-color: var(--brand, #B8954F);
  box-shadow: 0 0 0 3px rgba(184, 149, 79, .12);
}
.ajuda-input-erro {
  font-size: .72rem;
  color: #DC2626;
  display: none;
}
.ajuda-input-hint {
  font-size: .68rem;
  color: var(--text-3, #8B7355);
  line-height: 1.4;
}
.ajuda-send {
  padding: .6rem 1.05rem;
  font-size: .85rem;
  font-weight: 700;
  background: var(--brand, #B8954F);
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
  align-self: flex-end;
}
.ajuda-send:hover:not(:disabled) {
  background: var(--brand-dark, #2C1810);
  transform: translateY(-1px);
}
.ajuda-send:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Chat messages (aba Pergunte) ─────────────────────────── */
.ajuda-msg {
  margin-bottom: .75rem;
  padding: .65rem .9rem;
  border-radius: 10px;
  font-size: .87rem;
  line-height: 1.5;
  max-width: 85%;
}
.ajuda-msg-user {
  background: var(--brand, #B8954F);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 2px;
}
.ajuda-msg-bot {
  background: var(--surface-2, #FAF6EE);
  color: var(--text, #2C1810);
  margin-right: auto;
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border, #E8DCC0);
}

/* ── Scrollbar customizada ────────────────────────────────── */
.ajuda-body::-webkit-scrollbar { width: 6px; }
.ajuda-body::-webkit-scrollbar-track { background: var(--surface-2, #FAF6EE); }
.ajuda-body::-webkit-scrollbar-thumb {
  background: rgba(184, 149, 79, .4);
  border-radius: 3px;
}
.ajuda-body::-webkit-scrollbar-thumb:hover { background: var(--brand, #B8954F); }

/* ── Botão de Ajuda no topbar (pill — padrão Master Finance) ─────────────
   Cobre tanto .topbar-ajuda-btn (HTML atual do Salão) quanto .ajuda-btn-topbar
   (compatibilidade reversa caso o markup antigo ainda exista em algum lugar). */
.topbar-ajuda-btn,
.ajuda-btn-topbar {
  display: inline-flex !important;
  align-items: center;
  gap: .35rem;
  background: transparent;
  border: 1.5px solid var(--border, #E8DCC0);
  border-radius: 20px;
  padding: .32rem .75rem;
  cursor: pointer;
  color: var(--text-2, #4A3520);
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  margin-right: .5rem;
  transition: background .15s, border-color .15s, color .15s;
}
.topbar-ajuda-btn:hover,
.ajuda-btn-topbar:hover {
  background: var(--brand-ultra, #FCF8F1);
  border-color: var(--brand, #B8954F);
  color: var(--brand, #B8954F);
}
.topbar-ajuda-btn:focus-visible,
.ajuda-btn-topbar:focus-visible {
  outline: none;
  border-color: var(--brand, #B8954F);
  box-shadow: 0 0 0 3px rgba(184, 149, 79, .25);
}
.topbar-ajuda-btn span[aria-hidden="true"],
.ajuda-btn-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1;
}
.topbar-ajuda-label,
.ajuda-btn-label { display: inline; }
@media (max-width: 480px) {
  .topbar-ajuda-label,
  .ajuda-btn-label { display: none; }
  .topbar-ajuda-btn,
  .ajuda-btn-topbar { padding: .32rem .45rem; }
}

/* ── Quando modal aberto ──────────────────────────────────── */
body.ajuda-aberta { overflow: hidden; }
