/* ================================================
   REGIME SEMPLIFICATO — Calcolatore Fiscale
   style.css
   ================================================ */

/* ─── Reset & custom properties ─────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --gray-50:        #f9fafb;
  --gray-100:       #f3f4f6;
  --gray-200:       #e5e7eb;
  --gray-400:       #9ca3af;
  --gray-500:       #6b7280;
  --gray-600:       #4b5563;
  --gray-700:       #374151;
  --gray-900:       #111827;
  --radius:         12px;
  --shadow:         0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  text-align: center;
  padding: 36px 20px;
}

.header-content h1 {
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.4px;
}

.subtitle {
  color: rgba(255,255,255,.85);
  margin-top: 8px;
  font-size: .95rem;
}

/* ─── Page Layout (ad | content | ad) ────────── */
.page-layout {
  display: grid;
  grid-template-columns: 1fr;   /* mobile: single column */
  max-width: 1440px;
  margin: 0 auto;
}

/* ─── Ad Sidebars ─────────────────────────────── */
.ad-sidebar { display: none; padding: 24px 10px; }

.ad-placeholder {
  width: 160px;
  min-height: 600px;
  background: var(--gray-100);
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: .72rem;
  text-align: center;
  writing-mode: vertical-rl;
  line-height: 1.8;
  user-select: none;
}

/* ─── Main Content ────────────────────────────── */
main {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 16px 90px; /* bottom: space for mobile sticky ad */
}

/* ─── Tab Navigation ─────────────────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
  background: white;
  padding: 6px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: 110px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--gray-600);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.tab-btn:hover    { background: var(--gray-100); color: var(--gray-900); }
.tab-btn.active   { background: var(--primary);  color: white; font-weight: 600; }

/* ─── Tab Panels ─────────────────────────────── */
.tab-content         { display: none; }
.tab-content.active  { display: block; }

/* ─── Cards ──────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}
.card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 18px;
}
.card-desc {
  color: var(--gray-500);
  font-size: .875rem;
  margin-top: -10px;
  margin-bottom: 18px;
}

/* ─── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}

input[type="number"],
select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .95rem;
  color: var(--gray-900);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

small {
  display: block;
  font-size: .75rem;
  color: var(--gray-400);
  margin-top: 4px;
}

/* Advanced options collapsible */
.advanced-options {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 6px;
}
.advanced-options summary {
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  color: var(--gray-600);
  user-select: none;
}
.advanced-options summary:hover { color: var(--primary); }
.advanced-options .form-row { margin-top: 14px; }

/* Detail section (collapsible inside results) */
.detail-section {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 16px;
}
.detail-section summary {
  cursor: pointer;
  font-size: .82rem;
  color: var(--gray-500);
  user-select: none;
}
.detail-section summary:hover { color: var(--primary); }

/* ─── Results ────────────────────────────────── */
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--gray-100);
}
.result-row span    { color: var(--gray-600); }
.result-row strong  { font-size: .95rem; }

.result-subtotal {
  border-top: 2px solid var(--gray-200);
  border-bottom: 2px solid var(--gray-200);
  padding: 10px 0;
  margin: 4px 0;
}
.result-subtotal strong { font-size: 1rem !important; }

.result-total-tax {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 2px solid var(--gray-200);
  border-bottom: none;
}
.result-total-tax strong {
  color: var(--danger) !important;
  font-size: 1.05rem !important;
}

.result-highlight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--success-light);
  border-radius: 10px;
  padding: 16px;
  margin-top: 14px;
  font-weight: 700;
}
.result-highlight span  { color: var(--success); font-size: .95rem; }
.result-highlight strong { color: var(--success); font-size: 1.4rem; }

/* Color utilities */
.text-success  { color: var(--success)  !important; }
.text-warning  { color: var(--warning)  !important; }
.text-danger   { color: var(--danger)   !important; }

/* Breakdown table (inside details) */
.breakdown-table {
  margin-top: 10px;
  font-size: .82rem;
  color: var(--gray-600);
  line-height: 1.8;
}
.breakdown-table div {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dashed var(--gray-200);
}
.breakdown-table div:last-child { border-bottom: none; }

/* ─── Accantonamento box ─────────────────────── */
.accanto-box {
  background: var(--primary-light);
  border-radius: 10px;
  padding: 18px;
  margin-top: 20px;
}
.accanto-box h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}
.accanto-box p {
  font-size: .82rem;
  color: var(--primary-dark);
  margin-bottom: 12px;
}
.accanto-amount {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  padding: 6px 0;
}
.accanto-box small {
  display: block;
  text-align: center;
  color: var(--primary);
  opacity: .7;
  font-size: .75rem;
}

/* ─── Export buttons ─────────────────────────── */
.export-buttons {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.btn-secondary {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  color: var(--gray-700);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--gray-100); border-color: var(--gray-400); }

/* ─── Warning card ───────────────────────────── */
.warning-card {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.warning-card h3 { color: var(--danger); margin-bottom: 8px; font-size: 1rem; }
.warning-card p  { color: var(--danger); font-size: .875rem; }

/* ─── Alert info ─────────────────────────────── */
.alert-info {
  background: var(--warning-light);
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .82rem;
  color: #92400e;
  margin-bottom: 16px;
}

/* ─── Simulatore ─────────────────────────────── */
.sim-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.sim-stat {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
}
.sim-stat-highlight { background: var(--success-light); }
.sim-stat-primary   { background: var(--primary-light); }
.sim-stat span {
  display: block;
  font-size: .75rem;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.sim-stat strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
}
.sim-stat-primary strong { color: var(--primary); }

.full-deduction-note {
  background: var(--success-light);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .875rem;
  color: var(--success);
  margin-bottom: 16px;
}

/* Ammortamento table */
.amm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  margin-bottom: 10px;
}
.amm-table th {
  background: var(--gray-100);
  padding: 9px 14px;
  text-align: left;
  font-size: .75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.amm-table td   { padding: 9px 14px; border-bottom: 1px solid var(--gray-100); }
.amm-table tr.amm-total td {
  font-weight: 700;
  border-top: 2px solid var(--gray-200);
  border-bottom: none;
}

/* ─── Scadenziario ───────────────────────────── */
.scad-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.scad-item:last-child { border-bottom: none; }

.scad-date {
  min-width: 90px;
  font-size: .72rem;
  font-weight: 700;
  color: white;
  background: var(--primary);
  border-radius: 6px;
  padding: 7px 10px;
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
}
.scad-date.urgent  { background: var(--danger); }
.scad-date.caution { background: var(--warning); }

.scad-details { flex: 1; }
.scad-details h4 { font-size: .9rem; font-weight: 600; color: var(--gray-900); }
.scad-details p  { font-size: .8rem;  color: var(--gray-500); margin-top: 2px; }

.scad-amount {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--danger);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── IVA scadenze ───────────────────────────── */
.iva-scad-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: .875rem;
  border-bottom: 1px solid var(--gray-100);
}
.iva-scad-item:last-child { border-bottom: none; }
.iva-scad-item span   { color: var(--gray-600); }
.iva-scad-item strong { color: var(--danger); }

/* ─── Utility ────────────────────────────────── */
.hidden    { display: none !important; }
.mt-2      { margin-top: 12px; }
.mt-3      { margin-top: 20px; }
.disclaimer-small {
  font-size: .75rem;
  color: var(--gray-400);
  line-height: 1.5;
}

/* ─── Footer ─────────────────────────────────── */
footer {
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 28px 20px;
  margin-top: 10px;
}
.footer-content { max-width: 800px; margin: 0 auto; text-align: center; }
.disclaimer {
  font-size: .78rem;
  color: var(--gray-500);
  line-height: 1.7;
  margin-bottom: 12px;
}
.footer-links a {
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
}
.footer-links a:hover { text-decoration: underline; }

/* ─── Mobile sticky ad banner ────────────────── */
.mobile-ad-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
}
.mobile-ad-inner {
  height: 50px;
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: .72rem;
}

/* ─── Desktop layout (≥ 1080px) ─────────────── */
@media (min-width: 1080px) {
  .page-layout {
    grid-template-columns: 190px 1fr 190px;
    align-items: start;
  }
  .ad-sidebar {
    display: flex;
    justify-content: center;
    position: sticky;
    top: 20px;
  }
  .ad-left  { order: 1; }
  main      { order: 2; }
  .ad-right { order: 3; }
}

/* ─── Tablet (480–1079px) ────────────────────── */
@media (max-width: 1079px) and (min-width: 481px) {
  .mobile-ad-banner { display: block; }
}

/* ─── Mobile (≤ 480px) ───────────────────────── */
@media (max-width: 480px) {
  main          { padding: 14px 12px 70px; }
  .form-row     { grid-template-columns: 1fr; }
  .sim-summary  { grid-template-columns: 1fr; }
  .mobile-ad-banner { display: block; }
  .tab-btn      { min-width: 90px; font-size: .78rem; padding: 7px 8px; }
}

/* ─── Feedback floating button ───────────────────── */
.feedback-fab {
  position: fixed;
  bottom: 70px; /* sopra il banner mobile */
  left: 20px;   /* lato sinistro — Iubenda occupa il basso destra */
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,.45);
  z-index: 150;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feedback-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 18px rgba(37,99,235,.55);
}

/* ─── Feedback modal overlay ─────────────────────── */
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ─── Feedback modal card ────────────────────────── */
.feedback-modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}
.feedback-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
}
.feedback-modal-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
}
.feedback-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.feedback-close:hover { background: var(--gray-100); color: var(--gray-700); }

.feedback-body  { padding: 16px 24px 24px; }
.feedback-desc  { font-size: .875rem; color: var(--gray-600); margin-bottom: 18px; }

textarea#feedback-text {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .9rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 120px;
  transition: border-color .15s, box-shadow .15s;
}
textarea#feedback-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.btn-feedback-submit {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
  transition: background .15s;
}
.btn-feedback-submit:hover    { background: var(--primary-dark); }
.btn-feedback-submit:disabled { background: var(--gray-400); cursor: not-allowed; }

.feedback-privacy {
  font-size: .72rem;
  color: var(--gray-400);
  text-align: center;
  margin-top: 10px;
}

/* Stato successo / errore */
.feedback-state        { text-align: center; }
.feedback-state-icon   {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.feedback-state-ok     { background: var(--success-light); color: var(--success); }
.feedback-state-err    { background: var(--danger-light);  color: var(--danger);  }
.feedback-state h3     { color: var(--gray-900); margin-bottom: 8px; font-size: 1rem; }
.feedback-state p      { color: var(--gray-600); font-size: .875rem; margin-bottom: 20px; }
.feedback-state .btn-feedback-submit { margin-top: 0; }

/* Desktop: FAB non deve stare sopra il banner mobile (che non c'è) */
@media (min-width: 1080px) { .feedback-fab { bottom: 24px; left: 20px; } }

/* ─── Print styles ───────────────────────────── */
@media print {
  .ad-sidebar,
  .mobile-ad-banner,
  .feedback-fab,
  .feedback-overlay,
  .tab-nav,
  .export-buttons,
  .advanced-options,
  .tab-content:not(.active),
  .footer-links {
    display: none !important;
  }
  header      { padding: 16px; }
  .card       { box-shadow: none; border: 1px solid #ddd; margin-bottom: 10px; }
  main        { padding: 0; max-width: 100%; }
  .result-highlight {
    background: #f0fdf4 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
