/**
 * MedVet Gravity - Frontend Styles
 * Select2 and lookup field styling for Pet and Referral fields
 */

/* ==========================================================================
   Pet Lookup Fields
   ========================================================================== */

/* Container styling */
.ginput_container_pet_lookup {
    position: relative;
}

/* Native select styling (before Select2 initializes) */
.ginput_container_pet_lookup select.gfield_pet_lookup {
    width: 100%;
    height: auto;
    min-height: 38px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: inherit;
    line-height: 28px;
    color: #333;
    box-sizing: border-box;
}

/* Select2 container width */
.ginput_container_pet_lookup .select2-container {
    width: 100% !important;
}

/* Match Gravity Forms field styling */
.ginput_container_pet_lookup .select2-container--default .select2-selection--single {
    height: auto;
    min-height: 38px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
}

.ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    padding-left: 0;
    color: #333;
}

.ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #999;
}

/* Focus state */
.ginput_container_pet_lookup .select2-container--default.select2-container--focus .select2-selection--single,
.ginput_container_pet_lookup .select2-container--default.select2-container--open .select2-selection--single {
    border-color: #173b6b;
    box-shadow: 0 0 0 1px #173b6b;
    outline: none;
}

/* Disabled state */
.ginput_container_pet_lookup .select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.ginput_container_pet_lookup .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__placeholder {
    color: #aaa;
}

/* Dropdown styling - hover/highlighted option */
.select2-container--default .select2-results__option--highlighted,
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #4a6a9b !important;
    color: #333 !important;
}

/* Currently selected option */
.select2-container--default .select2-results__option--selected,
.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #173b6b !important;
    color: #fff !important;
}

/* Search input in dropdown */
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #173b6b;
    outline: none;
}

/* Loading indicator */
.select2-container--default .select2-results__option.loading-results {
    color: #666;
    font-style: italic;
}

/* No results message */
.select2-container--default .select2-results__message {
    color: #666;
    font-style: italic;
    padding: 8px 12px;
}

/* Clear button styling */
.ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__clear {
    color: #999;
    font-size: 16px;
    margin-right: 20px;
}

.ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #333;
}

/* Hidden label input - should not be visible */
.gfield_pet_lookup_label {
    position: absolute;
    left: -9999px;
}

/* Error state */
.gfield_error .ginput_container_pet_lookup .select2-container--default .select2-selection--single {
    border-color: #c02b0a;
}

/* ==========================================================================
   Referral Autocomplete Fields
   ========================================================================== */

/* Autocomplete wrapper with "Not Listed" button */
.ginput_autocomplete_wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ginput_autocomplete_wrapper .select2-container {
    flex: 1;
}

/* Ensure Select2 input matches button height */
.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single {
    height: 42px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
}

.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    padding-left: 0;
    padding-right: 28px;
    color: #333;
}

.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #757575;
}

.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    right: 8px;
}

/* Focus state for referral fields */
.ginput_autocomplete_wrapper .select2-container--default.select2-container--focus .select2-selection--single,
.ginput_autocomplete_wrapper .select2-container--default.select2-container--open .select2-selection--single {
    border-color: #173b6b;
    box-shadow: 0 0 0 1px #173b6b;
    outline: none;
}

/* Clear button for referral fields */
.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__clear {
    margin-right: 24px;
    font-size: 18px;
    color: #757575;
}

.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #c02b0a;
}

/* Disabled state for referral fields */
.ginput_autocomplete_wrapper .select2-container--disabled .select2-selection--single {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* "Not Listed" button styling */
.gform_not_listed_btn {
    padding: 0 16px;
    border: 1px solid #193458;
    border-radius: 4px;
    background-color: #193458;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    height: 42px;
    box-sizing: border-box;
}

.gform_not_listed_btn:hover:not(:disabled) {
    background-color: #0f2138;
    border-color: #0f2138;
}

.gform_not_listed_btn:focus {
    border-color: #193458;
    box-shadow: 0 0 0 1px #193458;
    outline: none;
}

/* Active state when "Not Listed" is selected */
.gform_not_listed_btn.active {
    background-color: #0f2138;
    border-color: #0f2138;
    color: #fff;
}

.gform_not_listed_btn.active:hover {
    background-color: #0a1625;
    border-color: #0a1625;
}

/* Disabled state for "Not Listed" button */
.gform_not_listed_btn:disabled {
    background-color: #8a9bb0;
    border-color: #8a9bb0;
    color: #fff;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Loading state for "Not Listed" button */
.gform_not_listed_btn.loading {
    cursor: wait;
}

/* "Not Listed" active state - hint text styling */
.ginput_autocomplete_wrapper.not-listed-active .select2-container--default .select2-selection--single {
    background-color: #fff8e6;
    border-color: #f0c36d;
}

.ginput_autocomplete_wrapper.not-listed-active .select2-selection__rendered {
    color: #856404 !important;
    font-style: italic;
}

/* Practice autocomplete - name + address display in dropdown */
.select2-container--default .select2-results__option .practice-name {
    font-weight: 500;
}

.select2-container--default .select2-results__option .practice-address {
    font-size: 0.85em;
    color: #666;
    margin-top: 2px;
}

/* Ensure address text is visible when option is highlighted */
.select2-container--default .select2-results__option--highlighted .practice-address,
.select2-container--default .select2-results__option:hover .practice-address {
    color: rgba(255, 255, 255, 0.85);
}

/* Hidden label input for referral fields */
.gfield_referral_lookup_label {
    position: absolute;
    left: -9999px;
}

/* Error state for referral fields */
.gfield_error .ginput_autocomplete_wrapper .select2-container--default .select2-selection--single {
    border-color: #c02b0a;
}

/* ==========================================================================
   Mobile Compliance
   ========================================================================== */

/* iOS zoom prevention - 16px minimum font size */
.ginput_container_pet_lookup select.gfield_pet_lookup {
    font-size: 16px;
}

.ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 16px;
}

.ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 16px;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    font-size: 16px;
}

.select2-container--default .select2-results__option {
    font-size: 16px;
    padding: 10px 12px;
}

/* iOS touch highlight removal */
.ginput_container_pet_lookup select.gfield_pet_lookup,
.ginput_container_pet_lookup .select2-container,
.ginput_autocomplete_wrapper .select2-container,
.gform_not_listed_btn {
    -webkit-tap-highlight-color: transparent;
}

/* Hover states for devices that support hover */
@media (hover: hover) {
    .ginput_container_pet_lookup .select2-container--default .select2-selection--single:hover,
    .ginput_autocomplete_wrapper .select2-container--default .select2-selection--single:hover {
        border-color: #173b6b;
    }
}

/* Touch devices - no hover effect, just active */
@media (hover: none) {
    .ginput_container_pet_lookup .select2-container--default .select2-selection--single:hover,
    .ginput_autocomplete_wrapper .select2-container--default .select2-selection--single:hover {
        border-color: #ccc;
    }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .ginput_container_pet_lookup select.gfield_pet_lookup {
        min-height: 44px;
        padding: 6px 10px;
        line-height: 30px;
    }

    .ginput_container_pet_lookup .select2-container--default .select2-selection--single {
        min-height: 44px;
        padding: 6px 10px;
    }

    .ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 30px;
    }

    .ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 42px;
    }

    /* Referral fields - stack button below input */
    .ginput_autocomplete_wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .ginput_autocomplete_wrapper .select2-container {
        flex: none;
        width: 100% !important;
    }

    .gform_not_listed_btn {
        width: 100%;
        min-height: 44px;
    }

    /* Touch-friendly dropdown options */
    .select2-container--default .select2-results__option {
        padding: 12px 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Limit dropdown height on mobile */
    .select2-container--default .select2-results {
        max-height: 250px;
    }

    /* Touch-friendly search input */
    .select2-container--default .select2-search--dropdown .select2-search__field {
        min-height: 44px;
        padding: 10px 12px;
    }

    /* Clear button touch target */
    .ginput_container_pet_lookup .select2-container--default .select2-selection--single .select2-selection__clear,
    .ginput_autocomplete_wrapper .select2-container--default .select2-selection--single .select2-selection__clear {
        font-size: 20px;
        padding: 8px;
        margin-right: 24px;
    }

    /* Larger touch targets and more readable address text on mobile */
    .select2-container--default .select2-results__option .practice-address {
        font-size: 0.9em;
        margin-top: 4px;
    }
}

/* ==========================================================================
   Bottom Sheet Component (Mobile)
   ========================================================================== */

/* Bottom sheet overlay */
.medvet-bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    flex-direction: column;
    justify-content: flex-end;
}

.medvet-bottom-sheet.is-open {
    display: flex;
}

/* Backdrop */
.medvet-bottom-sheet__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.medvet-bottom-sheet.is-open .medvet-bottom-sheet__backdrop {
    opacity: 1;
}

/* Panel */
.medvet-bottom-sheet__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    background-color: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.medvet-bottom-sheet.is-open .medvet-bottom-sheet__panel {
    transform: translateY(0);
}

/* Drag handle */
.medvet-bottom-sheet__drag-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 4px;
    cursor: grab;
    touch-action: none;
}

.medvet-bottom-sheet__drag-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background-color: #d1d5db;
    border-radius: 2px;
}

.medvet-bottom-sheet__drag-handle:active {
    cursor: grabbing;
}

/* Header */
.medvet-bottom-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.medvet-bottom-sheet__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.medvet-bottom-sheet__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: none;
    color: #6b7280;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-bottom-sheet__close:hover,
.medvet-bottom-sheet__close:focus {
    background-color: #f3f4f6;
    color: #111827;
}

.medvet-bottom-sheet__close:focus {
    outline: 2px solid #173b6b;
    outline-offset: 2px;
}

/* Search container */
.medvet-bottom-sheet__search {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.medvet-bottom-sheet__search-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 16px; /* Prevents iOS zoom */
    line-height: 48px;
    color: #111827;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.medvet-bottom-sheet__search-input:focus {
    outline: none;
    border-color: #173b6b;
    box-shadow: 0 0 0 2px rgba(23, 59, 107, 0.2);
    background-color: #fff;
}

.medvet-bottom-sheet__search-input::placeholder {
    color: #9ca3af;
}

.medvet-bottom-sheet__search-hint {
    margin-top: 6px;
    font-size: 13px;
    color: #6b7280;
}

/* Results container */
.medvet-bottom-sheet__results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 150px;
}

/* Loading state */
.medvet-bottom-sheet__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    color: #6b7280;
    font-size: 15px;
}

.medvet-bottom-sheet__loading::before {
    content: '';
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid #e5e7eb;
    border-top-color: #173b6b;
    border-radius: 50%;
    animation: medvet-spin 0.8s linear infinite;
}

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

/* Error state */
.medvet-bottom-sheet__error {
    padding: 32px 16px;
    text-align: center;
    color: #dc2626;
    font-size: 15px;
}

/* Empty state */
.medvet-bottom-sheet__empty {
    padding: 32px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 15px;
}

/* Results list */
.medvet-bottom-sheet__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Result item */
.medvet-bottom-sheet__item {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-bottom-sheet__item:last-child {
    border-bottom: none;
}

.medvet-bottom-sheet__item:hover,
.medvet-bottom-sheet__item:focus,
.medvet-bottom-sheet__item.is-focused {
    background-color: #f3f4f6;
    outline: none;
}

.medvet-bottom-sheet__item:active {
    background-color: #e5e7eb;
}

.medvet-bottom-sheet__item[aria-selected="true"] {
    background-color: #173b6b;
    color: #fff;
}

.medvet-bottom-sheet__item[aria-selected="true"]:hover,
.medvet-bottom-sheet__item[aria-selected="true"]:focus,
.medvet-bottom-sheet__item[aria-selected="true"].is-focused {
    background-color: #0f2a4d;
}

.medvet-bottom-sheet__item-name {
    display: block;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
}

.medvet-bottom-sheet__item-address {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.3;
}

.medvet-bottom-sheet__item[aria-selected="true"] .medvet-bottom-sheet__item-address {
    color: rgba(255, 255, 255, 0.8);
}

/* Footer with sticky "Not Listed" button */
.medvet-bottom-sheet__footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background-color: #fff;
    flex-shrink: 0;
}

.medvet-bottom-sheet__not-listed {
    display: block;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid #193458;
    border-radius: 8px;
    background-color: #fff;
    color: #193458;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-bottom-sheet__not-listed:hover,
.medvet-bottom-sheet__not-listed:focus {
    background-color: #193458;
    color: #fff;
}

.medvet-bottom-sheet__not-listed:focus {
    outline: 2px solid #173b6b;
    outline-offset: 2px;
}

.medvet-bottom-sheet__not-listed:active {
    background-color: #0f2138;
    border-color: #0f2138;
    color: #fff;
}

/* Screen reader announcements */
.medvet-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Trigger Field (Mobile replacement for Select2)
   ========================================================================== */

.medvet-trigger-field {
    display: none;
    position: relative;
}

.medvet-trigger-field__input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 48px;
    padding: 0 44px 0 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 16px;
    color: #333;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-trigger-field__input:focus {
    outline: none;
    border-color: #173b6b;
    box-shadow: 0 0 0 1px #173b6b;
}

.medvet-trigger-field__input::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #757575;
    pointer-events: none;
}

.medvet-trigger-field__placeholder {
    color: #757575;
}

.medvet-trigger-field__value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.medvet-trigger-field__clear {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    color: #757575;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s ease, background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-trigger-field__clear:hover,
.medvet-trigger-field__clear:focus {
    color: #c02b0a;
    background-color: rgba(192, 43, 10, 0.1);
}

.medvet-trigger-field.has-value .medvet-trigger-field__clear {
    display: flex;
}

.medvet-trigger-field.has-value .medvet-trigger-field__input::after {
    display: none;
}

/* Disabled state */
.medvet-trigger-field.is-disabled .medvet-trigger-field__input {
    background-color: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

.medvet-trigger-field.is-disabled .medvet-trigger-field__clear {
    display: none;
}

/* Error state */
.gfield_error .medvet-trigger-field__input {
    border-color: #c02b0a;
}

/* Not Listed active state */
.medvet-trigger-field.not-listed-active .medvet-trigger-field__input {
    background-color: #fff8e6;
    border-color: #f0c36d;
}

.medvet-trigger-field.not-listed-active .medvet-trigger-field__value {
    color: #856404;
    font-style: italic;
}

/* ==========================================================================
   Responsive: Mobile Bottom Sheet / Desktop Select2
   ========================================================================== */

/* Mobile: Show trigger field, hide Select2 */
@media (max-width: 767px) {
    /* Show trigger field on mobile for referral fields */
    .ginput_autocomplete_wrapper.is-mobile-mode .medvet-trigger-field {
        display: block;
    }

    /* Hide Select2 on mobile for referral fields */
    .ginput_autocomplete_wrapper.is-mobile-mode .select2-container {
        display: none !important;
    }

    /* Hide original desktop "Not Listed" button on mobile */
    .ginput_autocomplete_wrapper.is-mobile-mode > .gform_not_listed_btn {
        display: none;
    }

    /* Adjust wrapper for mobile - full width, stacked layout */
    .ginput_autocomplete_wrapper.is-mobile-mode {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
}

/* Desktop: Show Select2, hide trigger field and bottom sheet */
@media (min-width: 768px) {
    /* Always hide trigger field on desktop */
    .medvet-trigger-field {
        display: none !important;
    }

    /* Always hide bottom sheet on desktop */
    .medvet-bottom-sheet {
        display: none !important;
    }
}

/* ==========================================================================
   Desktop Combobox Dropdown
   ========================================================================== */

/* Combobox container */
.medvet-combobox {
    position: relative;
    flex: 1;
}

/* Combobox trigger button */
.medvet-combobox__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 42px;
    padding: 0 40px 0 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 16px;
    color: #333;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-combobox__trigger:focus {
    outline: none;
    border-color: #173b6b;
    box-shadow: 0 0 0 1px #173b6b;
}

.medvet-combobox__trigger:hover:not(:disabled) {
    border-color: #173b6b;
}

/* Dropdown arrow */
.medvet-combobox__arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #757575;
    pointer-events: none;
    transition: transform 0.2s ease;
}

.medvet-combobox.is-open .medvet-combobox__arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Value display */
.medvet-combobox__value {
    display: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
    color: #333;
}

.medvet-combobox.has-value .medvet-combobox__value {
    display: block;
}

.medvet-combobox.has-value .medvet-combobox__placeholder {
    display: none;
}

/* Placeholder */
.medvet-combobox__placeholder {
    color: #757575;
}

/* Clear button */
.medvet-combobox__clear {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    color: #757575;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s ease, background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-combobox__clear:hover,
.medvet-combobox__clear:focus {
    color: #c02b0a;
    background-color: rgba(192, 43, 10, 0.1);
}

.medvet-combobox.has-value .medvet-combobox__clear {
    display: flex;
}

.medvet-combobox.has-value .medvet-combobox__arrow {
    display: none;
}

/* Disabled state */
.medvet-combobox.is-disabled .medvet-combobox__trigger {
    background-color: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

.medvet-combobox.is-disabled .medvet-combobox__placeholder {
    color: #aaa;
}

.medvet-combobox.is-disabled .medvet-combobox__clear {
    display: none;
}

/* Not Listed active state */
.medvet-combobox.not-listed-active .medvet-combobox__trigger {
    background-color: #fff8e6;
    border-color: #f0c36d;
}

.medvet-combobox.not-listed-active .medvet-combobox__value {
    color: #856404;
    font-style: italic;
}

/* Error state */
.gfield_error .medvet-combobox__trigger {
    border-color: #c02b0a;
}

/* ==========================================================================
   Combobox Dropdown Panel
   ========================================================================== */

.medvet-combobox__dropdown {
    position: fixed;
    max-height: 400px;
    display: none;
    flex-direction: column;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.medvet-combobox__dropdown.is-open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Dropdown opens upward when not enough space below */
.medvet-combobox__dropdown.is-flipped {
    transform-origin: bottom center;
    transform: translateY(8px);
}

.medvet-combobox__dropdown.is-flipped.is-open {
    transform: translateY(0);
}

/* Flip arrow direction when flipped */
.medvet-combobox.is-flipped.is-open .medvet-combobox__arrow {
    transform: translateY(-50%) rotate(0deg); /* Points down when dropdown is above */
}

/* Search input container */
.medvet-combobox__search {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.medvet-combobox__search-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-size: 16px;
    color: #111827;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.medvet-combobox__search-input:focus {
    outline: none;
    border-color: #173b6b;
    box-shadow: 0 0 0 2px rgba(23, 59, 107, 0.2);
    background-color: #fff;
}

.medvet-combobox__search-input::placeholder {
    color: #9ca3af;
}

.medvet-combobox__hint {
    margin-top: 6px;
    font-size: 13px;
    color: #6b7280;
}

/* Results container */
.medvet-combobox__results {
    flex: 1;
    overflow-y: auto;
    max-height: 280px;
}

/* Loading state */
.medvet-combobox__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 12px;
    color: #6b7280;
    font-size: 14px;
}

.medvet-combobox__loading::before {
    content: '';
    width: 18px;
    height: 18px;
    margin-right: 10px;
    border: 2px solid #e5e7eb;
    border-top-color: #173b6b;
    border-radius: 50%;
    animation: medvet-spin 0.8s linear infinite;
}

/* Error state */
.medvet-combobox__error {
    padding: 24px 12px;
    text-align: center;
    color: #dc2626;
    font-size: 14px;
}

/* Empty state */
.medvet-combobox__empty {
    padding: 24px 12px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* Results list */
.medvet-combobox__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Result item - mirrors bottom sheet styling */
.medvet-combobox__item {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-combobox__item:last-child {
    border-bottom: none;
}

.medvet-combobox__item:hover,
.medvet-combobox__item:focus,
.medvet-combobox__item.is-focused {
    background-color: #f3f4f6;
    outline: none;
}

.medvet-combobox__item:active {
    background-color: #e5e7eb;
}

.medvet-combobox__item[aria-selected="true"] {
    background-color: #173b6b;
    color: #fff;
}

.medvet-combobox__item[aria-selected="true"]:hover,
.medvet-combobox__item[aria-selected="true"]:focus,
.medvet-combobox__item[aria-selected="true"].is-focused {
    background-color: #0f2a4d;
}

.medvet-combobox__item-name {
    display: block;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
}

.medvet-combobox__item-address {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.3;
}

.medvet-combobox__item[aria-selected="true"] .medvet-combobox__item-address {
    color: rgba(255, 255, 255, 0.8);
}

/* Footer with sticky "Not Listed" button */
.medvet-combobox__footer {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background-color: #fff;
    flex-shrink: 0;
}

.medvet-combobox__not-listed {
    display: block;
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border: 1px solid #193458;
    border-radius: 6px;
    background-color: #fff;
    color: #193458;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.medvet-combobox__not-listed:hover,
.medvet-combobox__not-listed:focus {
    background-color: #193458;
    color: #fff;
}

.medvet-combobox__not-listed:focus {
    outline: 2px solid #173b6b;
    outline-offset: 2px;
}

.medvet-combobox__not-listed:active {
    background-color: #0f2138;
    border-color: #0f2138;
    color: #fff;
}

/* ==========================================================================
   Desktop Combobox Integration with Referral Fields
   ========================================================================== */

/* Hide Select2 and old Not Listed button when combobox is active */
.ginput_autocomplete_wrapper.has-combobox .select2-container {
    display: none !important;
}

.ginput_autocomplete_wrapper.has-combobox > .gform_not_listed_btn {
    display: none !important;
}

/* Combobox takes the full width in the wrapper */
.ginput_autocomplete_wrapper.has-combobox {
    display: block;
}

/* Desktop-only: show combobox */
@media (min-width: 768px) {
    .ginput_autocomplete_wrapper.is-desktop-mode .medvet-combobox {
        display: block;
    }
}

/* Mobile: hide combobox */
@media (max-width: 767px) {
    .medvet-combobox {
        display: none !important;
    }
}
