/* ---- INTROTERAPIA CHAT ---- */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300&family=DM+Sans:wght@300;400&display=swap');

body.introterapia-active { overflow: hidden; }
body.introterapia-active #wpadminbar,
body.introterapia-active header,
body.introterapia-active footer,
body.introterapia-active nav,
body.introterapia-active aside,
body.introterapia-active .site-header,
body.introterapia-active .site-footer { display: none !important; }

#introterapia-app {
  --bg:          #0E0D0B;
  --surface:     #1A1915;
  --border:      rgba(255,255,255,0.07);
  --text:        #E2DDD4;
  --muted:       rgba(226,221,212,0.4);
  --accent:      #8FB3A0;
  --chip-bg:     rgba(143,179,160,0.08);
  --chip-border: rgba(143,179,160,0.22);
  --error:       #C4756A;
  --font-size:   14px;

  position:      fixed;
  top:           0; left: 0;
  width:         100%; height: 100dvh;
  z-index:       99999;
  overflow:      hidden;
  background:    var(--bg);
  color:         var(--text);
  font-family:   'DM Sans', sans-serif;
  font-weight:   300;
  display:       flex;
  flex-direction: column;
  align-items:   center;
  transition:    background 0.3s, color 0.3s;
}

#introterapia-app[data-theme="light"] {
  --bg:          #E8E5E0;
  --surface:     #D8D4CE;
  --border:      rgba(0,0,0,0.08);
  --text:        #2A2825;
  --muted:       rgba(42,40,37,0.38);
  --accent:      #5F9680;
  --chip-bg:     rgba(95,150,128,0.08);
  --chip-border: rgba(95,150,128,0.25);
}

/* ---- HEADER ---- */
#intro-header {
  width: 100%; display: flex; align-items: center;
  justify-content: center; padding: 1.4rem 1.2rem 0.8rem;
  flex-shrink: 0; position: relative; gap: 1rem;
}
#intro-header h1 {
  font-family: 'Cormorant Garamond', serif; font-weight: 300;
  font-size: clamp(1.4rem, 4vw, 2.2rem); letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text); margin: 0;
}
#intro-header h1 .ia { color: var(--accent); }

/* Controlos do topo direito */
#intro-controls {
  position: absolute; right: 1.2rem; top: 50%;
  transform: translateY(-50%);
  display: flex; align-items: center; gap: 0.4rem;
}

#intro-fontsize {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-family: 'DM Sans', sans-serif; font-weight: 300;
  font-size: 0.72rem; padding: 0.3rem 0.5rem; cursor: pointer;
  transition: color 0.2s, border-color 0.2s; letter-spacing: 0.02em;
  white-space: nowrap;
}
#intro-fontsize:hover { color: var(--text); border-color: var(--accent); }

#intro-search-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 30px; height: 28px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: border-color 0.2s;
}
#intro-search-btn svg {
  width: 13px; height: 13px; stroke: var(--muted); fill: none;
  stroke-width: 2; stroke-linecap: round;
  transition: stroke 0.2s;
}
#intro-search-btn:hover svg { stroke: var(--text); }
#intro-search-btn:hover { border-color: var(--accent); }

/* Toggle tema */
#intro-theme-toggle {
  width: 38px; height: 22px; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center;
  padding: 2px 3px; transition: background 0.3s;
}
#intro-theme-toggle::after {
  content: ''; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform 0.3s, background 0.3s;
}
#introterapia-app[data-theme="light"] #intro-theme-toggle::after {
  transform: translateX(16px); background: var(--accent);
}

/* ---- SEARCH OVERLAY ---- */
#intro-search-overlay {
  width: 100%; max-width: 620px; flex-shrink: 0;
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0 1.4rem 0.6rem;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#intro-search-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.5rem 0.8rem; font-family: 'DM Sans', sans-serif;
  font-weight: 300; font-size: 0.88rem; color: var(--text); outline: none;
  transition: border-color 0.2s;
}
#intro-search-input:focus { border-color: var(--accent); }
#intro-search-input::placeholder { color: var(--muted); }
#intro-search-count {
  font-size: 0.72rem; color: var(--muted); white-space: nowrap; min-width: 40px;
  text-align: center;
}
#intro-search-prev, #intro-search-next {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: border-color 0.2s;
}
#intro-search-prev svg, #intro-search-next svg {
  width: 12px; height: 12px; stroke: var(--muted); fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 0.2s;
}
#intro-search-prev:hover svg, #intro-search-next:hover svg { stroke: var(--text); }
#intro-search-close {
  background: none; border: none; color: var(--muted); font-size: 1rem;
  cursor: pointer; padding: 0 0.2rem; transition: color 0.2s; line-height: 1;
}
#intro-search-close:hover { color: var(--text); }
.intro-search-highlight {
  background: rgba(143,179,160,0.3); border-radius: 2px;
}
.intro-search-highlight.intro-search-current {
  background: rgba(143,179,160,0.6);
}

/* ---- MESSAGES ---- */
#intro-messages {
  flex: 1; width: 100%; max-width: 620px;
  overflow-y: auto; padding: 0.5rem 1.4rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.8rem;
  scroll-behavior: smooth;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
/* Font sizes */
#intro-messages.fs-12 .intro-msg { font-size: 12px; }
#intro-messages.fs-14 .intro-msg { font-size: 14px; }
#intro-messages.fs-16 .intro-msg { font-size: 16px; }

.intro-msg {
  max-width: 82%; padding: 0.75rem 1rem; border-radius: 14px;
  font-size: var(--font-size); line-height: 1.65; position: relative;
}
.intro-msg--user {
  align-self: flex-end; background: var(--accent); color: #0E0D0B;
  border-bottom-right-radius: 4px;
}
.intro-msg--assistant {
  align-self: flex-start; background: var(--surface);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.intro-msg--error { align-self: center; color: var(--error); font-size: 0.8rem; background: none; }

/* Acções por mensagem */
.intro-msg__actions {
  position: absolute; top: -28px; right: 0;
  display: none; gap: 0.3rem; align-items: center;
}
.intro-msg--user .intro-msg__actions { right: 0; }
.intro-msg--assistant .intro-msg__actions { left: 0; right: auto; }
.intro-msg:hover .intro-msg__actions { display: flex; }

.intro-msg-action {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.intro-msg-action:hover { border-color: var(--accent); }
.intro-msg-action--del:hover { border-color: var(--error); }
.intro-msg-action svg {
  width: 12px; height: 12px; stroke: var(--muted); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 0.2s;
}
.intro-msg-action:hover svg { stroke: var(--text); }
.intro-msg-action--del:hover svg { stroke: var(--error); }

/* TYPING */
.intro-typing { display: flex; gap: 5px; align-items: center; padding: 0.75rem 1rem; }
.intro-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: introBounce 1.2s infinite;
}
.intro-typing span:nth-child(2) { animation-delay: 0.2s; }
.intro-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes introBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ---- NAVEGAÇÃO LATERAL ---- */
#intro-nav {
  position: fixed; right: 1rem; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 0.3rem;
  z-index: 100001;
}
#intro-nav button {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
#intro-nav button:hover { border-color: var(--accent); }
#intro-nav button svg {
  width: 14px; height: 14px; stroke: var(--muted); fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 0.2s;
}
#intro-nav button:hover svg { stroke: var(--text); }
#intro-nav-bottom {
  margin-top: 0.3rem;
}

/* ---- CHIPS ---- */
#intro-chips {
  display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center;
  width: 100%; max-width: 620px; padding: 0 1.4rem 0.8rem; flex-shrink: 0;
}
.intro-chip {
  background: var(--chip-bg); border: 1px solid var(--chip-border);
  border-radius: 100px; padding: 0.4rem 0.9rem; font-size: 0.78rem;
  font-family: 'DM Sans', sans-serif; font-weight: 300; color: var(--muted);
  cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.intro-chip:hover {
  background: rgba(143,179,160,0.14); border-color: var(--accent); color: var(--text);
}

/* ---- BOTTOM ---- */
#intro-bottom {
  width: 100%; max-width: 620px; padding: 0 1.4rem 1.2rem;
  flex-shrink: 0; display: flex; flex-direction: column; gap: 0.6rem;
}

/* INPUT */
#intro-input-area {
  display: flex; align-items: flex-end; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.8rem 1rem; transition: border-color 0.3s;
}
#intro-input-area:focus-within { border-color: rgba(143,179,160,0.35); }
#intro-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: 'DM Sans', sans-serif; font-weight: 300; font-size: 0.92rem;
  color: var(--text); resize: none; max-height: 120px; line-height: 1.5;
}
#intro-input::placeholder { color: var(--muted); }
#intro-send {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  border: none; cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: opacity 0.2s, transform 0.2s;
}
#intro-send:hover  { opacity: 0.85; transform: scale(1.05); }
#intro-send:disabled { opacity: 0.35; cursor: default; transform: none; }
#intro-send svg { width: 14px; height: 14px; fill: #0E0D0B; }

/* AUTH PANEL */
#intro-auth-panel {
  background: var(--surface); border: 1px solid var(--chip-border);
  border-radius: 14px; padding: 1.2rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}
#intro-auth-msg { font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
#intro-email {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.9rem; font-family: 'DM Sans', sans-serif; font-weight: 300;
  font-size: 0.9rem; color: var(--text); outline: none; transition: border-color 0.3s;
}
#intro-email:focus { border-color: var(--accent); }
#intro-email::placeholder { color: var(--muted); }
#intro-auth-send {
  align-self: flex-start; background: var(--accent); color: #0E0D0B; border: none;
  border-radius: 8px; padding: 0.55rem 1.2rem; font-family: 'DM Sans', sans-serif;
  font-weight: 400; font-size: 0.85rem; cursor: pointer; transition: opacity 0.2s;
}
#intro-auth-send:hover    { opacity: 0.85; }
#intro-auth-send:disabled { opacity: 0.4; cursor: default; }
#intro-auth-feedback { font-size: 0.78rem; color: var(--muted); }

/* FOOTER */
#intro-footer-bar {
  display: flex; justify-content: space-between; align-items: center; min-height: 20px;
}
#intro-status { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; }
#intro-logout {
  background: none; border: none; color: var(--muted); font-size: 0.72rem;
  font-family: 'DM Sans', sans-serif; cursor: pointer; letter-spacing: 0.04em;
  transition: color 0.2s;
}
#intro-logout:hover { color: var(--text); }

/* NOTA LEGAL */
#intro-legal {
  text-align: center; font-size: 0.65rem;
  color: rgba(226,221,212,0.12); letter-spacing: 0.06em;
  text-transform: uppercase;
}
#introterapia-app[data-theme="light"] #intro-legal { color: rgba(42,40,37,0.12); }

/* Toast de cópia */
#intro-toast {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.78rem;
  color: var(--muted); z-index: 100002; pointer-events: none;
  opacity: 0; transition: opacity 0.2s;
}
#intro-toast.visible { opacity: 1; }
