/**
 * Searchable Combobox + Location Selection System styles.
 * Integrates with the sell-dashboard design system (Inter, 12px radii, #006AFF brand).
 */

/* Container */
.tb-combobox {
    position: relative;
    width: 100%;
}

.tb-combobox-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* Input field — mirrors .tb-sell-input */
.tb-combobox-input.tb-sell-input {
    width: 100%;
    padding-right: 2.5rem;
    cursor: text;
    text-overflow: ellipsis;
}

.tb-combobox-input.tb-sell-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f8fafc;
}

/* Clear button (X) */
.tb-combobox-clear {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
    height: 1.375rem;
    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.625rem;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
    z-index: 2;
}

.tb-combobox-clear:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* Chevron toggle */
.tb-combobox-chevron {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    color: #94a3b8;
    cursor: pointer;
    transition: transform 0.2s ease, color 0.15s ease;
    z-index: 2;
}

.tb-combobox--open .tb-combobox-chevron {
    transform: translateY(-50%) rotate(180deg);
    color: #006aff;
}

.tb-combobox-chevron:hover {
    color: #475569;
}

/* Dropdown list */
.tb-combobox-listbox {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 0.375rem;
    list-style: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.07),
        0 10px 25px -3px rgba(0, 0, 0, 0.1);
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.tb-combobox-listbox::-webkit-scrollbar {
    width: 6px;
}

.tb-combobox-listbox::-webkit-scrollbar-track {
    background: transparent;
}

.tb-combobox-listbox::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Individual option */
.tb-combobox-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5625rem 0.75rem;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #0f172a;
    cursor: pointer;
    transition: background-color 0.1s ease;
    line-height: 1.35;
}

.tb-combobox-option:hover,
.tb-combobox-option--highlight {
    background: #f1f5f9;
}

.tb-combobox-option--selected {
    background: #e8f2ff;
    color: #006aff;
    font-weight: 600;
}

.tb-combobox-option--selected:hover,
.tb-combobox-option--selected.tb-combobox-option--highlight {
    background: #dbeafe;
}

/* Option label container */
.tb-combobox-option-label {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.tb-combobox-option-am {
    font-size: 12px;
    font-weight: 400;
    color: #64748b;
    white-space: nowrap;
}

.tb-combobox-option-meta {
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Match highlight */
.tb-combobox-match {
    background: #fef08a;
    color: #0f172a;
    border-radius: 2px;
    padding: 0 1px;
}

/* Empty state */
.tb-combobox-empty {
    padding: 1rem 0.75rem;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
}

/* "Other" option — visually distinct */
.tb-combobox-option--other {
    margin-top: 0.25rem;
    padding-top: 0.625rem;
    border-top: 1px solid #f1f5f9;
    color: #475569;
    font-weight: 600;
    gap: 0.625rem;
}

.tb-combobox-option--other:hover,
.tb-combobox-option--other.tb-combobox-option--highlight {
    background: #fffbeb;
    color: #92400e;
}

.tb-combobox-other-icon {
    font-size: 0.75rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.tb-combobox-option--other:hover .tb-combobox-other-icon {
    color: #92400e;
}

/* Coordinates badge */
.tb-sell-coords-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border-radius: 10px;
    background: #e8f2ff;
    border: 1px solid #bfdbfe;
    font-family: Inter, sans-serif;
}

.tb-sell-coords-badge .fa-map-pin {
    font-size: 0.8125rem;
}

/* Region select refinement (match combobox height) */
.tb-sell-form-column #pRegion.tb-sell-select {
    height: 2.875rem;
}

/* "Other" text input reveal animation */
#pCityOtherWrap {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.25s ease;
    max-height: 0;
    opacity: 0;
}

#pCityOtherWrap:not(.hidden) {
    max-height: 120px;
    opacity: 1;
}

/* Dark mode support */
.dark .tb-combobox-input.tb-sell-input {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.dark .tb-combobox-input.tb-sell-input::placeholder {
    color: #64748b;
}

.dark .tb-combobox-input.tb-sell-input:focus {
    border-color: #006aff;
    box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.2);
}

.dark .tb-combobox-listbox {
    background: #1e293b;
    border-color: #334155;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 25px -3px rgba(0, 0, 0, 0.4);
}

.dark .tb-combobox-option {
    color: #e2e8f0;
}

.dark .tb-combobox-option:hover,
.dark .tb-combobox-option--highlight {
    background: #334155;
}

.dark .tb-combobox-option--selected {
    background: rgba(0, 106, 255, 0.15);
    color: #60a5fa;
}

.dark .tb-combobox-option-am {
    color: #94a3b8;
}

.dark .tb-combobox-option-meta {
    color: #64748b;
}

.dark .tb-combobox-match {
    background: rgba(250, 204, 21, 0.25);
    color: #fef08a;
}

.dark .tb-combobox-empty {
    color: #64748b;
}

.dark .tb-combobox-clear {
    background: #334155;
    color: #94a3b8;
}

.dark .tb-combobox-clear:hover {
    background: #475569;
    color: #e2e8f0;
}

.dark .tb-combobox-chevron {
    color: #64748b;
}

.dark .tb-combobox-option--other {
    border-top-color: #334155;
    color: #94a3b8;
}

.dark .tb-combobox-option--other:hover,
.dark .tb-combobox-option--other.tb-combobox-option--highlight {
    background: rgba(250, 204, 21, 0.08);
    color: #fde68a;
}

.dark .tb-sell-coords-badge {
    background: rgba(0, 106, 255, 0.1);
    border-color: rgba(0, 106, 255, 0.2);
}

.dark .tb-sell-coords-badge span {
    color: #94a3b8;
}

.dark #pRegion.tb-sell-select {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

/* Responsive: tighter padding on mobile */
@media (max-width: 639px) {
    .tb-combobox-option {
        padding: 0.5rem 0.625rem;
        font-size: 13px;
    }

    .tb-combobox-listbox {
        max-height: 220px;
    }
}
