/**
 * Style - Buy Come Stai - Flusso di acquisto cliente
 * Branding: gradient green→blue, white cards, clean design
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f0f2f5;
    min-height: 100vh;
}

/* Header */
.buy-header {
    background: linear-gradient(135deg, #27ae60 0%, #2980b9 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.buy-header .logo {
    max-height: 60px;
    margin-bottom: 12px;
}

.buy-header .frase {
    font-size: 18px;
    font-weight: 300;
    opacity: 0.95;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

.buy-header .descrizione {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.82;
    max-width: 560px;
    margin: 8px auto 0;
    line-height: 1.6;
}

/* Container */
.buy-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.buy-container.narrow {
    max-width: 560px;
}

/* Cards */
.buy-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 28px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.buy-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.buy-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}

/* Package cards */
.package-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.package-card {
    background: #ffffff;
    border: 2px solid #e8ecf0;
    border-radius: 12px;
    padding: 28px;
    text-align: center;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    flex: 0 1 320px;
    min-width: 260px;
}

.package-card:hover {
    border-color: #27ae60;
    box-shadow: 0 6px 24px rgba(39, 174, 96, 0.15);
    transform: translateY(-3px);
}

.package-card .package-name {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
}

.package-card .package-desc {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    flex-grow: 1;
    line-height: 1.5;
}

.package-card .package-price {
    font-size: 28px;
    font-weight: 800;
    color: #27ae60;
    margin-bottom: 20px;
}

.package-card .package-price .currency {
    font-size: 16px;
    font-weight: 600;
    color: #555;
}

/* Checkbox consensi */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: #27ae60;
    cursor: pointer;
}

.checkbox-label a {
    color: #27ae60;
    text-decoration: underline;
}

.checkbox-label a:hover {
    color: #1a7a3f;
}

/* Buttons */
.btn-buy {
    display: inline-block;
    background: linear-gradient(135deg, #27ae60 0%, #219a52 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-buy:hover {
    background: linear-gradient(135deg, #219a52 0%, #1a7a3f 100%);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
    transform: translateY(-1px);
}

.btn-buy:active {
    transform: translateY(0);
}

.btn-buy:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-buy.loading {
    position: relative;
    color: transparent;
}

.btn-buy.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Form */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
}

.form-group label .required {
    color: #e74c3c;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 2px solid #dde1e6;
    border-radius: 8px;
    background: #fff;
    color: #333;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

.form-control::placeholder {
    color: #aab0b8;
}

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

/* Order summary */
.order-summary {
    background: linear-gradient(135deg, #f8fffe 0%, #f0f7ff 100%);
    border: 2px solid #e0eeea;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.order-summary h3 {
    font-size: 16px;
    color: #555;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-summary .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.order-summary .summary-item .item-label {
    color: #555;
    font-size: 15px;
}

.order-summary .summary-item .item-value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
}

.order-summary .summary-total {
    border-top: 2px solid #d0e0da;
    margin-top: 12px;
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-summary .summary-total .item-label {
    font-size: 17px;
    font-weight: 700;
    color: #2c3e50;
}

.order-summary .summary-total .item-value {
    font-size: 22px;
    font-weight: 800;
    color: #27ae60;
}

/* Stripe Element */
.stripe-element-container {
    padding: 14px;
    border: 2px solid #dde1e6;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 20px;
    transition: border-color 0.2s ease;
}

.stripe-element-container.focused {
    border-color: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

/* Messages */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 15px;
    line-height: 1.5;
}

.alert-error {
    background: #fdf0f0;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-info {
    background: #f0f8ff;
    border: 1px solid #bee3f8;
    color: #1e40af;
}

/* Error page */
.error-page {
    text-align: center;
    padding: 60px 20px;
}

.error-page .error-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.error-page h2 {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 12px;
}

.error-page p {
    font-size: 16px;
    color: #666;
    max-width: 400px;
    margin: 0 auto;
}

/* Confirmation page */
.confirmation-box {
    text-align: center;
    padding: 20px 0;
}

.confirmation-box .success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.confirmation-box .success-icon svg {
    width: 40px;
    height: 40px;
    stroke: white;
    stroke-width: 3;
    fill: none;
}

.confirmation-box h2 {
    font-size: 24px;
    color: #27ae60;
    margin-bottom: 10px;
}

.confirmation-box .message {
    font-size: 16px;
    color: #555;
    margin-bottom: 24px;
}

.qr-image-box {
    background: #fff;
    border: 3px solid #e8ecf0;
    border-radius: 16px;
    padding: 24px;
    display: inline-block;
    margin: 20px 0;
}

.qr-image-box img {
    max-width: 250px;
    height: auto;
    display: block;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    color: #888;
}

.detail-row .value {
    font-weight: 600;
    color: #2c3e50;
}

/* Loading / polling */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e8ecf0;
    border-top-color: #27ae60;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.loading-state h2 {
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 8px;
}

.loading-state p {
    font-size: 15px;
    color: #888;
}

/* Footer */
.buy-footer {
    text-align: center;
    padding: 24px 20px;
    font-size: 13px;
    color: #999;
}

.buy-footer a {
    color: #27ae60;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 600px) {
    .buy-header {
        padding: 24px 16px;
    }

    .buy-header .logo {
        max-height: 48px;
    }

    .buy-header .frase {
        font-size: 15px;
    }

    .buy-container {
        padding: 20px 16px 40px;
    }

    .buy-card {
        padding: 20px;
    }

    .package-card {
        flex: 1 1 100%;
        min-width: unset;
        padding: 22px;
    }

    .package-card .package-price {
        font-size: 24px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .order-summary .summary-total .item-value {
        font-size: 18px;
    }

    .btn-buy {
        padding: 12px 24px;
        font-size: 15px;
    }

    .qr-image-box img {
        max-width: 200px;
    }
}

@media (max-width: 400px) {
    .buy-header .frase {
        font-size: 14px;
    }

    .package-card .package-name {
        font-size: 18px;
    }

    .buy-card {
        padding: 16px;
    }
}
