/**
 * HamamSpaAdvisor — Premium Custom Select (portal-only menu)
 */

:root {
    --cs-height: 52px;
    --cs-height-sm: 40px;
    --cs-radius: 14px;
    --cs-border: #E5E7EB;
    --cs-border-focus: #C9A84C;
    --cs-navy: #101B33;
    --cs-navy-soft: #F4F7FB;
    --cs-gold-soft: #FBF6EA;
    --cs-text: #101B33;
    --cs-muted: #6B7280;
    --cs-shadow: 0 20px 25px -5px rgba(16, 27, 51, 0.14), 0 8px 10px -6px rgba(16, 27, 51, 0.1);
    --cs-z: 2147483647;
    --cs-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23101B33' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ===== Native select fallback (JS kapalı / henüz dönüşmemiş) ===== */
select.form-control:not(.custom-select-native),
select.form-select:not(.custom-select-native),
.search-select,
.home-search-input select,
.search-field select,
.search-field-ultra select,
.rezai-input-row select,
.sort-form select,
.admin-card select:not(.custom-select-native),
.business-card-panel select:not(.custom-select-native) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-height: var(--cs-height);
    height: auto;
    padding: 0 44px 0 16px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    background-color: #fff;
    background-image: var(--cs-chevron);
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--cs-text);
    box-shadow: 0 1px 2px rgba(16, 27, 51, 0.04);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select.form-control:not(.custom-select-native):focus,
select.form-select:not(.custom-select-native):focus,
.search-select:focus,
.home-search-input select:focus {
    outline: none;
    border-color: var(--cs-border-focus);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18);
}

select.form-control:not(.custom-select-native):disabled,
select.form-select:not(.custom-select-native):disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background-color: #F9FAFB;
}

select.form-select-sm:not(.custom-select-native),
select.form-control.form-select-sm:not(.custom-select-native) {
    min-height: var(--cs-height-sm);
    padding: 0 36px 0 12px;
    font-size: 0.8125rem;
    border-radius: 10px;
}

/* ===== Custom select trigger (wrapper içinde SADECE trigger) ===== */
.custom-select {
    position: relative;
    width: 100%;
    font-size: 0.9375rem;
}

/* Wrapper içindeki eski menü kalıntıları — asla görünmesin */
.custom-select .custom-select-menu,
.custom-select .custom-select-dropdown {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.custom-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: var(--cs-height);
    padding: 0 16px;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    background: #fff;
    color: var(--cs-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 27, 51, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.custom-select-trigger:hover:not(:disabled) {
    border-color: #D1D5DB;
    background: #FAFBFC;
}

.custom-select.is-open .custom-select-trigger,
.custom-select-trigger:focus-visible {
    outline: none;
    border-color: var(--cs-border-focus);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18);
}

.custom-select-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--cs-text);
}

.custom-select-value.is-placeholder {
    color: var(--cs-muted);
}

.custom-select-chevron {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    background: var(--cs-chevron) center / contain no-repeat;
    transition: transform 0.2s;
}

.custom-select.is-open .custom-select-chevron {
    transform: rotate(180deg);
}

/* ===== Body portal — tek gerçek menü katmanı ===== */
#custom-select-portal {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--cs-z);
}

#custom-select-portal .custom-select-menu {
    pointer-events: auto;
    position: fixed !important;
    z-index: var(--cs-z) !important;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    display: block !important;
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow);
    padding: 6px;
    transform-origin: top center;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    animation: cs-menu-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#custom-select-portal .custom-select-menu.is-flip-up {
    transform-origin: bottom center;
    animation-name: cs-menu-in-up;
}

@keyframes cs-menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cs-menu-in-up {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#custom-select-portal .custom-select-menu::-webkit-scrollbar {
    width: 6px;
}

#custom-select-portal .custom-select-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px 0;
}

#custom-select-portal .custom-select-menu::-webkit-scrollbar-thumb {
    background: rgba(16, 27, 51, 0.18);
    border-radius: 999px;
}

#custom-select-portal .custom-select-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 27, 51, 0.32);
}

#custom-select-portal .custom-select-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(16, 27, 51, 0.22) transparent;
}

.custom-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--cs-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.custom-select-option:hover,
.custom-select-option.is-focused {
    background: var(--cs-navy-soft);
}

.custom-select-option.is-selected {
    background: var(--cs-gold-soft);
    color: var(--cs-navy);
    font-weight: 600;
}

.custom-select-option.is-selected::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #C9A84C;
    flex-shrink: 0;
    margin-left: 8px;
}

.custom-select-option.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.custom-select.is-disabled .custom-select-trigger {
    opacity: 0.65;
    cursor: not-allowed;
    background: #F9FAFB;
}

.custom-select.is-sm .custom-select-trigger {
    min-height: var(--cs-height-sm);
    font-size: 0.8125rem;
    border-radius: 10px;
}

.custom-select.is-sm .custom-select-option {
    padding: 8px 12px;
    font-size: 0.8125rem;
}

.rezai-input-row .custom-select {
    flex: 1;
}

.rezai-input-row .custom-select-trigger {
    min-height: 44px;
    font-size: 0.875rem;
}

.business-table .custom-select,
.admin-table .custom-select {
    min-width: 120px;
}

html[dir="rtl"] .custom-select-trigger {
    text-align: right;
}

html[dir="rtl"] .custom-select-chevron {
    transform: scaleX(-1);
}

html[dir="rtl"] .custom-select.is-open .custom-select-chevron {
    transform: scaleX(-1) rotate(180deg);
}

.home-search-input .custom-select {
    flex: 1;
    min-width: 0;
    position: relative;
}

.home-search-input .custom-select-trigger {
    min-height: auto;
    height: auto;
    padding: 0 24px 0 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-weight: 500;
}

.home-search-input .custom-select-trigger:hover:not(:disabled),
.home-search-input .custom-select.is-open .custom-select-trigger,
.home-search-input .custom-select-trigger:focus-visible {
    border: none;
    background: transparent;
    box-shadow: none;
}

.home-search-input .custom-select-chevron {
    position: absolute;
    right: 0;
    opacity: 0.55;
}

.sort-form .custom-select-trigger {
    min-height: 36px;
    font-size: 0.875rem;
    border-radius: 10px;
}

@media (max-width: 767px) {
    .custom-select-trigger {
        min-height: 48px;
    }
}
