/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.is-active {
    display: flex;
}

/* Modal Container */
.modal-container {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Close Button */
.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--color-gray-600);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
    z-index: 10001;
}

.modal-close:hover {
    background-color: var(--color-gray-200);
    color: var(--color-blue-700);
}

/* Modal Content */
.modal-content {
    padding: 40px;
}

.modal-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-blue-700);
    margin: 0 0 8px 0;
    padding-right: 40px;
}

.modal-subtitle {
    font-size: 1rem;
    color: var(--color-gray-600);
    margin: 0 0 32px 0;
}

/* Form Styles */
.quote-form {
    display: block;
}

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

.form-field {
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-blue-700);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.required {
    color: #e53e3e;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--color-gray-300);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-blue-900);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: white;
}

.form-field input[type="text"]:focus,
.form-field input[type="email"]:focus,
.form-field input[type="tel"]:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--color-blue-500);
    box-shadow: 0 0 0 3px rgba(65, 133, 192, 0.1);
}

.form-field textarea {
    resize: vertical;
    min-height: 100px;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
    color: var(--color-gray-500);
}

/* Error States */
.form-field.has-error input,
.form-field.has-error textarea {
    border-color: #e53e3e;
}

.form-field.has-error input:focus,
.form-field.has-error textarea:focus {
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.error-message {
    display: none;
    color: #e53e3e;
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 500;
}

.form-field.has-error .error-message {
    display: block;
}

/* SMS Consent Checkbox */
.sms-consent {
    margin-bottom: 20px;
}

.sms-consent .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
}

.sms-consent input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--color-blue-600);
}

.sms-consent .checkbox-text {
    font-size: 0.75rem;
    color: var(--color-gray-600);
    line-height: 1.5;
}

.sms-consent .checkbox-text a {
    color: var(--color-blue-600);
    text-decoration: underline;
}

.sms-consent .checkbox-text a:hover {
    color: var(--color-blue-700);
}

/* Honeypot (Anti-spam) */
.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Form Actions */
.form-actions {
    margin-top: 32px;
    display: flex;
    justify-content: flex-end;
}

.btn--submit {
    position: relative;
    min-width: 180px;
    padding: 14px 32px;
}

.btn--submit .btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.btn--submit.is-loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn--submit.is-loading .btn-text {
    visibility: hidden;
}

.btn--submit.is-loading .btn-loader {
    display: block;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Success Message */
.success-message {
    display: none;
    text-align: center;
    padding: 40px 20px;
}

.success-message.is-active {
    display: block;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background-color: #48bb78;
    color: white;
    font-size: 48px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-message h3 {
    font-size: 1.5rem;
    color: var(--color-blue-700);
    margin: 0 0 12px 0;
}

.success-message p {
    font-size: 1rem;
    color: var(--color-gray-600);
    margin: 0 0 24px 0;
    line-height: 1.6;
}

/* Non-Serviced Area Variant */
.success-message--not-serviced {
    background: linear-gradient(180deg, #fef9f6 0%, #ffffff 100%);
    border-radius: 16px;
}

.success-icon--not-serviced {
    width: 88px;
    height: 88px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, rgba(242, 101, 34, 0.1) 0%, rgba(30, 90, 158, 0.1) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e5a9e;
    position: relative;
    animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(242, 101, 34, 0.1);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 12px rgba(242, 101, 34, 0);
    }
}

.success-message--not-serviced h3 {
    font-size: 1.5rem;
    color: var(--color-blue-700, #1e5a9e);
    margin: 0 0 16px 0;
    font-weight: 700;
}

.success-message__lead {
    font-size: 1.05rem;
    color: #4a5568;
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.success-message__detail {
    font-size: 0.95rem;
    color: #718096;
    margin: 0 0 28px 0;
    line-height: 1.65;
}

.success-message__detail a {
    color: #f26522;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(242, 101, 34, 0.3);
    transition: border-color 0.2s ease, color 0.2s ease;
}

.success-message__detail a:hover {
    color: #d4541d;
    border-bottom-color: #f26522;
}

/* "Doesn't Build" Area Variant */
.success-message--doesnt-build {
    background: linear-gradient(180deg, #f0f6fc 0%, #ffffff 100%);
    border-radius: 16px;
}

.success-message--doesnt-build h3 {
    font-size: 1.5rem;
    color: var(--color-blue-700, #1e5a9e);
    margin: 0 0 16px 0;
    font-weight: 700;
}

.success-message--doesnt-build.is-active .success-icon--not-serviced {
    animation: iconEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               gentlePulse 3s ease-in-out 0.5s infinite;
}

/* Entrance animation for the icon */
.success-message--not-serviced.is-active .success-icon--not-serviced {
    animation: iconEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               gentlePulse 3s ease-in-out 0.5s infinite;
}

@keyframes iconEntrance {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.quote-form.is-hidden {
    display: none;
}

/* Error Box */
.error-box {
    display: none;
    background-color: #fed7d7;
    border: 1px solid #fc8181;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 20px;
}

.error-box.is-active {
    display: block;
}

.error-text {
    color: #c53030;
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
}

/* Mobile Responsive */
@media screen and (max-width: 600px) {
    .modal-content {
        padding: 24px 20px;
    }

    .modal-title {
        font-size: 1.5rem;
        padding-right: 32px;
    }

    .modal-subtitle {
        font-size: 0.875rem;
        margin-bottom: 24px;
    }

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

    .form-field {
        margin-bottom: 16px;
    }

    .form-actions {
        margin-top: 24px;
    }

    .btn--submit {
        width: 100%;
    }

    .modal-container {
        margin: 20px 0;
    }
}

@media screen and (max-width: 400px) {
    .modal-overlay {
        padding: 10px;
    }

    .modal-content {
        padding: 20px 16px;
    }

    .modal-close {
        top: 12px;
        right: 12px;
        width: 28px;
        height: 28px;
        font-size: 28px;
    }
}
