/* VoltCalc Pro - Foglio di stile principale e per stampa A4 */

:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg-slate: #f8fafc;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Disabilita completamente le freccette native number input per evitare accavallamenti */
.input-clean-number::-webkit-inner-spin-button,
.input-clean-number::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

.input-clean-number {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

/* Pulsanti stepper (+ e -) con ergonomia touch per smartphone */
.btn-step {
  transition: all 0.15s ease-in-out;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  min-width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-step:hover {
  background-color: #eff6ff !important;
  color: #2563eb !important;
}

.btn-step:active {
  background-color: #dbeafe !important;
  transform: scale(0.95);
}

/* Utilità per scorrimento orizzontale pulito senza barre su mobile */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Tabella Sezioni */
.table-container {
  overflow-x: auto;
}

.table-sections tr.optimal-row {
  background-color: #ecfdf5 !important;
  border-left: 4px solid #10b981;
}

.table-sections tr.non-compliant {
  opacity: 0.6;
}

/* Sfocatura righe non ottimali in versione FREE */
body:not(.is-pro) .table-sections tr:not(.optimal-row) td {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
  opacity: 0.5;
}

/* Quando la licenza PRO è attiva, sblocca la tabella e nascondi overlay */
body.is-pro .table-pro-overlay {
  display: none !important;
}

body.is-pro .table-sections tr:not(.optimal-row) td {
  filter: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Filigrana Bozza Anteprima per Relazione Tecnica */
.watermark-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 25;
  overflow: hidden;
}

.watermark-text {
  transform: rotate(-30deg);
  font-size: 2.8rem;
  font-weight: 900;
  color: rgba(220, 38, 38, 0.08);
  border: 5px dashed rgba(220, 38, 38, 0.16);
  padding: 24px 40px;
  border-radius: 20px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.3;
  user-select: none;
}

/* Quando PRO è attivo, rimuovi la filigrana sia a schermo che in stampa */
body.is-pro .watermark-container {
  display: none !important;
}

/* Stili specifici per Stampa e Generazione PDF A4 della Relazione Tecnica */
@media print {
  /* 1. Rimuovi completamente dal flusso tutti gli elementi della pagina web principale */
  header,
  section,
  main,
  footer,
  #stripe-modal,
  .no-print {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* 2. Reset totale html e body per eliminare qualsiasi scroll o altezza fantasma */
  html, body {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
    overflow: visible !important;
    font-size: 9.5pt;
  }

  /* 3. Il modal diventa un contenitore statico a tutto foglio, senza posizionamento fisso */
  #report-modal {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    background: white !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  #report-modal > div {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* 4. Il blocco della Relazione Tecnica: esattamente 1 pagina A4 */
  #printable-report {
    display: block !important;
    position: static !important;
    visibility: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    line-height: 1.35;
  }

  body.is-pro .watermark-container {
    display: none !important;
  }

  body:not(.is-pro) .watermark-container {
    display: flex !important;
    position: absolute !important;
    top: 35% !important;
    left: 0 !important;
    right: 0 !important;
  }

  body:not(.is-pro) .watermark-text {
    color: rgba(185, 28, 28, 0.15) !important;
    border: 5px dashed rgba(185, 28, 28, 0.25) !important;
    font-size: 2.2rem !important;
  }

  @page {
    size: A4 portrait;
    margin: 15mm 12mm 14mm 12mm;
  }

  .page-break-inside-avoid {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* Timbro Professionale Placeholder */
.stamp-box {
  border: 1.5px dashed #64748b;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  background-color: #f8fafc;
  padding: 8px 12px;
  text-align: center;
}

/* Ottimizzazione scorrimento touch per le finestre modali su smartphone (iOS & Android) */
#report-modal .overflow-y-auto,
#stripe-modal .overflow-y-auto,
#projects-modal .overflow-y-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
