/* inked/assets/css/shared/custom-select.css */
/**
 * Shared CustomSelect Component
 * Searchable dark dropdown with gold accent.
 * Extracted from masters-v2/listing.css ().
 *
 * Works with any wrapper class that has data-custom-select attribute,
 * plus backward-compatible with specific subsystem wrapper classes.
 */

/* ======================================================
   HIDE NATIVE SELECT WHEN CUSTOM IS ACTIVE
   ====================================================== */

[data-custom-select].has-custom-select select,
.filter-dropdown.has-custom-select select,
.masters-filter-dropdown.has-custom-select select,
.studios-filter-dropdown.has-custom-select select,
.afisha-filter-dropdown.has-custom-select select,
.rankings-filter-dropdown.has-custom-select select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Hide the native caret arrow when custom select is active */
[data-custom-select].has-custom-select::after,
.filter-dropdown.has-custom-select::after,
.masters-filter-dropdown.has-custom-select::after,
.studios-filter-dropdown.has-custom-select::after,
.afisha-filter-dropdown.has-custom-select::after,
.rankings-filter-dropdown.has-custom-select::after {
    display: none;
}

/* ======================================================
   TRIGGER BUTTON
   ====================================================== */

.custom-select-trigger {
    appearance: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border, #333);
    border-radius: var(--radius-md, 8px);
    padding: 10px 36px 10px 14px;
    min-height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text, #f5f5f5);
    cursor: pointer;
    transition: border-color var(--transition-fast, 150ms);
    font-family: inherit;
    white-space: nowrap;
    position: relative;
    user-select: none;
    line-height: 1.3;
}

.light-theme .custom-select-trigger {
    background: rgba(0, 0, 0, 0.03);
    color: var(--color-text);
}

.custom-select-trigger:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.light-theme .custom-select-trigger:hover {
    border-color: rgba(0, 0, 0, 0.2);
}

.custom-select-trigger.is-open {
    border-color: var(--color-brand-accent, #E8C547);
}

/* Trigger caret */
.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--color-text-muted, #666);
    transition: transform var(--transition-fast, 150ms);
}

.custom-select-trigger.is-open::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Placeholder state (no value selected) */
.custom-select-trigger.is-placeholder {
    color: var(--color-text-muted, #666);
}

/* ======================================================
   DROPDOWN PANEL
   ====================================================== */

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-width: 320px;
    background: rgba(26, 26, 27, 0.97);
    backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid var(--color-border, #333);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 100;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 150ms ease, transform 150ms ease;
}

.custom-select-dropdown.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.light-theme .custom-select-dropdown {
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ======================================================
   SEARCH INPUT
   ====================================================== */

.custom-select-search {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid var(--color-border, #333);
    background: transparent;
    color: var(--color-text, #f5f5f5);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.custom-select-search::placeholder {
    color: var(--color-text-muted, #666);
}

.light-theme .custom-select-search {
    color: var(--color-text);
}

.light-theme .custom-select-search::placeholder {
    color: var(--color-text-muted);
}

/* ======================================================
   OPTIONS LIST
   ====================================================== */

.custom-select-options {
    max-height: 260px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border, #333) transparent;
}

.custom-select-options::-webkit-scrollbar {
    width: 4px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: var(--color-border, #333);
    border-radius: 2px;
}

/* ======================================================
   OPTION ITEM
   ====================================================== */

.custom-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    min-height: 44px;
    box-sizing: border-box;
    font-size: 13px;
    color: var(--color-text, #f5f5f5);
    cursor: pointer;
    transition: background var(--transition-fast, 150ms);
    user-select: none;
}

.custom-select-option:hover,
.custom-select-option.is-focused {
    background: rgba(255, 255, 255, 0.06);
}

.light-theme .custom-select-option:hover,
.light-theme .custom-select-option.is-focused {
    background: rgba(0, 0, 0, 0.04);
}

.light-theme .custom-select-option {
    color: var(--color-text);
}

.custom-select-option.is-selected {
    color: var(--color-brand-accent, #E8C547);
    font-weight: 600;
}

/* Selected indicator (dot) */
.custom-select-option.is-selected::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-brand-accent, #E8C547);
    flex-shrink: 0;
}

.custom-select-option:not(.is-selected)::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    flex-shrink: 0;
}

/* Hidden option (filtered out by search) */
.custom-select-option.is-hidden {
    display: none;
}

/* ======================================================
   NO RESULTS MESSAGE
   ====================================================== */

.custom-select-no-results {
    padding: 16px 14px;
    font-size: 13px;
    color: var(--color-text-muted, #666);
    text-align: center;
    display: none;
}

.custom-select-no-results.is-visible {
    display: block;
}

/* ======================================================
   RESPONSIVE — MOBILE
   ====================================================== */

@media (max-width: 768px) {
    /* Full-width bottom sheet on mobile */
    .custom-select-dropdown {
        max-width: none;
        left: -16px;
        right: -16px;
        width: calc(100vw - 32px);
        position: fixed;
        top: auto;
        bottom: 0;
        border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
        max-height: 60vh;
    }

    .custom-select-dropdown.is-visible {
        transform: translateY(0);
    }

    .custom-select-options {
        max-height: calc(60vh - 50px);
    }
}

@media (max-width: 480px) {
    .custom-select-trigger {
        width: 100%;
    }
}
