/* ============================================================
   CALCULATOR.CSS — Edilizia in un Click
   Stili per:
   1. Modal "Sblocca Calcolatore" (pagine articolo)
   2. Pagina Calcolatore Incidenza Acciaio
   ============================================================ */

/* ============================================================
   1. MODAL SBLOCCA CALCOLATORE
   ============================================================ */

.calc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.calc-modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.calc-modal-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px) scale(0.97);
    transition: transform 300ms ease;
    padding: 40px 36px 36px;
}

.calc-modal-overlay.is-visible .calc-modal-card {
    transform: translateY(0) scale(1);
}

/* Scrollbar sottile */
.calc-modal-card::-webkit-scrollbar { width: 4px; }
.calc-modal-card::-webkit-scrollbar-track { background: transparent; }
.calc-modal-card::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 2px; }

.calc-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    color: #525252;
    transition: background 150ms ease, color 150ms ease;
    font-family: inherit;
    flex-shrink: 0;
}
.calc-modal-close:hover { background: #e5e5e5; color: #1a1a1a; }

/* Badge accesso */
.calc-modal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #C41E3A;
    background: #fef2f4;
    border: 1px solid #fecdd3;
    border-radius: 100px;
    padding: 4px 10px;
    margin-bottom: 14px;
}

.calc-modal-title {
    font-size: 20px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1.25;
    margin: 0 0 10px;
    letter-spacing: -.02em;
}

.calc-modal-subtitle {
    font-size: 14px;
    color: #525252;
    line-height: 1.6;
    margin: 0 0 20px;
}

.calc-modal-features {
    list-style: none;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 14px 16px;
    margin: 0 0 22px;
}
.calc-modal-features li {
    font-size: 13px;
    color: #404040;
    padding: 4px 0 4px 22px;
    position: relative;
    line-height: 1.5;
}
.calc-modal-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #15803d;
    font-weight: 700;
}

/* Form fields */
.calc-modal-field {
    margin-bottom: 14px;
}
.calc-modal-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 5px;
}
.calc-modal-field input[type="text"],
.calc-modal-field input[type="email"] {
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
    font-family: inherit;
    border: 1.5px solid #d4d4d4;
    border-radius: 8px;
    outline: none;
    color: #1a1a1a;
    background: #fff;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.calc-modal-field input:focus {
    border-color: #C41E3A;
    box-shadow: 0 0 0 3px rgba(196,30,58,.12);
}
.calc-modal-field input.is-error { border-color: #dc2626; }

.calc-field-error {
    display: block;
    font-size: 12px;
    color: #dc2626;
    margin-top: 4px;
    min-height: 16px;
}

/* Checkboxes */
.calc-modal-checkbox {
    margin-bottom: 12px;
}
.calc-modal-checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #404040;
    line-height: 1.5;
}
.calc-modal-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    accent-color: #C41E3A;
    cursor: pointer;
}
.calc-modal-checkbox label em {
    font-style: normal;
    color: #737373;
    font-size: 12px;
}
.calc-modal-checkbox a { color: #C41E3A; }

/* Submit button */
.calc-modal-submit {
    display: block;
    width: 100%;
    padding: 15px;
    background: #C41E3A;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 150ms ease, transform 100ms ease;
    margin: 18px 0 12px;
    letter-spacing: .01em;
}
.calc-modal-submit:hover { background: #A01830; }
.calc-modal-submit:active { transform: scale(.98); }
.calc-modal-submit:disabled {
    background: #d4d4d4;
    cursor: not-allowed;
    transform: none;
}

.calc-modal-disclaimer {
    font-size: 11px;
    color: #a3a3a3;
    text-align: center;
    line-height: 1.5;
}

/* Success state */
.calc-modal-success {
    text-align: center;
    padding: 8px 0;
}
.calc-modal-success-icon {
    width: 64px;
    height: 64px;
    background: #d1fae5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 20px;
    color: #15803d;
}
.calc-modal-success h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 12px;
}
.calc-modal-success p {
    font-size: 14px;
    color: #525252;
    line-height: 1.6;
    margin: 0 0 12px;
}
.calc-modal-spam-note {
    font-size: 12px;
    color: #a3a3a3;
    margin-top: 16px !important;
}

/* General error alert */
.calc-modal-alert {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

/* ============================================================
   2. PAGINA CALCOLATORE
   ============================================================ */

/* Layout base pagina */
.calc-page {
    min-height: 100vh;
    background: #f5f5f5;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

/* Header minimale */
.calc-page-header {
    background: #1a1a1a;
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.calc-page-header .container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.calc-header-logo {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.calc-header-logo-dot {
    width: 10px;
    height: 10px;
    background: #C41E3A;
    border-radius: 50%;
}
.calc-header-back {
    font-size: 13px;
    color: #a3a3a3;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 150ms;
}
.calc-header-back:hover { color: #fff; }

/* Hero */
.calc-hero {
    background: linear-gradient(135deg, #C41E3A 0%, #8B1527 100%);
    padding: 40px 0 36px;
    color: #fff;
}
.calc-hero .container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}
.calc-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 100px;
    padding: 4px 12px;
    margin-bottom: 12px;
}
.calc-hero h1 {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 800;
    margin: 0 0 10px;
    letter-spacing: -.02em;
    line-height: 1.2;
}
.calc-hero p {
    font-size: 15px;
    opacity: .85;
    margin: 0;
    max-width: 540px;
}

/* Contenuto principale */
.calc-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* Welcome bar */
.calc-welcome-bar {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 28px;
    font-size: 14px;
    color: #525252;
}
.calc-welcome-bar strong { color: #1a1a1a; }
.calc-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 100px;
    padding: 3px 10px;
    white-space: nowrap;
}

/* Gate (accesso negato) */
.calc-gate {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 24px;
}
.calc-gate-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 32px rgba(0,0,0,.08);
    padding: 48px 40px;
    max-width: 480px;
    width: 100%;
    text-align: center;
}
.calc-gate-icon {
    font-size: 40px;
    margin-bottom: 20px;
}
.calc-gate-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 12px;
}
.calc-gate-card p {
    font-size: 14px;
    color: #525252;
    line-height: 1.6;
    margin: 0 0 24px;
}
.calc-gate-card .btn-primary {
    display: inline-block;
    background: #C41E3A;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    padding: 13px 28px;
    border-radius: 8px;
    text-decoration: none;
    margin-bottom: 16px;
    transition: background 150ms;
}
.calc-gate-card .btn-primary:hover { background: #A01830; }
.calc-gate-already {
    font-size: 13px;
    color: #737373;
    margin-top: 8px;
}
.calc-gate-already a { color: #C41E3A; cursor: pointer; text-decoration: underline; }

/* Sezioni del calcolatore */
.calc-section {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 14px;
    padding: 28px 28px 24px;
    margin-bottom: 24px;
}
.calc-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.calc-section-title {
    font-size: 17px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.calc-section-title-icon {
    width: 32px;
    height: 32px;
    background: #fef2f4;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.calc-section-desc {
    font-size: 13px;
    color: #737373;
    margin: -12px 0 20px;
}

/* Card elemento strutturale */
.element-card {
    border: 1.5px solid #e5e5e5;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    background: #fafafa;
    transition: border-color 200ms;
}
.element-card:hover { border-color: #d4d4d4; }
.element-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 8px;
}
.element-card-label {
    font-size: 13px;
    font-weight: 600;
    color: #525252;
    display: flex;
    align-items: center;
    gap: 8px;
}
.element-number {
    width: 22px;
    height: 22px;
    background: #C41E3A;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-remove-element {
    background: none;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    color: #737373;
    cursor: pointer;
    transition: border-color 150ms, color 150ms;
    font-family: inherit;
}
.btn-remove-element:hover { border-color: #dc2626; color: #dc2626; }

/* Grid input elemento */
.element-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: end;
}

@media (max-width: 700px) {
    .element-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
    .element-grid { grid-template-columns: 1fr; }
}

.element-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #525252;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.element-field select,
.element-field input[type="number"] {
    width: 100%;
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid #d4d4d4;
    border-radius: 8px;
    background: #fff;
    color: #1a1a1a;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms;
    appearance: auto;
}
.element-field select:focus,
.element-field input[type="number"]:focus {
    border-color: #C41E3A;
    box-shadow: 0 0 0 3px rgba(196,30,58,.1);
}

/* Range hint */
.range-hint {
    font-size: 11px;
    color: #a3a3a3;
    margin-top: 3px;
}

/* Risultato per elemento */
.element-result-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e5e5e5;
}
@media (max-width: 700px) {
    .element-result-row { grid-template-columns: repeat(2, 1fr); }
}

.element-result-item {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}
.element-result-item .result-label {
    font-size: 11px;
    color: #737373;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.element-result-item .result-value {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}
.element-result-item .result-value.highlight { color: #C41E3A; }

/* Add element button */
.btn-add-element {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    background: none;
    border: 1.5px dashed #d4d4d4;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #525252;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: border-color 150ms, color 150ms, background 150ms;
    font-family: inherit;
    margin-top: 8px;
}
.btn-add-element:hover {
    border-color: #C41E3A;
    color: #C41E3A;
    background: #fef2f4;
}

/* Riepilogo totale */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}
.summary-card {
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 18px 16px;
    text-align: center;
}
.summary-card.accent {
    background: linear-gradient(135deg, #C41E3A, #A01830);
    border-color: transparent;
    color: #fff;
}
.summary-card .s-label {
    font-size: 11px;
    color: #737373;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 6px;
}
.summary-card.accent .s-label { color: rgba(255,255,255,.75); }
.summary-card .s-value {
    font-size: 22px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1;
    margin-bottom: 2px;
}
.summary-card.accent .s-value { color: #fff; }
.summary-card .s-unit {
    font-size: 12px;
    color: #a3a3a3;
}
.summary-card.accent .s-unit { color: rgba(255,255,255,.65); }

/* Tabella barre acciaio */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid #e5e5e5;
}
.bars-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.bars-table thead tr {
    background: #1a1a1a;
    color: #fff;
}
.bars-table thead th {
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: right;
    white-space: nowrap;
}
.bars-table thead th:first-child { text-align: center; }
.bars-table tbody tr:nth-child(even) { background: #fafafa; }
.bars-table tbody tr:hover { background: #fef2f4; }
.bars-table tbody td {
    padding: 10px 14px;
    color: #1a1a1a;
    text-align: right;
    border-bottom: 1px solid #f0f0f0;
}
.bars-table tbody td:first-child {
    text-align: center;
    font-weight: 700;
    color: #C41E3A;
}
.bars-table tfoot td {
    padding: 8px 14px;
    font-size: 11px;
    color: #a3a3a3;
    border-top: 1px solid #e5e5e5;
}

/* Quick bar calculator */
.quick-calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    align-items: end;
}
.quick-calc-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #525252;
    margin-bottom: 5px;
}
.quick-calc-field select,
.quick-calc-field input[type="number"] {
    width: 100%;
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid #d4d4d4;
    border-radius: 8px;
    background: #fff;
    color: #1a1a1a;
    outline: none;
    transition: border-color 150ms;
    appearance: auto;
}
.quick-calc-field select:focus,
.quick-calc-field input[type="number"]:focus {
    border-color: #C41E3A;
    box-shadow: 0 0 0 3px rgba(196,30,58,.1);
}
.quick-calc-result {
    background: #fef2f4;
    border: 1.5px solid #fecdd3;
    border-radius: 10px;
    padding: 14px 18px;
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.quick-calc-result .qc-label {
    font-size: 13px;
    color: #525252;
}
.quick-calc-result .qc-value {
    font-size: 20px;
    font-weight: 800;
    color: #C41E3A;
}

/* Print button */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: none;
    border: 1.5px solid #d4d4d4;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #525252;
    cursor: pointer;
    transition: all 150ms;
    font-family: inherit;
}
.btn-print:hover { border-color: #1a1a1a; color: #1a1a1a; }

/* Loading state pagina calcolatore */
.calc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    flex-direction: column;
    gap: 16px;
    color: #737373;
    font-size: 14px;
}
.calc-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e5e5;
    border-top-color: #C41E3A;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Email gate form (se non ha token in localStorage) */
.calc-email-gate {
    border: 1.5px solid #e5e5e5;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 20px;
    background: #fafafa;
    display: none;
}
.calc-email-gate h4 {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 10px;
}
.calc-email-gate p {
    font-size: 13px;
    color: #737373;
    margin: 0 0 14px;
    line-height: 1.5;
}
.calc-email-gate-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.calc-email-gate-form input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid #d4d4d4;
    border-radius: 8px;
    outline: none;
    transition: border-color 150ms;
}
.calc-email-gate-form input:focus { border-color: #C41E3A; }
.calc-email-gate-form button {
    padding: 10px 20px;
    background: #C41E3A;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 150ms;
}
.calc-email-gate-form button:hover { background: #A01830; }

/* Note normativa */
.calc-norm-note {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 12px;
    color: #0369a1;
    line-height: 1.5;
    margin-top: 16px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    .calc-modal-card { padding: 32px 20px 28px; }
    .calc-modal-title { font-size: 17px; }
    .calc-section { padding: 20px 16px 18px; }
    .calc-gate-card { padding: 36px 24px; }
    .calc-hero { padding: 28px 0 24px; }
    .calc-content { padding: 20px 16px 48px; }
    .element-card { padding: 16px; }
    .summary-card .s-value { font-size: 18px; }
}

@media print {
    .calc-page-header, .calc-hero-badge,
    .btn-add-element, .btn-remove-element,
    .btn-print, .calc-welcome-bar,
    .calc-norm-note { display: none !important; }
    .calc-hero { background: #1a1a1a !important; -webkit-print-color-adjust: exact; }
    .calc-section { break-inside: avoid; }
}
