/* =========================================================
   STUDIO SCAPUZZI RUSCIANO — Calcolatore Costo del Lavoro
   ========================================================= */

/* ---- Variabili ---- */
:root {
  --navy:   #1B2F5E;
  --gold:   #C9A84C;
  --white:  #FFFFFF;
  --light:  #F5F7FA;
  --gray:   #6B7280;
  --gray-light: #E5E7EB;
  --danger: #DC2626;
  --success:#16A34A;
  --shadow: 0 2px 12px rgba(27,47,94,.10);
  --radius: 8px;
  --font-title: 'Playfair Display', Georgia, serif;
  --font-body:  'Source Sans 3', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: #1f2937;
  background: var(--light);
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.hidden { display: none !important; }

/* =========================================================
   HEADER
   ========================================================= */
.site-header {
  background: var(--navy);
  color: var(--white);
  padding: .9rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.logo-img {
  height: 52px;
  width: auto;
  border-radius: 4px;
  background: var(--white);
  padding: 3px;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.studio-name {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .02em;
}

.studio-claim {
  font-size: .78rem;
  color: var(--gold);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.header-contacts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .2rem;
}

.header-phone,
.header-web {
  color: var(--gold);
  font-size: .875rem;
  font-weight: 500;
}

.header-phone:hover,
.header-web:hover { color: var(--white); text-decoration: underline; }

/* =========================================================
   SEZIONI
   ========================================================= */
section { padding: 3rem 0; }

.section-title {
  font-family: var(--font-title);
  font-size: 1.9rem;
  color: var(--navy);
  margin-bottom: .5rem;
}

.badge-anno {
  background: var(--gold);
  color: var(--white);
  font-family: var(--font-body);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 20px;
  vertical-align: middle;
  letter-spacing: .05em;
}

.section-subtitle {
  color: var(--gray);
  margin-bottom: 2rem;
  font-size: 1rem;
}

/* =========================================================
   CARD
   ========================================================= */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  border-top: 4px solid var(--navy);
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--navy);
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--gray-light);
  padding-bottom: .6rem;
}

/* =========================================================
   CALCOLATORE — LAYOUT
   ========================================================= */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 820px) {
  .calc-layout { grid-template-columns: 1fr; }
}

/* =========================================================
   FORM
   ========================================================= */
.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .4rem;
  color: var(--navy);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group textarea {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  color: #1f2937;
  transition: border-color .2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27,47,94,.12);
}

.form-error {
  display: block;
  font-size: .82rem;
  color: var(--danger);
  margin-top: .3rem;
  min-height: 1.1em;
}

/* Radio buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-top: .2rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: .65rem;
  cursor: pointer;
  font-size: .95rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  border: 1.5px solid var(--gray-light);
  transition: border-color .2s, background .2s;
}

.radio-option:hover { border-color: var(--navy); background: var(--light); }

.radio-option input[type="radio"] { display: none; }

.radio-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: border-color .2s;
}

.radio-option input[type="radio"]:checked ~ .radio-custom {
  border-color: var(--navy);
  background: var(--navy);
  box-shadow: inset 0 0 0 4px var(--white);
}

.radio-option input[type="radio"]:checked ~ span:last-child { font-weight: 600; }
.radio-option input[type="radio"]:checked + .radio-custom + span { color: var(--navy); }

.radio-option em { font-size: .8rem; color: var(--gray); font-style: normal; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1.4rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s, transform .1s;
  white-space: nowrap;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.btn-primary:hover { background: #14245a; border-color: #14245a; text-decoration: none; color: var(--white); }

.btn-secondary {
  background: var(--light);
  color: var(--navy);
  border-color: var(--gray-light);
}
.btn-secondary:hover { background: var(--gray-light); text-decoration: none; }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-outline:hover { background: var(--navy); color: var(--white); text-decoration: none; }

.btn-whatsapp {
  background: #25D366;
  color: var(--white);
  border-color: #25D366;
}
.btn-whatsapp:hover { background: #1da855; border-color: #1da855; text-decoration: none; color: var(--white); }

.btn-block { width: 100%; }

/* =========================================================
   RISULTATI
   ========================================================= */
.results-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray);
}

.placeholder-icon { font-size: 3rem; margin-bottom: 1rem; }

.badge-indicativo {
  background: #FFF3CD;
  border-left: 4px solid var(--gold);
  color: #92400E;
  padding: .65rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .84rem;
  margin-bottom: 1.25rem;
  font-weight: 500;
}

/* Tabella prospetto */
.prospetto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
  margin-bottom: 1.5rem;
}

.prospetto-table th {
  background: var(--navy);
  color: var(--white);
  padding: .6rem .9rem;
  text-align: left;
  font-weight: 600;
}

.prospetto-table td {
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--gray-light);
}

.prospetto-table tr:nth-child(even) td { background: var(--light); }

.prospetto-table tr.row-total td {
  font-weight: 700;
  background: #EEF2FB;
  border-top: 2px solid var(--navy);
  color: var(--navy);
}

.prospetto-table tr.row-separator td {
  border-bottom: 2px solid var(--navy);
  padding-bottom: 0;
  height: 4px;
  background: var(--light);
}

.prospetto-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .5rem;
}

/* Grafici */
.grafici-card { margin-top: 1.75rem; }

.charts-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
}

.chart-wrap {
  flex: 0 0 auto;
  max-width: 100%;
}

.chart-wrap canvas { max-width: 100%; height: auto !important; }

/* =========================================================
   CONTATTI
   ========================================================= */
.section-contatti { background: var(--white); }

.contatti-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 820px) {
  .contatti-layout { grid-template-columns: 1fr; }
}

.contatti-info-card { border-top-color: var(--gold); }

.info-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--gray-light);
}

.info-item:last-of-type { border-bottom: none; }

.info-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1.5; }

.form-feedback {
  margin-top: .75rem;
  padding: .65rem .9rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
}

.form-feedback.success { background: #DCFCE7; color: #15803D; border-left: 4px solid var(--success); }
.form-feedback.error   { background: #FEE2E2; color: #B91C1C; border-left: 4px solid var(--danger); }

/* =========================================================
   CHATBOT
   ========================================================= */
.section-chatbot { background: var(--light); }

/* Header row con switch */
.chatbot-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.chatbot-header-row .section-subtitle { margin-bottom: 1.5rem; }

.chatbot-toggle-wrap {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
  padding-top: .35rem;
}

.toggle-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray);
  min-width: 72px;
  text-align: right;
  transition: color .2s;
}

.toggle-label.active { color: var(--success); }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-light);
  border-radius: 26px;
  transition: background .25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform .25s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* Card chatbot con overlay */
.chatbot-wrapper { max-width: 780px; margin: 0 auto; }

.chatbot-card {
  padding: 0;
  overflow: hidden;
  position: relative;
}

/* Overlay disabilitato */
.chatbot-disabled-overlay {
  position: absolute;
  inset: 0;
  background: rgba(245, 247, 250, .88);
  backdrop-filter: blur(2px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.chatbot-disabled-msg {
  text-align: center;
  color: var(--gray);
  padding: 1rem;
}

.chatbot-disabled-msg p {
  margin-top: .6rem;
  font-size: .95rem;
  line-height: 1.6;
}

.chatbot-messages {
  height: 420px;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
}

.msg-bot { align-self: flex-start; max-width: 85%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; max-width: 85%; }

.msg-avatar {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

.msg-bubble {
  padding: .75rem 1rem;
  border-radius: 12px;
  font-size: .93rem;
  line-height: 1.55;
}

.msg-bot .msg-bubble {
  background: #F3F4F6;
  color: #1f2937;
  border-radius: 2px 12px 12px 12px;
}

.msg-user .msg-bubble {
  background: var(--navy);
  color: var(--white);
  border-radius: 12px 2px 12px 12px;
}

.msg-user .msg-bubble a { color: var(--gold); }

.msg-bot .msg-bubble a { color: var(--navy); font-weight: 600; }

/* Typing indicator */
.typing-indicator .msg-bubble {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .85rem 1rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray);
  animation: typing-bounce .8s infinite;
}

.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.chatbot-model-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem .4rem;
  border-top: 1px solid var(--gray-light);
  background: var(--light);
  font-size: .82rem;
  color: var(--gray);
}

.chatbot-model-row label { font-weight: 600; white-space: nowrap; }

.chatbot-model-row select {
  padding: .25rem .5rem;
  border: 1.5px solid var(--gray-light);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: .82rem;
  color: #1f2937;
  background: var(--white);
  cursor: pointer;
  flex: 1;
}

.chatbot-model-row select:focus {
  outline: none;
  border-color: var(--navy);
}

.chatbot-input-area {
  display: flex;
  gap: .5rem;
  padding: .85rem 1rem;
  border-top: 1px solid var(--gray-light);
  background: var(--white);
}

#chatInput {
  flex: 1;
  padding: .6rem .9rem;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}

#chatInput:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27,47,94,.12);
}

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,.75);
  padding: 1.5rem 0;
  font-size: .85rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.footer-left { color: rgba(255,255,255,.85); }
.footer-left a { color: var(--gold); }
.footer-left a:hover { color: var(--white); }

.footer-right { max-width: 560px; }
.disclaimer-footer { color: rgba(255,255,255,.55); line-height: 1.5; }

/* =========================================================
   WHATSAPP STICKY
   ========================================================= */
.whatsapp-sticky {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  background: #25D366;
  color: var(--white);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  text-decoration: none;
}

.whatsapp-sticky:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
  text-decoration: none;
}

.whatsapp-tooltip {
  position: absolute;
  right: 68px;
  background: #1f2937;
  color: var(--white);
  padding: .35rem .75rem;
  border-radius: 6px;
  font-size: .8rem;
  font-family: var(--font-body);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.whatsapp-sticky:hover .whatsapp-tooltip { opacity: 1; }

/* =========================================================
   RESPONSIVE GENERALE
   ========================================================= */
@media (max-width: 600px) {
  .section-title { font-size: 1.5rem; }
  .calc-form-col, .calc-results-col { width: 100%; }
  .export-buttons { flex-direction: column; }
  .export-buttons .btn { width: 100%; }
  .charts-layout { flex-direction: column; }
  .header-contacts { display: none; }
  .footer-inner { flex-direction: column; }
}
