/* ------------------------------------------------- */
/*  Reset CSS e Stili di Base
/* ------------------------------------------------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Barlow', -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #000;
    background-color: #fff;
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------- */
/*  Testata del sito
/* ------------------------------------------------- */

.site-header {
    margin-bottom: 2em;
}

.header-top-bar {
    background-color: #f7f7f7;
    padding: 0.5em 0;
    border-bottom: 1px solid #ddd;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1em;
}

.top-bar-content {
    text-align: center;
    font-size: 0.9em;
}

.top-bar-content a {
    color: #000;
    text-decoration: none;
    transition: color 0.2s;
}

.top-bar-content a:hover {
    color: #ed6c07;
}

.header-branding-wrapper {
    padding: 1.5em 0;
}

.header-branding-wrapper .header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1em;
}

.header-branding {
    flex: 1;
}

.site-logo {
    max-width: 100%;
    height: auto;
    max-height: 80px;
}

.partner-logo-wrapper {
    text-align: right;
}

.partner-logo-wrapper p {
    font-size: 0.75em;
    margin-bottom: 0.5em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.partner-logo {
    max-width: 150px;
    height: auto;
}

@media screen and (max-width: 48em) {
    .header-branding-wrapper .header-container {
        flex-direction: column;
        text-align: center;
    }

    .partner-logo-wrapper {
        text-align: center;
    }

    .site-logo {
        max-height: 60px;
    }
}

/* ------------------------------------------------- */
/*  Struttura della pagina
/* ------------------------------------------------- */

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2em 1em;
}

@media screen and (min-width: 48em) {
    .container {
        padding: 3em 2em;
    }
}

/* ------------------------------------------------- */
/*  Intestazione pagina
/* ------------------------------------------------- */

.page-header {
    text-align: center;
    margin-bottom: 3em;
    padding-bottom: 2em;
    border-bottom: 3px solid #02aab7;
}

.page-header h1 {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 2em;
    font-weight: 600;
    color: #5c2e88;
    margin-bottom: 0.5em;
    line-height: 1.2;
}

@media screen and (min-width: 48em) {
    .page-header h1 {
        font-size: 2.6em;
    }
}

.subtitle {
    font-size: 1.1em;
    color: #666;
    margin: 0;
}

/* ------------------------------------------------- */
/*  Sezioni del modulo
/* ------------------------------------------------- */

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 2em;
}

.form-section {
    background-color: #fff;
    border: 2px solid #ddd;
    padding: 2em;
    border-radius: 0;
}

@media screen and (min-width: 48em) {
    .form-section {
        padding: 2.5em 3em;
    }
}

.section-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.5em;
    font-weight: 600;
    color: #5c2e88;
    margin-bottom: 1.5em;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ------------------------------------------------- */
/*  Campi del modulo
/* ------------------------------------------------- */

.form-group {
    margin-bottom: 1.5em;
}

.form-group:last-of-type {
    margin-bottom: 2em;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5em;
    color: #000;
}

.required {
    color: #ed6c07;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 0.75em;
    border: 2px solid #ddd;
    border-radius: 0;
    font-family: 'Barlow', sans-serif;
    font-size: 1em;
    transition: border-color 0.2s;
    background-color: #fff;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #ed6c07;
}

/* Stili per i campi data personalizzati */
.date-inputs {
    display: flex;
    gap: 0.5em;
}

.date-inputs select,
.date-inputs input {
    flex: 1;
}

.date-inputs input[type="number"] {
    text-align: center;
}

/* Mese e anno competenza */
.date-inputs select {
    flex: 2;
}

/* Data pagamento (GG/MM/AAAA) */
.date-inputs input#giorno,
.date-inputs input#mesePagamento {
    flex: 0 0 60px;
    max-width: 60px;
}

.date-inputs input#annoPagamento {
    flex: 0 0 90px;
    max-width: 90px;
}

/* Anno competenza */
.date-inputs input#anno {
    flex: 1;
    max-width: 120px;
}

@media screen and (max-width: 30em) {
    .date-inputs {
        flex-wrap: wrap;
    }

    .date-inputs select,
    .date-inputs input {
        min-width: 100%;
        max-width: 100% !important;
    }
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    padding-right: 3em;
}

.input-icon {
    position: absolute;
    right: 1em;
    font-weight: 600;
    color: #666;
    pointer-events: none;
}

.help-text {
    display: block;
    margin-top: 0.5em;
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

/* ------------------------------------------------- */
/*  Pulsanti
/* ------------------------------------------------- */

.btn {
    font-family: 'Barlow', sans-serif;
    font-size: 1em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75em 1.5em;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #ed6c07;
    color: #fff;
    width: 100%;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #f9872e;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(237, 108, 7, 0.3);
}

.btn-primary:disabled {
    background-color: #bbb;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Messaggi di errore/avviso nel form (sostituiscono gli alert) */
.form-message {
    margin-bottom: 1em;
    padding: 0.75em 1em;
    border-left: 4px solid #c0392b;
    background-color: #fdecea;
    color: #8a1f14;
    font-size: 0.95em;
}

.form-message[hidden] {
    display: none;
}

.btn-secondary {
    background-color: #02aab7;
    color: #fff;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #039ca8;
}

.btn-outline {
    background-color: transparent;
    color: #5c2e88;
    border: 2px solid #5c2e88;
}

.btn-outline:hover,
.btn-outline:focus {
    background-color: #5c2e88;
    color: #fff;
}

.action-buttons {
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
    margin-top: 1.5em;
}

.action-buttons .btn {
    flex: 1;
    min-width: 200px;
}

@media screen and (max-width: 48em) {
    .action-buttons .btn {
        width: 100%;
    }
}

/* ------------------------------------------------- */
/*  Sezione risultati
/* ------------------------------------------------- */

.results-section {
    background-color: #f7f7f7;
    border-color: #02aab7;
    border-width: 3px;
}

.result-grid {
    display: grid;
    gap: 1.5em;
    margin-bottom: 2em;
}

@media screen and (min-width: 48em) {
    .result-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.result-item {
    background-color: #fff;
    padding: 1.5em;
    border: 2px solid #ddd;
    text-align: center;
}

.result-item.highlight {
    border-color: #ed6c07;
    background-color: #fff9f5;
}

.result-item.total {
    border-color: #5c2e88;
    background-color: #5c2e88;
    color: #fff;
}

@media screen and (min-width: 48em) {
    .result-item.total {
        grid-column: 1 / -1;
    }
}

.result-label {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5em;
    letter-spacing: 0.05em;
}

.result-item.total .result-label {
    color: #fff;
}

.result-value {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 2em;
    font-weight: 600;
    line-height: 1;
}

.result-item.total .result-value {
    font-size: 2.5em;
    color: #fff;
}

.currency {
    font-size: 0.7em;
    opacity: 0.8;
}

/* ------------------------------------------------- */
/*  Dettaglio del calcolo
/* ------------------------------------------------- */

.calculation-details {
    background-color: #fff;
    padding: 1.5em;
    border-left: 4px solid #02aab7;
    margin-bottom: 1.5em;
}

.calculation-details h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: #5c2e88;
    margin-bottom: 0.75em;
}

.calculation-details p {
    color: #333;
    line-height: 1.6;
    margin: 0;
}

/* ------------------------------------------------- */
/*  Riquadro informativo
/* ------------------------------------------------- */

.info-box {
    background-color: #fff9f5;
    border: 2px solid #ed6c07;
    padding: 1.5em 2em;
    margin-top: 2em;
}

.info-box h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: #ed6c07;
    margin-bottom: 1em;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    padding-left: 1.5em;
    margin-bottom: 0.5em;
    position: relative;
}

.info-box li::before {
    content: "•";
    color: #ed6c07;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* ------------------------------------------------- */
/*  Piè di pagina
/* ------------------------------------------------- */

.page-footer {
    margin-top: 3em;
    padding-top: 2em;
    border-top: 2px solid #ddd;
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

/* ------------------------------------------------- */
/*  Modalità Operatore (Riservato Cassa Edile)
/* ------------------------------------------------- */

.operator-badge {
    background-color: #f0f8f9;
    border: 1px solid #02aab7;
    border-left: 5px solid #02aab7;
    border-radius: 6px;
    padding: 0.75em 1.2em;
    margin-bottom: 2em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    color: #0b5059;
}

.operator-badge-content {
    display: flex;
    align-items: center;
    gap: 0.6em;
}

.operator-badge-icon {
    font-size: 1.2em;
}

.operator-exit-link {
    color: #c94c00;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85em;
    padding: 0.25em 0.7em;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #f0d0be;
    transition: all 0.2s;
}

.operator-exit-link:hover {
    background: #ed6c07;
    color: #fff;
    border-color: #ed6c07;
}

.operator-detail-box {
    margin-top: 1.2em;
    padding: 1em 1.2em;
    background: #fdfdfd;
    border: 1px dashed #02aab7;
    border-radius: 6px;
}

.operator-detail-header {
    display: flex;
    align-items: center;
    gap: 0.6em;
    margin-bottom: 0.6em;
    flex-wrap: wrap;
}

.operator-tag {
    background-color: #5c2e88;
    color: #fff;
    font-size: 0.75em;
    padding: 0.2em 0.6em;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.operator-period-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.operator-period-list li {
    padding: 0.35em 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95em;
}

.operator-period-list li:last-child {
    border-bottom: none;
}

.operator-footer-info {
    margin-top: 0.6em;
    font-size: 0.85em;
}

.operator-toggle-link {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.operator-toggle-link:hover,
.operator-toggle-link.active {
    color: #5c2e88;
    text-decoration: underline;
}

/* ------------------------------------------------- */
/*  Stili per la stampa
/* ------------------------------------------------- */

@media print {
    body {
        font-size: 11pt;
        color: #111;
        background: #fff;
    }

    .header-top-bar {
        display: none;
    }

    .site-header {
        margin-bottom: 1em;
        page-break-inside: avoid;
    }

    .header-branding-wrapper {
        padding: 0.5em 0;
    }

    .header-branding-wrapper .header-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .site-logo {
        max-height: 48px;
    }

    .partner-logo {
        max-height: 40px;
        width: auto;
    }

    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .page-header {
        border-bottom: 1.5px solid #02aab7;
        margin-bottom: 1.2em;
        padding-bottom: 0.8em;
    }

    .page-header h1 {
        font-size: 1.8em;
    }

    .page-header .subtitle {
        font-size: 0.95em;
    }

    .form-section:first-child,
    .action-buttons,
    .btn,
    .operator-badge,
    .operator-footer-info {
        display: none !important;
    }

    .operator-detail-box {
        border: 1px solid #444;
        background: #fff;
        padding: 0.8em 1em;
        margin-top: 1em;
        page-break-inside: avoid;
    }

    .operator-tag {
        background-color: #333;
        color: #fff;
    }

    .results-section {
        display: block !important;
        border: 1.5px solid #5c2e88;
        padding: 1.2em;
        margin-bottom: 1em;
        page-break-inside: avoid;
    }

    .result-grid {
        gap: 1em;
        margin-bottom: 1em;
    }

    .calculation-details {
        margin-top: 1em;
        padding: 1em;
        font-size: 0.95em;
    }

    .info-box {
        page-break-inside: avoid;
        margin-top: 1em;
        padding: 0.9em 1.2em;
        font-size: 0.85em;
        border-left: 4px solid #02aab7;
    }

    .page-footer {
        margin-top: 1.2em;
        padding-top: 0.6em;
        font-size: 0.8em;
        border-top: 1px solid #ddd;
    }
}

/* ------------------------------------------------- */
/*  Animazioni
/* ------------------------------------------------- */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-section {
    animation: slideIn 0.3s ease-out;
}

/* ------------------------------------------------- */
/*  Accessibilità
/* ------------------------------------------------- */

.btn:focus,
input:focus {
    outline: 2px solid #ed6c07;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
