/* Print'app — stile trascritto dal design di Claude design.
   Palette: menta #C3E1D7, rosa #F3D2F2, viola #7A1E6E, verde #1F6B54.
   Font grandi e bottoni ampi: interfaccia "a prova di boomer". */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  -webkit-font-smoothing: antialiased;
  font-family: 'Baloo 2', system-ui, sans-serif;
  background: #E3DBEA;
}

.app {
  max-width: 460px;
  min-height: 100vh;
  height: 100vh;
  min-height: 100dvh;   /* sui telefoni segue la barra del browser */
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, #C3E1D7 0%, #E3DBEA 48%, #F3D2F2 100%);
  color: #23202B;
  overflow: hidden;
  box-shadow: 0 0 46px rgba(120, 60, 110, 0.14);
}

/* Header */
.header {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid #E7C9E4;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  background: #FEF4E6; overflow: hidden;
  box-shadow: 0 3px 8px rgba(90, 30, 90, 0.20);
}
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.title {
  font-weight: 800; font-size: clamp(22px, 7vw, 29px); line-height: 1;
  color: #7A1E6E; text-shadow: 1.5px 1.5px 0 #F3D2F2; white-space: nowrap;
}
.title .script { font-family: 'Pacifico', cursive; font-weight: 400; font-size: 0.9em; }
.subtitle {
  font-size: clamp(11px, 3.6vw, 14px); font-weight: 700; color: #4A3D52;
  margin-top: 4px; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Thread */
.thread { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.thread-inner { display: flex; flex-direction: column; gap: 16px; padding: 18px 16px 14px; }
.row { display: flex; }
.row.studio { justify-content: flex-start; }
.row.user { justify-content: flex-end; }

@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.bubble {
  max-width: 86%; padding: 15px 18px; border-radius: 24px;
  font-size: 20px; line-height: 1.45; font-weight: 600;
  box-shadow: 0 3px 11px rgba(90, 40, 90, 0.12);
  animation: popIn .25s ease both; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble.studio { background: #fff; color: #23202B; border: 2px solid #EAD9E8; border-radius: 24px 24px 24px 8px; }
.bubble.user { background: #1F6B54; color: #fff; border: 2px solid #1F6B54; border-radius: 24px 24px 8px 24px; }
.bubble.suggestion { background: #F7DDF6; color: #5A1653; border: 3px solid #B14FA6; border-radius: 24px; font-weight: 700; }

/* Foto scelte */
.photos-cap { margin-bottom: 10px; }
.photos-aiuto {
  font-size: 15px; font-weight: 600; opacity: .85; margin: -4px 0 10px;
}
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 216px; max-width: 100%; }
/* Quando le foto si possono togliere servono anteprime più grandi e più spazio
   attorno, altrimenti la ✕ è impossibile da centrare col dito. */
.thumbs-larga {
  width: 100%; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.thumb-cella { position: relative; }
.thumb-togli {
  position: absolute; top: -8px; right: -8px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid #fff; background: #A32222; color: #fff;
  font-size: 16px; font-weight: 800; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35); padding: 0;
}
.thumb-togli:active { transform: scale(.9); }
.promemoria-foto {
  font-size: 17px; font-weight: 800; color: #4A3D52; margin-bottom: 4px; text-align: center;
}
.thumb {
  aspect-ratio: 1 / 1; border-radius: 12px; object-fit: cover; width: 100%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55); background: #cbb7c8;
}
.thumb-fallback { background: linear-gradient(135deg, #C3B8E7, #8567D3); }
.thumb-more { display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: rgba(0,0,0,.35); font-size: 22px; }

/* Barra di caricamento */
.prog-text { margin-bottom: 10px; }
.prog-track { height: 16px; border-radius: 10px; background: #E3EFE9; overflow: hidden; border: 2px solid #1F6B54; }
.prog-fill { height: 100%; width: 0; background: #1F6B54; border-radius: 8px; transition: width .3s ease; }

/* Riepiloghi */
.sum-title { font-weight: 800; font-size: 22px; margin-bottom: 10px; color: #7A1E6E; }
.sum-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #E1CFDF; }
.sum-unit { font-size: 16px; font-weight: 600; color: #5E5566; }
.sum-sub { font-weight: 800; white-space: nowrap; }
.sum-total { display: flex; justify-content: space-between; margin-top: 10px; font-size: 23px; font-weight: 800; }
.final-title { font-weight: 800; font-size: 23px; color: #7A1E6E; margin-bottom: 12px; }
.final-name { font-size: 19px; margin-bottom: 8px; }
.final-block { margin: 8px 0; border-top: 2px solid #EAD9E8; padding-top: 10px; }
.final-line { display: flex; justify-content: space-between; padding: 6px 0; }
.final-line b, .final-line .b { font-weight: 800; }
.final-grand { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 12px; border-top: 2px solid #EAD9E8; font-size: 25px; font-weight: 800; }

/* Composer (barra in basso) */
.composer {
  background: rgba(255, 255, 255, 0.93); backdrop-filter: blur(6px);
  border-top: 2px solid #E7C9E4;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.composer:empty { display: none; }
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.format {
  min-height: 68px; border-radius: 20px; border: 3px solid #1F6B54; background: #fff;
  color: #173F32; font-family: inherit; font-weight: 800; font-size: 21px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
/* Se i formati sono dispari, l'ultimo occupa tutta la riga (niente bottone "storto") */
.formats .format:last-child:nth-child(odd) { grid-column: 1 / -1; }
.format .fprice { font-size: 16px; font-weight: 700; color: #1F6B54; }
.actions { display: flex; flex-direction: column; gap: 12px; }
.action {
  width: 100%; min-height: 64px; border-radius: 30px; border: none; cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: 21px; color: #fff; text-align: center;
  background: #1F6B54; box-shadow: 0 5px 14px rgba(90, 30, 90, 0.25); padding: 0 20px;
}
/* Il bottone "Scegli le foto" è una <label>: apre la galleria col meccanismo
   nativo del browser, che funziona su tutti i telefoni. Va allineata come un
   bottone perché una label non lo è. */
label.action { display: flex; align-items: center; justify-content: center; }

/* L'input file resta invisibile ma NON display:none, altrimenti su Android
   la galleria non si apre. */
.file-invisibile {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.action.primary { background: #7A1E6E; }
.input-row { display: flex; gap: 10px; align-items: stretch; }
.text-input {
  flex: 1 1 auto; min-width: 0;   /* min-width:0 = si stringe e non schiaccia il tasto Invia */
  min-height: 60px; border-radius: 26px; border: 3px solid #B14FA6;
  padding: 0 20px; font-size: 20px; font-family: inherit; font-weight: 600;
  color: #23202B; outline: none; background: #fff;
}
.send-btn {
  flex: 0 0 auto;   /* larghezza fissa: non si deforma mai */
  min-height: 60px; border-radius: 26px; border: none; white-space: nowrap;
  background: #7A1E6E; color: #fff; font-size: 21px; font-weight: 800; cursor: pointer;
  padding: 0 26px; font-family: inherit;
}

/* --- Header: due tasti (aiuto + ricomincia) --- */
.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn {
  min-width: 48px; min-height: 48px; border-radius: 14px;
  border: 2px solid #B14FA6; background: #fff; color: #7A1E6E;
  font-size: 20px; font-weight: 800; cursor: pointer; line-height: 1;
}

/* --- Correzioni bottoni/righe che si tagliavano --- */
.action { line-height: 1.2; white-space: normal; padding: 10px 20px; }
.bubble.final { font-size: 18px; }
.final-line { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; align-items: baseline; }
/* L'etichetta a sinistra non si spezza a metà parola ("Pagament/o"):
   se serve spazio, è il valore a destra ad andare a capo. */
.final-line > div:first-child { flex: 0 0 auto; white-space: nowrap; }
.final-line > div:last-child { min-width: 0; text-align: right; }
.final-line .b, .final-grand > div:last-child { white-space: nowrap; }
.final-grand { gap: 14px; }

/* --- Pannello Domande frequenti --- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(40, 20, 45, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay[hidden] { display: none; }
.sheet {
  background: #fff; width: 100%; max-width: 460px; max-height: 90vh;
  border-radius: 24px 24px 0 0; display: flex; flex-direction: column;
  box-shadow: 0 -8px 40px rgba(90, 30, 90, 0.30);
  animation: popIn .2s ease both;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px; border-bottom: 2px solid #EAD9E8;
}
.sheet-title { font-weight: 800; font-size: 24px; color: #7A1E6E; }
.faq-search { padding: 14px 16px 4px; }
.faq-search input {
  width: 100%; min-height: 52px; border-radius: 18px; border: 2px solid #E7C9E4;
  padding: 0 16px; font-size: 18px; font-family: inherit; font-weight: 600; outline: none; background: #FBF6FB;
}
.faq-ask-btn {
  margin-top: 10px; width: 100%; min-height: 54px; border-radius: 18px; border: none;
  background: #7A1E6E; color: #fff; font-family: inherit; font-weight: 800; font-size: 18px;
  cursor: pointer; box-shadow: 0 4px 12px rgba(90, 30, 90, 0.25);
}
.faq-answer {
  margin: 4px 16px 8px; padding: 14px 16px; border-radius: 18px;
  background: #F7DDF6; border: 2px solid #B14FA6;
}
.faq-answer-label { font-weight: 800; font-size: 14px; color: #7A1E6E; letter-spacing: .3px; margin-bottom: 6px; }
.faq-answer-text { font-size: 18px; line-height: 1.5; font-weight: 600; color: #3A1636; white-space: pre-wrap; }
.faq-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 14px 6px; }
.faq-item { border: 2px solid #EAD9E8; border-radius: 18px; margin-bottom: 12px; overflow: hidden; }
.faq-q {
  width: 100%; text-align: left; background: #FBF3FB; border: none; cursor: pointer;
  padding: 16px 18px; font-family: inherit; font-weight: 800; font-size: 19px; color: #23202B;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.faq-q .chev { color: #B14FA6; flex: none; transition: transform .2s ease; }
.faq-item.open .faq-q .chev { transform: rotate(180deg); }
.faq-a {
  padding: 0 18px; max-height: 0; overflow: hidden;
  transition: max-height .28s ease, padding .28s ease;
  font-size: 18px; line-height: 1.5; font-weight: 600; color: #3A3340;
}
.faq-item.open .faq-a { padding: 4px 18px 18px; max-height: 1200px; }
.faq-empty { padding: 22px 18px; text-align: center; color: #7A6B78; font-weight: 600; font-size: 18px; line-height: 1.5; }
.sheet-links {
  display: flex; flex-direction: column; gap: 10px;
  margin: 8px 16px calc(16px + env(safe-area-inset-bottom));
}
.portfolio-link {
  display: block; text-align: center; text-decoration: none; background: #1F6B54;
  color: #fff; font-weight: 800; font-size: 19px; padding: 16px; border-radius: 20px;
}
.email-link {
  display: block; text-align: center; text-decoration: none; background: #fff;
  color: #7A1E6E; font-weight: 800; font-size: 18px; padding: 14px;
  border-radius: 20px; border: 2px solid #B14FA6;
  overflow-wrap: anywhere;
}

/* --- Bolla "sta scrivendo…" --- */
.bubble.typing {
  color: #7A6B78; font-size: 22px; letter-spacing: 4px; font-weight: 800;
  animation: typingPulse 1s ease-in-out infinite;
}
@keyframes typingPulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* --- Schermi piccoli (iPhone SE, Android compatti) --- */
@media (max-width: 380px) {
  .thread-inner { padding: 14px 12px 12px; }
  .bubble { font-size: 18px; padding: 13px 15px; }
  .composer { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .formats { gap: 10px; }
  .format { min-height: 60px; font-size: 19px; }
  .format .fprice { font-size: 14px; }
  .action { min-height: 58px; font-size: 19px; }
  .text-input { min-height: 54px; font-size: 18px; padding: 0 16px; }
  .send-btn { min-height: 54px; font-size: 19px; padding: 0 20px; }
  .logo { width: 46px; height: 46px; border-radius: 14px; }
  .icon-btn { min-width: 44px; min-height: 44px; font-size: 18px; }
  .header { padding: 10px 12px; }
}

/* --- Desktop: l'app resta una "card" centrata, comoda anche col mouse --- */
@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app {
    min-height: calc(100dvh - 48px);
    height: calc(100dvh - 48px);
    border-radius: 32px;
  }
}
