/* ==========================================================================
   FamilyHub.lu V2 — Estilos: chat, cartas, CV, parceiros, impressão
   ========================================================================== */

/* ---------- Banner de configuração da IA ---------- */
.ai-setup-banner {
  padding: var(--spacing);
  margin: var(--spacing) 0;
  background: #FFF4E0;
  border: 2px solid var(--color-warning);
  border-radius: var(--radius);
}
.ai-setup-banner h2 { margin: 0 0 6px; font-size: 1.1rem; }
.ai-setup-banner p { margin: 0; font-size: 0.95rem; }
body.dark-mode .ai-setup-banner { background: #2E2716; }

/* ---------- Chat ---------- */
.chat-box {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: var(--spacing);
}

.chat-messages {
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: #EDF1F5;
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}
body.dark-mode .chat-msg.assistant { background: #262B33; }

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: var(--spacing);
  flex-wrap: wrap;
}
.chat-input-row input[type="text"] {
  flex: 1;
  min-width: 180px;
  max-width: none;
}
.chat-mic {
  /* Evita que o gesto de "segurar para falar" dispare scroll/zoom no telemóvel
     e evita selecionar texto ao manter o botão premido. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.chat-mic[aria-pressed="true"] {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
  animation: fh-pulse 1.2s ease-in-out infinite;
}
@keyframes fh-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-mic[aria-pressed="true"] { animation: none; }
}
.chat-mic-hint {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--color-text-muted, #667085);
}
body.dark-mode .chat-mic-hint { color: #9AA5B1; }

#chat-tts-toggle { margin-top: 10px; }
#chat-tts-toggle[aria-pressed="true"] {
  background: #E3ECF4;
  border-color: var(--color-primary);
}

/* ---------- Cartas ---------- */
.file-label { cursor: pointer; }
#letter-form { margin-top: var(--spacing); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.letter-result {
  margin-top: var(--spacing);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: var(--spacing);
}

#letter-reply-body { width: 100%; font-family: inherit; font-size: 1rem;
  padding: 12px 16px; border: 2px solid var(--color-border); border-radius: var(--radius); }
#letter-reply-subject { max-width: none; width: 100%; }

/* ---------- CV ---------- */
textarea {
  width: 100%;
  max-width: 560px;
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 16px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  line-height: 1.5;
}
textarea:focus { border-color: var(--color-primary); }

.cv-photo-preview {
  display: block;
  width: 110px;
  height: 140px;
  object-fit: cover;
  margin-top: 10px;
  border-radius: 8px;
  border: 2px solid var(--color-border);
}

.cv-sheet {
  background: #fff;
  color: #1F2430;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 32px;
  max-width: 780px;
  margin-top: var(--spacing);
}
.cv-sheet .cv-header { display: flex; gap: 24px; align-items: flex-start; }
.cv-sheet .cv-header img {
  width: 110px; height: 140px; object-fit: cover; border-radius: 6px;
}
.cv-sheet h2.cv-name-h { font-size: 1.9rem; margin: 0; color: #1F2430; }
.cv-sheet .cv-title-line { color: #2C5F8A; font-weight: 600; margin: 4px 0; }
.cv-sheet .cv-contact-line { color: #444B57; font-size: 0.95rem; }
.cv-sheet h3 {
  color: #2C5F8A;
  text-transform: uppercase;
  font-size: 1rem;
  letter-spacing: 0.06em;
  border-bottom: 2px solid #E3ECF4;
  padding-bottom: 4px;
  margin: 22px 0 8px;
}
.cv-sheet .cv-exp-head { font-weight: 700; }
.cv-sheet .cv-exp-meta { color: #444B57; font-size: 0.92rem; }
.cv-sheet ul { margin: 6px 0; padding-left: 22px; }
.cv-sheet li { margin: 2px 0; }

/* ---------- Carta de Motivação ---------- */
.letter-sheet {
  background: #fff;
  color: #1F2430;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 40px;
  max-width: 780px;
  margin-top: var(--spacing);
  line-height: 1.6;
}
.letter-sheet .letter-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1F2430;
  margin-bottom: 2px;
}
.letter-sheet .letter-contact {
  font-size: 0.9rem;
  color: #444B57;
  margin-bottom: 20px;
}
.letter-sheet .letter-date {
  font-size: 0.95rem;
  color: #444B57;
  margin-bottom: 20px;
}
.letter-sheet .letter-recipient {
  font-size: 0.95rem;
  color: #1F2430;
  margin-bottom: 20px;
  line-height: 1.5;
}
.letter-sheet .letter-subject {
  font-size: 0.95rem;
  color: #1F2430;
  margin-bottom: 20px;
  font-weight: 500;
}
.letter-sheet p {
  margin: 12px 0;
  text-align: justify;
  font-size: 0.95rem;
}
.letter-sheet .letter-signature {
  font-weight: 600;
  margin-top: 32px;
  font-size: 0.95rem;
}

/* ---------- Impressão: CV e Carta ---------- */
@media print {
  body * { visibility: hidden; }
  #cv-print-area, #cv-print-area *,
  #letter-print-area, #letter-print-area * { visibility: visible; }
  #cv-print-area,
  #letter-print-area {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    border: none;
    padding: 0;
  }
  header, footer, .no-print { display: none !important; }
}

/* ---------- Parceiros ---------- */
#partner-form h2 { color: var(--color-primary-dark); }
#partner-message { max-width: 560px; }

@media (max-width: 640px) {
  .chat-messages { max-height: 320px; }
  .cv-sheet { padding: 18px; }
  .cv-sheet .cv-header { flex-direction: column; }
}

/* ==========================================================================
   V3 — Guia de voz, serviços, ditado
   ========================================================================== */

.voice-guide-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #E3ECF4;
  border-bottom: 2px solid var(--color-primary);
}
.voice-guide-bar[hidden] { display: none; }
.voice-guide-bar p { margin: 0; font-weight: 600; max-width: none; }
body.dark-mode .voice-guide-bar { background: #26303C; }

#voice-guide-btn.voice-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary-dark);
}

.services-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.service-card { border-left-color: var(--color-primary); }
.service-card h3 { font-size: 1.15rem; }
.service-card .btn { margin-top: 8px; }

/* ---------- Feedback de testadores ---------- */
.footer-feedback-btn { margin-top: var(--spacing); }
#feedback-modal .radio-group label.radio-option { min-width: 64px; justify-content: center; }

.dictate-btn {
  margin: 6px 0 10px;
  font-size: 0.9rem;
  padding: 8px 14px;
}
.dictate-btn[aria-pressed="true"] {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
}

/* ---- V4: painel expandido de parceiros + interesse das famílias ---- */
#partner-panel h2 { color: var(--color-primary-dark); }
.partner-stats {
  background: var(--color-bg-alt, #f4f7fa);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 12px 0 20px;
}
.partner-stats .value { margin: 0; font-size: 1.1rem; font-weight: 700; }
.partner-stats .helper-text { margin: 4px 0 0; }
.partner-ratio-result { margin-top: 10px; }
.partner-ratio-result .field-status { display: block; margin: 6px 0; }
#partner-interest-section { margin-top: 28px; }
#partner-interest-list .result-card h4 { margin: 0 0 4px; }
#partner-interest-list .result-card p { margin: 2px 0; }
#detail-interesse { white-space: nowrap; }
