/* ── Layout pagina chat ──────────────────────────────────────────── */
#chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--brand-bg);
}

/* ── Banner offline ──────────────────────────────────────────────── */
.chat-offline-banner {
  background: #FEF3C7;
  color: #92400E;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 8px 16px;
  border-bottom: 1px solid #FDE68A;
  flex-shrink: 0;
}

/* ── Overlay GDPR ────────────────────────────────────────────────── */
.gdpr-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.gdpr-overlay[hidden] {
  display: none;
}

.gdpr-card {
  background: var(--brand-bg);
  border-radius: 16px;
  border: 1px solid var(--brand-border);
  padding: 32px 24px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gdpr-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-primary-dark);
}

.gdpr-card p {
  font-size: 14px;
  color: var(--brand-text-light);
  line-height: 1.6;
}

/* ── Area messaggi ───────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Bubble messaggi ─────────────────────────────────────────────── */
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

/* Utente — destra, blu */
.chat-bubble-user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

/* Assistente — sinistra, grigio */
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--brand-surface);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
  border-bottom-left-radius: 4px;
}

/* Sistema / errori — centrato, rosso tenue */
.chat-bubble-system {
  align-self: center;
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  font-size: 13px;
  text-align: center;
  border-radius: 8px;
  max-width: 90%;
}

/* Cursore lampeggiante durante lo streaming */
.chat-bubble-streaming::after {
  content: '▋';
  display: inline-block;
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Card escalation ─────────────────────────────────────────────── */
.chat-escalation-card {
  align-self: stretch;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-escalation-card p {
  font-size: 14px;
  font-weight: 500;
  color: #92400E;
}

.chat-escalation-card small {
  font-size: 12px;
  color: #B45309;
}

/* ── Banner rate limit ───────────────────────────────────────────── */
.chat-ratelimit-banner {
  background: #FEF3C7;
  color: #92400E;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 8px 16px;
  border-top: 1px solid #FDE68A;
  flex-shrink: 0;
}

#chat-countdown {
  font-weight: 700;
}

/* ── Area input ──────────────────────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--brand-border);
  background: var(--brand-bg);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-family: var(--brand-font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--brand-text);
  background: var(--brand-surface);
  outline: none;
  overflow-y: hidden;
  max-height: 120px;
  transition: border-color 0.15s;
}

.chat-input:focus {
  border-color: var(--brand-secondary);
}

.chat-input:disabled {
  opacity: 0.5;
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-send-btn:active {
  background: var(--brand-primary-dark);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}
