.form-control-pill {
    background-color: #f3f4f6 !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 35px !important;
    padding: 12px 25px !important;
    font-size: 1.1rem !important;
    width: 100% !important;
    color: #333 !important;
    transition: all 0.25s;
    height: auto !important;
    outline: none !important;
}

.form-control-pill:focus {
    background-color: #fff !important;
    border-color: #7b4bb7 !important;
}

/* Input Group with Prefix (e.g., £) */
.input-group-custom {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-group-custom .prefix {
    position: absolute;
    left: 20px;
    font-size: 1.1rem;
    color: #333;
    pointer-events: none;
    z-index: 2;
    /* Ensure it stays above input background */
}

/* Increase padding-left specifically for inputs with prefixes to avoid overlap */
.input-group-custom .form-control-pill {
    padding-left: 48px !important;
}

/* Custom dropdown arrow for pill selects */
select.form-control-pill {
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 25px center !important;
    padding-right: 50px !important;
    cursor: pointer !important;
}

/* Custom Select Enhancer (JS-backed) */
.custom-select-container {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select-display {
    cursor: pointer;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 35px;
    padding: 12px 25px;
    font-size: 1.1rem;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s;
    min-height: 52px;
}

.custom-select-display:after {
    content: "";
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
}

.custom-select-container.is-open .custom-select-display {
    background-color: #fff;
    border-color: #7b4bb7;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-container.is-open .custom-select-display:after {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #7b4bb7;
    border-top: none;
    border-bottom-left-radius: 35px;
    border-bottom-right-radius: 35px;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    /* This clips the scrollbar to the rounded corners */
    overflow: hidden;
}

.custom-select-scroller {
    max-height: 70vh;
    overflow-y: auto;
    width: calc(100% - 8px);
    margin: 0 auto;
    /* Custom scrollbar for better fit */
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.custom-select-scroller::-webkit-scrollbar {
    width: 6px;
}

.custom-select-scroller::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-scroller::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 10px;
}

/* Ensure buttons are visible if browser wants them */
.custom-select-scroller::-webkit-scrollbar-button {
    display: block;
    height: 10px;
}

.custom-select-container.is-open .custom-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    padding: 6px 21px;
    cursor: pointer;
    transition: background 0.2s;
    color: #444;
    text-align: left;
    border-radius: 10px;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
}

.custom-select-option:hover {
    background: #f7f3ff;
    color: #7b4bb7;
}

.custom-select-option.selected {
    background: #f0eaff;
    color: #7b4bb7;
    font-weight: 600;
}

/* Validation Styles */
.is-invalid {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
}

.is-valid {
    /* Keep neutral to focus on the icon instead */
    border-color: transparent !important;
}

.error-shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Validation icon inside input and message below input */
.form-group {
    position: relative;
    margin-bottom: 1.25rem;
    display: grid;
    grid-template-areas: "field";
    align-items: center;
    /* This ensures the icon stays centered against the first row */
}

/* Layer the input and the icon in the same grid spot */
.form-control-pill,
.validation-icon {
    grid-area: field;
}

.validation-icon {
    justify-self: end;
    margin-right: 18px;
    font-size: 1.1rem;
    pointer-events: none;
    z-index: 10;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

/* Give inputs room for the icon on the right */
/* Specific adjustment for full-width groups if needed, but top 50% relative to input is better */
.form-group .form-control-pill {
    padding-right: 50px !important;
}

/* If the form-group contains a label, we might need a different top value, 
   but currently, placeholders are used. Let's make it relative to the input. */

.form-group .validation-message,
.form-group .api-validation-message {
    grid-row: 2;
    /* Move messages to a second row */
    padding-left: 25px;
    margin-top: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    display: block;
    min-height: 1.2em;
    animation: revealError 0.35s ease-out forwards;
}

@keyframes revealError {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.validation-icon.text-success {
    color: #28a745 !important;
}

.validation-icon.text-danger {
    color: #dc3545 !important;
}

.validation-spinner .spinner-border {
    width: 1.1rem;
    height: 1.1rem;
    border-width: 0.15em;
    color: #7b4bb7;
}

/* Shared Multi-step Form Components */

.quote-card,
.contact-form-card {
    background: #fff;
    border: 15px solid var(--doddle-navy);
    border-radius: 40px;
    width: 100%;
    max-width: 600px;
    padding: 45px 35px 85px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    margin: 0 auto;
}

.quote-card-title {
    font-size: 2rem;
    font-weight: 800;
    color: #555c66;
    margin-bottom: 5px;
    text-align: center;
}

.quote-card-subtitle {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 30px;
    text-align: center;
}

.contact-form-card {
    padding-bottom: 50px;
    /* Contact card doesn't have absolute footer */
}

.progress-container {
    background: #e1f5f3;
    height: 18px;
    border-radius: 20px;
    margin-bottom: 30px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    background: var(--doddle-teal);
    height: 100%;
    width: 25%;
    transition: width 0.6s ease;
}

.form-step {
    display: none;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.form-step.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #555c66;
    margin-bottom: 30px;
}

/* Options Grid & Cards */
.options-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.option-card {
    border: 1px solid #eee;
    border-radius: 20px;
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    width: calc(50% - 10px);
    max-width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.option-card:hover {
    border-color: var(--doddle-teal);
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
}

.option-card.selected {
    border-color: var(--doddle-teal);
    background-color: #f7feff;
}

.icon-circle {
    width: 85px;
    height: 85px;
    border: 4px solid var(--doddle-teal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    color: var(--doddle-teal);
    /* Standardized text styling for text-based icons (YES/NO) */
    font-size: 2rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
    /* Fixes vertical misalignment */
    padding-top: 2px;
    padding-left: 2px;
    /* Optical nudge for perfect horizontal center */
    /* Optical nudge for perfect perceived center */
}

.option-icon {
    font-size: 2.5rem;
    color: inherit;
}

.option-card:hover .icon-circle,
.option-card.selected .icon-circle {
    background-color: var(--doddle-teal);
    color: #fff;
}

.option-label {
    font-size: 1.25rem;
    font-weight: 700;
    color: #444;
}

/* Form Layout Grids */
.form-grid,
.contact-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    text-align: left;
}

.full-width {
    grid-column: span 2;
}

.consent-text {
    font-size: 0.95rem;
    color: #777;
    margin-top: 20px;
    line-height: 1.5;
    grid-column: span 2;
}

.consent-text a {
    color: #e63946;
    text-decoration: none;
    font-weight: 700;
}

/* Navigation Buttons */
.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 35px;
}

.btn-prev {
    background: #fff;
    border: 2.5px solid #7b4bb7;
    color: #7b4bb7;
    border-radius: 40px;
    padding: 12px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    transition: all 0.25s;
}

.btn-submit,
.btn-contact-submit {
    background: #7b4bb7;
    border: none;
    color: #fff;
    border-radius: 40px;
    padding: 12px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(123, 75, 183, 0.3);
    transition: all 0.25s;
}

.btn-contact-submit {
    margin: 30px auto 0;
    display: block;
}

.btn-submit:hover,
.btn-prev:hover,
.btn-contact-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 75, 183, 0.4);
}

/* Integrated Form Footer */
.integrated-footer {
    background: var(--doddle-navy);
    color: #fff;
    position: absolute;
    bottom: 0px;
    left: 0px;
    right: 0px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 15px 5px 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.footer-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mobile Optimizations - Sitewide Forms */
@media (max-width: 768px) {

    .quote-card,
    .contact-form-card {
        padding: 30px 15px 85px;
        border-width: 10px;
    }

    .contact-form-card {
        padding-bottom: 40px;
    }

    .step-title {
        font-size: 1.8rem;
        margin-bottom: 30px;
    }

    .options-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
    }

    .option-card {
        width: 100% !important;
        min-width: 0 !important;
        padding: 15px 5px !important;
    }

    .icon-circle {
        width: 70px !important;
        height: 70px !important;
        margin-bottom: 10px !important;
        border-width: 3px !important;
    }

    .option-icon {
        font-size: 2.2rem !important;
    }

    .option-label {
        font-size: 1rem !important;
    }

    .form-grid,
    .contact-form-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .nav-buttons {
        flex-direction: column-reverse !important;
        gap: 12px !important;
    }

    .btn-prev,
    .btn-submit,
    .btn-contact-submit {
        width: 100% !important;
        padding: 12px 20px !important;
    }

    .integrated-footer {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 15px 20px !important;
        text-align: center !important;
        font-size: 1rem !important;
    }
}