:root {
    --primary-color: #635bff;
    --primary-hover-color: #5548e8;
    --light-grey: #f0f4f9;
    --dark-grey: #6c757d;
    --text-color: #32325d;
    --border-color: #ced4da;
    --error-color: #df1b41;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--light-grey);
    margin: 0;
    display: flex;
    flex-direction: column; /* Necessario per gestire header/footer correttamente */
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
}

.container {
    width: 100%;
    max-width: 480px;
}


/* =========================== */
/*    Header, Card e Layout    */
/* =========================== */

.page-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    max-width: 150px;
    max-height: 150px;
    height: auto;
    width: auto;
}

.payment-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-header {
    margin-bottom: 25px;
}

.card-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
}


/* =========================== */
/*      Stili del Form         */
/* =========================== */

.form-row {
    margin-bottom: 20px;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark-grey);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fff;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px 12px;
}

.form-control:focus, .form-control.StripeElement--focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.15);
}

#iban-element {
    padding: 12px 0;
}

#error-message {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
    text-align: center;
}

.sepa-mandate {
    background-color: var(--light-grey);
    border-radius: 6px;
    padding: 15px;
    margin: 25px 0;
    font-size: 12px;
    color: var(--dark-grey);
    line-height: 1.5;
}

.sepa-mandate strong {
    color: var(--text-color);
}


/* =========================== */
/*   Pulsante di Invio e Spinner */
/* =========================== */

.submit-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    position: relative;
    overflow: hidden;
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Stile per l'effetto hover (quando il mouse è sopra) */
.submit-btn:hover {
    background-color: var(--primary-hover-color);
}
/* Stile per quando il pulsante viene premuto */
.submit-btn:active {
    transform: scale(0.99);
}
/* Stile per quando il pulsante è disabilitato (durante il caricamento) */
.submit-btn:disabled {
    background-color: #a0a0a0;
    cursor: not-allowed;
}
/* Stile per lo spinner di caricamento */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    width: 20px;
    height: 20px;
    animation: spin 1s ease-in-out infinite;
    position: absolute; /* Si posiziona al centro del pulsante */
}
/* Regole per gestire la visibilità del testo e dello spinner durante il caricamento */
.spinner.hidden { 
    display: none; 
}

.submit-btn.loading .button-text {
    visibility: hidden;
}

.submit-btn.loading .spinner {
    display: block;
}

/* Animazione dello spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}


/* =========================== */
/*           Footer            */
/* =========================== */

.page-footer {
    text-align: center;
    margin: 40px auto 20px auto;
    padding: 0 15px;
    color: var(--dark-grey);
    font-size: 12px;
    line-height: 1.6;
}

.page-footer p {
    margin: 5px 0;
}

.page-footer .disclaimer {
    font-style: italic;
    margin: 15px 0;
    font-size: 11px;
}

.footer-links {
    margin: 15px 0;
    font-size: 11px;
    font-weight: 500;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 5px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.page-footer .powered-by {
    margin-top: 15px;
    font-size: 12px;
}

.page-footer .powered-by a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.page-footer .powered-by a:hover {
    text-decoration: underline;
}

/* Rimuove il vecchio footer, se ancora presente */
.footer-text {
    display: none;
}


/* =========================== */
/*     Stili Responsive        */
/* =========================== */

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .payment-card {
        padding: 20px;
    }
}

/* Stili per il campo condizionale */
.hidden-field {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin-bottom: 0 !important; /* Sovrascrive il margin di .form-row */
    transition: all 0.4s ease-out;
}

.visible-field {
    max-height: 100px; /* Abbastanza alto da contenere il campo */
    opacity: 1;
    margin-bottom: 20px !important;
}

/* Stile per i campi di upload file */
.file-input-wrapper label {
    margin-bottom: 8px;
}
/* Rende il padding coerente con gli altri campi */
input[type="file"].form-control {
    padding: 10px 16px;
}
/* Stile per il testo del pulsante "Scegli file" in alcuni browser */
input[type="file"]::file-selector-button {
    margin-right: 15px;
    border: 1px solid var(--border-color);
    background: var(--light-grey);
    padding: 6px 12px;
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color .2s;
}
input[type="file"]::file-selector-button:hover {
    background-color: #e2e6ea;
}