/**
 * Сучасна стилізація селектів 2025
 * Liquid Glass стиль з плавними анімаціями
 */

/* Обгортка для кастомного селекту */
.select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Базовий стиль селекту */
#input-sort,
#input-limit,
select.form-control {
    /* Розміри та відступи */
    width: 100% !important;
    padding: 12px 40px 12px 16px !important;
    min-height: 48px !important;
    
    /* Шрифт */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    color: var(--text-primary, #1a1a1a) !important;
    
    /* Фон та межі */
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(249, 250, 251, 0.95) 100%
    ) !important;
    border: 2px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 12px !important;
    
    /* Liquid Glass ефект */
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
    
    /* Анімації */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    
    /* Прибираємо стандартну стрілку */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    cursor: pointer !important;
}

/* Кастомна стрілка */
#input-sort::after,
#input-limit::after,
.select-wrapper::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--text-primary, #1a1a1a);
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

/* Hover стан */
#input-sort:hover,
#input-limit:hover,
select.form-control:hover {
    border-color: rgba(59, 130, 246, 0.4) !important;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 1) 0%, 
        rgba(249, 250, 251, 1) 100%
    ) !important;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.06),
        0 8px 16px rgba(59, 130, 246, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
    transform: translateY(-1px) !important;
}

/* Focus стан */
#input-sort:focus,
#input-limit:focus,
select.form-control:focus {
    outline: none !important;
    border-color: rgba(59, 130, 246, 0.6) !important;
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.1),
        0 4px 12px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}

/* Active стан (при кліку) */
#input-sort:active,
#input-limit:active,
select.form-control:active {
    transform: translateY(0) !important;
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 2px 8px rgba(59, 130, 246, 0.1),
        inset 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

/* Стилізація option елементів */
#input-sort option,
#input-limit option,
select.form-control option {
    padding: 12px 16px !important;
    background: #ffffff !important;
    color: var(--text-primary, #1a1a1a) !important;
    font-weight: 500 !important;
}

/* Вибраний option */
#input-sort option:checked,
#input-limit option:checked,
select.form-control option:checked {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.15) 0%, 
        rgba(59, 130, 246, 0.05) 100%
    ) !important;
    color: #3b82f6 !important;
    font-weight: 600 !important;
}

/* Hover на option (Firefox підтримує) */
#input-sort option:hover,
#input-limit option:hover,
select.form-control option:hover {
    background: rgba(59, 130, 246, 0.08) !important;
}

/* Disabled стан */
#input-sort:disabled,
#input-limit:disabled,
select.form-control:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: rgba(249, 250, 251, 0.5) !important;
}

/* Label для селекту */
.input-group-addon,
label[for="input-sort"],
label[for="input-limit"] {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 8px;
    display: block;
    letter-spacing: 0.025em;
}

/* Input group стилізація */
.input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.input-group .input-group-addon {
    flex-shrink: 0;
    margin-bottom: 0;
    white-space: nowrap;
}

.input-group #input-sort,
.input-group #input-limit {
    flex: 1;
    margin-bottom: 0;
}

/* Адаптивність для мобільних */
@media (max-width: 768px) {
    #input-sort,
    #input-limit,
    select.form-control {
        padding: 10px 36px 10px 14px !important;
        min-height: 44px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
    }
    
    .select-wrapper::after {
        right: 14px !important;
        border-left: 5px solid transparent !important;
        border-right: 5px solid transparent !important;
        border-top: 5px solid var(--text-primary, #1a1a1a) !important;
    }
    
    .input-group {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    
    .input-group .input-group-addon {
        margin-bottom: 4px !important;
    }
}

/* Анімація при завантаженні */
@keyframes selectFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#input-sort,
#input-limit,
select.form-control {
    animation: selectFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Dark mode підтримка */
@media (prefers-color-scheme: dark) {
    #input-sort,
    #input-limit,
    select.form-control {
        color: rgba(255, 255, 255, 0.95) !important;
        background: linear-gradient(135deg, 
            rgba(30, 30, 30, 0.95) 0%, 
            rgba(20, 20, 20, 0.95) 100%
        ) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
        box-shadow: 
            0 1px 2px rgba(0, 0, 0, 0.3),
            0 4px 12px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
    }
    
    #input-sort option,
    #input-limit option,
    select.form-control option {
        background: #1a1a1a !important;
        color: rgba(255, 255, 255, 0.95) !important;
    }
    
    #input-sort:hover,
    #input-limit:hover,
    select.form-control:hover {
        border-color: rgba(59, 130, 246, 0.5) !important;
        background: linear-gradient(135deg, 
            rgba(35, 35, 35, 1) 0%, 
            rgba(25, 25, 25, 1) 100%
        ) !important;
    }
    
    .select-wrapper::after {
        border-top-color: rgba(255, 255, 255, 0.7) !important;
    }
}

/* Покращена доступність */
#input-sort:focus-visible,
#input-limit:focus-visible,
select.form-control:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.5) !important;
    outline-offset: 2px !important;
}

/* Smooth scrolling для dropdown */
select {
    scroll-behavior: smooth;
}

/* Стилізація для Firefox */
@-moz-document url-prefix() {
    #input-sort,
    #input-limit,
    select.form-control {
        padding-right: 40px;
    }
}

/* Стилізація placeholder (якщо використовується) */
#input-sort::placeholder,
#input-limit::placeholder,
select.form-control::placeholder {
    color: rgba(107, 114, 128, 0.6);
    font-weight: 400;
}

/* Hover ефект на стрілку */
#input-sort:hover ~ .select-wrapper::after,
#input-limit:hover ~ .select-wrapper::after {
    opacity: 1;
    border-top-color: #3b82f6;
}

/* Focus ефект на стрілку */
#input-sort:focus ~ .select-wrapper::after,
#input-limit:focus ~ .select-wrapper::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Gradient hover effect */
#input-sort::before,
#input-limit::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0) 0%, 
        rgba(59, 130, 246, 0.3) 100%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#input-sort:hover::before,
#input-limit:hover::before {
    opacity: 1;
}
