/* Lead Generation Modal - "Modern Editorial" Aesthetic 
   Consistent with RisparmioCerto.it Brand System */

:root {
    --lg-primary: #44BB67;
    --lg-secondary: #4281A4;
    --lg-text: #283333;
    --lg-text-light: #666666;
    --lg-bg-soft: #f9fbfd;
}

.lg-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 14, 1, 0.8); /* Brand Black with opacity */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(12px) saturate(180%);
    padding: 20px;
}

.lg-modal-container {
    display: flex;
    width: 100%;
    max-width: 1080px;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.15);
    max-height: 90vh;
    min-height: 600px; /* Added min-height */
    position: relative;
    font-family: 'Greycliff CF', system-ui, -apple-system, sans-serif;
    animation: lg-modal-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* The signature top line from the site's design */
.lg-modal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--lg-secondary), var(--lg-primary));
    z-index: 10;
}

@keyframes lg-modal-pop {
    0% { opacity: 0; transform: scale(0.9) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Loading State ── */

.lg-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--lg-primary);
    font-size: 1.1rem;
    font-weight: 600;
    gap: 15px;
    min-height: 400px; /* Ensure vertical centering space */
}

.lg-loading i {
    font-size: 3rem;
    margin-bottom: 10px;
}

/* ── Integrated Sidebar (The "Info" Block) ── */

.lg-sidebar {
    width: 300px;
    background: #f8fafc;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    border-right: 1px solid #edf2f7;
    position: relative;
    justify-content: center;
}

.lg-sidebar-logo-wrap {
    width: 220px;
    height: 180px;
    background: #fff;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    border: 1px solid #f0f0f0;
    transition: transform 0.3s ease;
    padding: 20px;
}

.lg-sidebar-logo-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lg-sidebar-benefits {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lg-benefit {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lg-benefit-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--lg-secondary);
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.lg-benefit-text strong {
    display: block;
    color: var(--lg-text);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
}

.lg-benefit-text span {
    color: var(--lg-text-light);
    font-size: 0.8rem;
    font-weight: 500;
}

/* ── Form Side ── */

.lg-form-side {
    flex: 1;
    background: #fff;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lg-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 35px 0;
}

.lg-secure-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(66, 129, 164, 0.08); /* Secondary Blue */
    color: var(--lg-secondary);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lg-modal-close {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.lg-modal-close i {
    font-size: 1.1rem; /* Adjust icon size specifically */
    margin: 0;
    line-height: 1;
}

.lg-modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
}

.lg-modal-content {
    padding: 25px 40px 40px; /* Increased padding */
    overflow-y: auto;
}

.lg-offer-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--lg-primary);
    margin: 0 0 8px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.lg-offer-desc {
    color: var(--lg-text-light);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 25px; /* Increased margin */
}

.lg-offer-desc strong {
    color: var(--lg-text);
    font-weight: 800;
}

/* ── Compact Form Grid ── */

#lg-lead-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px 20px; /* Increased gap */
}

.lg-form-group {
    margin-bottom: 0;
}

/* Full width fields (like textarea or specific types) */
.lg-form-group:has(textarea),
.lg-form-group:nth-last-child(2), /* Success message/Alert area */
.lg-policies,
.lg-submit-btn {
    grid-column: span 2;
}

.lg-form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--lg-text);
}

.lg-form-input,
.lg-form-select,
.lg-form-textarea {
    width: 100%;
    padding: 14px 18px; /* Increased padding */
    border: 2px solid #edf2f7;
    border-radius: 14px;
    font-size: 0.95rem;
    color: var(--lg-text);
    background: #f8fafc;
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.lg-form-input:focus,
.lg-form-select:focus,
.lg-form-textarea:focus {
    border-color: var(--lg-primary);
    background: #fff;
    outline: none;
    box-shadow: 0 5px 15px rgba(68, 187, 103, 0.05);
}

/* ── Ultra Compact Policies Section ── */

.lg-policies {
    margin-top: 15px; /* Increased margin */
    padding: 0;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Increased gap */
}

.lg-policy-item {
    margin-bottom: 0;
}

.lg-policy-label {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    line-height: 1.2;
    color: var(--lg-text-light);
    cursor: pointer;
    align-items: center;
    white-space: nowrap;
}

.lg-policy-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    accent-color: var(--lg-primary);
}

/* ── Submit Button ── */

.lg-submit-btn {
    width: 100%;
    padding: 16px 25px;
    background: var(--lg-primary);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-top: 15px;
    box-shadow: 0 10px 25px rgba(68, 187, 103, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.lg-submit-btn:hover {
    background: #39a65a;
    transform: translateY(-3px);
}


.lg-submit-btn:active {
    transform: translateY(0) scale(1);
}

/* ── Success Animations ── */

.lg-success {
    text-align: center;
    padding: 50px 20px;
}

.lg-success i {
    font-size: 6rem;
    color: var(--lg-primary);
    margin-bottom: 30px;
    display: block;
    animation: success-check 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes success-check {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.lg-success h3 {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--lg-text);
    margin-bottom: 15px;
}

/* ── Mobile Optimization ── */

@media (max-width: 820px) {
    .lg-modal-container {
        flex-direction: column;
        max-height: 98vh;
        max-width: 100%;
        border-radius: 0;
    }

    .lg-modal-overlay {
        padding: 0;
    }

    .lg-sidebar {
        width: 100%;
        padding: 30px;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid #edf2f7;
    }

    .lg-sidebar-logo-wrap {
        width: 70px;
        height: 70px;
        margin-bottom: 0;
        border-radius: 20px;
        padding: 10px;
    }

    .lg-sidebar-logo-wrap img {
        max-width: 100%;
    }

    .lg-sidebar-benefits {
        display: none;
    }

    .lg-sidebar-mobile-info {
        display: flex;
        flex-direction: column;
        margin-left: 20px;
    }

    .lg-sidebar-mobile-info strong {
        font-size: 1.3rem;
        font-weight: 900;
    }

    .lg-form-header {
        padding: 25px 30px 0;
    }

    .lg-modal-content {
        padding: 20px 30px 40px;
    }

    .lg-offer-title {
        font-size: 1.7rem;
    }
}

@media (min-width: 821px) {
    .lg-sidebar-mobile-info {
        display: none;
    }
}

/* ── Recommendation View (Success Mode) ── */

.lg-modal-container.success-mode {
    flex-direction: column;
    background: #fff;
    /* Maintain dimensions or auto-adjust */
    min-height: 600px;
}

.lg-modal-container.success-mode .lg-sidebar {
    display: none;
}

.lg-modal-container.success-mode .lg-form-side {
    width: 100%;
}

.lg-success-view {
    padding: 20px 40px 40px;
    animation: lg-shutter-down 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    background: #fff;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

@keyframes lg-shutter-down {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Header */
.lg-rec-header {
    text-align: center;
    margin-bottom: 30px;
}

.lg-rec-icon {
    width: 60px;
    height: 60px;
    background: var(--lg-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 15px;
    box-shadow: 0 10px 20px rgba(68, 187, 103, 0.3);
}

.lg-rec-header h3 {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--lg-text);
    margin: 0 0 10px;
}

.lg-rec-header p {
    color: var(--lg-text-light);
    font-size: 1rem;
}

/* Divider */
.lg-rec-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 30px 0;
}

.lg-rec-divider::before,
.lg-rec-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #edf2f7;
}

.lg-rec-divider span {
    padding: 0 15px;
    color: #a0aec0;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Grid */
.lg-rec-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .lg-rec-grid {
        grid-template-columns: 1fr;
    }
}

/* Card */
.lg-rec-card {
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: 16px;
    padding: 20px;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lg-rec-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.08);
    border-color: #e2e8f0;
}

.lg-rec-type {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    color: #fff;
}

.badge-fisso { background: #3498db; }
.badge-mobile { background: #e67e22; }
.badge-luce { background: #f1c40f; color: #333; }
.badge-gas { background: #9b59b6; }

.lg-rec-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    width: 100%;
}

.lg-rec-logo {
    height: 40px;
    max-width: 100px;
    object-fit: contain;
}

.lg-rec-price {
    color: var(--lg-text);
    font-weight: 800;
}

.lg-rec-price-int { font-size: 1.5rem; }
.lg-rec-price-dec { font-size: 0.9rem; }

.lg-rec-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--lg-text);
    margin: 0 0 10px;
    line-height: 1.3;
}

.lg-rec-feat {
    background: #f7fafc;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--lg-text-light);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lg-rec-btn {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 2px solid var(--lg-primary);
    color: var(--lg-primary);
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
    margin-top: auto;
}

.lg-rec-btn:hover {
    background: var(--lg-primary);
    color: #fff;
}