/* style.css — Bot AI Libertà di Stampa */
:root {
  --black:     #0a0a0a;
  --cream:     #f5f2ed;
  --red:       #c8401a;
  --red-dark:  #9c3114;
  --gold:      #e8a020;
  --white:     #ffffff;
  --gray:      #888;
  --border:    #e4dfd7;
  --bubble-bot: #ffffff;
  --radius:    12px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--black);
  font-size: 15px;
  line-height: 1.55;
}

/* ── Layout principale ──────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--cream);
  box-shadow: 0 0 40px rgba(0,0,0,.12);
  position: relative;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────── */
.chat-header {
  background: var(--black);
  padding: 14px 16px 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-sq {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--red); color: #fff;
  font-family: var(--font-head); font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.header-info { display: flex; flex-direction: column; }
.bot-name { color: #fff; font-weight: 600; font-size: 0.92rem; }
.bot-status { color: #aaa; font-size: 0.75rem; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.dot-online {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}
.header-badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  background: rgba(255,255,255,.1); color: #ccc;
  font-size: 0.7rem; padding: 3px 8px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.15);
  white-space: nowrap;
}

/* ── Area messaggi ──────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Bubble messaggi ────────────────────────────── */
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-bot  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.msg-user .bubble {
  background: var(--red);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.msg-bot .bubble {
  background: var(--bubble-bot);
  color: var(--black);
  border-bottom-left-radius: 3px;
}
.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 600; }
.bubble ul, .bubble ol { padding-left: 20px; margin: 6px 0; }
.bubble li { margin-bottom: 4px; }

/* Preventivo indicativo — bordo oro */
.bubble .preventivo-note {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  background: #fffbf2;
  color: #7a4a00;
  font-size: 0.82rem;
}

/* Allegato in bubble */
.bubble-attachment {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  max-width: 200px;
}
.bubble-attachment img { width: 100%; display: block; }
.bubble-attachment .att-file {
  background: rgba(0,0,0,.08);
  padding: 8px 12px;
  font-size: 0.82rem;
  display: flex; align-items: center; gap: 8px;
}

/* Timestamp */
.msg-time { font-size: 0.72rem; color: var(--gray); margin-top: 4px; }

/* ── Quick replies ───────────────────────────────── */
.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.qr-btn {
  background: transparent;
  border: 1.5px solid var(--red);
  color: var(--red);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.qr-btn:hover { background: var(--red); color: #fff; }

/* ── Typing indicator ───────────────────────────── */
.typing-wrap { padding: 0 14px 4px; flex-shrink: 0; }
.typing-wrap.hidden { display: none; }
.typing-bubble {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 12px 16px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gray);
  animation: bounce 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ── Preview allegato in input ───────────────────── */
.attachment-preview {
  background: #f0ede8;
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  flex-shrink: 0;
}
.attachment-preview.hidden { display: none; }
.att-inner { display: flex; align-items: center; gap: 10px; }
#att-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
#att-name { font-size: 0.82rem; color: #555; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-remove {
  background: none; border: none; font-size: 16px; cursor: pointer; color: var(--gray); padding: 4px;
}
.att-remove:hover { color: var(--red); }

/* ── Input area ──────────────────────────────────── */
.input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  flex-shrink: 0;
  position: relative;
}
.input-row { display: flex; align-items: flex-end; gap: 8px; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 6px; color: var(--gray);
  transition: color .2s; flex-shrink: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--red); }
.message-input {
  flex: 1; border: 1.5px solid var(--border); border-radius: 22px;
  padding: 9px 14px; font-family: var(--font-body); font-size: 0.92rem;
  resize: none; line-height: 1.4; max-height: 120px; overflow-y: auto;
  background: #faf9f7; color: var(--black); transition: border-color .2s;
}
.message-input:focus { outline: none; border-color: var(--red); }
.message-input::placeholder { color: #b0a898; }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--red); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s, transform .1s;
}
.send-btn:hover  { background: var(--red-dark); }
.send-btn:active { transform: scale(.93); }

/* ── Barra registrazione ─────────────────────────── */
.recording-bar {
  display: flex; align-items: center; gap: 10px;
  padding-top: 8px; font-size: 0.82rem; color: var(--red);
}
.recording-bar.hidden { display: none; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  animation: pulse-red 1s infinite;
  flex-shrink: 0;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(1.3); }
}
#rec-timer { font-weight: 700; min-width: 30px; }
.rec-cancel {
  background: none; border: none; cursor: pointer; color: var(--gray);
  font-size: 0.82rem; margin-left: auto; text-decoration: underline;
}

/* ── Drop zone ───────────────────────────────────── */
.drop-zone {
  display: none;
  position: absolute; inset: 0; background: rgba(200,64,26,.08);
  border: 2px dashed var(--red); border-radius: 8px;
  align-items: center; justify-content: center;
  font-weight: 600; color: var(--red); z-index: 10; pointer-events: none;
}
.drop-zone.active { display: flex; }

/* ── Footer ──────────────────────────────────────── */
.chat-footer {
  text-align: center;
  padding: 7px 12px;
  font-size: 0.7rem;
  color: #b0a898;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Responsive: desktop centra ─────────────────── */
@media (min-width: 500px) {
  body { display: flex; align-items: center; justify-content: center; }
  .chat-container { border-radius: 16px; height: min(96dvh, 820px); }
}

/* ── Animazioni ingresso messaggi ───────────────── */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg { animation: msg-in .25s ease; }

/* ── Markdown-like in bubble bot ────────────────── */
.bubble code {
  background: #f0ede8; padding: 2px 6px; border-radius: 4px;
  font-size: 0.85em; font-family: monospace;
}
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
