/**
 * Select Component Styles
 * Переиспользуемые стили для кастомных селектов (dropdowns)
 */

/* Wrapper для кастомного селекта валюты */
.invoice-currency-wrapper {
    position: relative;
    display: block;
    width: 100%;
    height: 38px; /* Фиксированная высота - только селект */
    overflow: visible !important; /* Разрешаем dropdown выходить за пределы */
    z-index: 1; /* Устанавливаем контекст наложения */
}

/* Когда селект открыт, wrapper должен быть выше календаря */
.invoice-currency-wrapper.select-open {
    z-index: 100001 !important; /* Выше календаря (100000) */
}

/* Скрытое поле для значения */
.invoice-currency-wrapper input[type="hidden"] {
    display: none;
}

/* Кастомный селект - отображение выбранного значения */
.invoice-currency-select {
    background: var(--color-bg-input);
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-md);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    transition: all var(--transition-base);
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 2;
    min-height: 38px;
}

.invoice-currency-select:hover {
    background: var(--color-bg-input-hover);
}

.invoice-currency-wrapper.select-open .invoice-currency-select {
    background: var(--color-bg-input);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    opacity: 1;
    pointer-events: auto;
    z-index: 100001; /* Выше календаря */
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.currency-value {
    flex: 1;
    text-align: left;
}

/* Стрелка в селекте */
.currency-arrow {
    width: 12px;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(255,255,255,0.5)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transition: transform var(--transition-slow), opacity var(--transition-base), background-image var(--transition-base);
    opacity: 0.6;
    flex-shrink: 0;
    margin-left: var(--spacing-sm);
}

.invoice-currency-select:hover .currency-arrow {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(255,255,255,1)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    opacity: 1;
}

.invoice-currency-wrapper.select-open .currency-arrow {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(255,255,255,1)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    transform: rotate(180deg);
    opacity: 1;
}

/* Выпадающий список */
.invoice-currency-dropdown {
    position: absolute;
    top: 100%; /* Располагаем dropdown под селектом */
    left: 0;
    right: 0;
    background: var(--color-bg-secondary) !important; /* Непрозрачный фон */
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    transition: max-height var(--transition-slow), opacity var(--transition-base), visibility var(--transition-base);
    z-index: 100001; /* Выше календаря (100000) для отображения поверх всего */
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    pointer-events: none;
    margin-top: 0; /* Убираем отступ между селектом и dropdown */
}

.invoice-currency-wrapper.select-open .invoice-currency-dropdown {
    opacity: 1;
    visibility: visible;
    max-height: 418px; /* Фиксированная высота dropdown */
    pointer-events: auto;
    background: var(--color-bg-secondary) !important; /* Непрозрачный фон при открытии */
}

/* Внутренний контейнер для скролла */
.invoice-currency-dropdown-inner {
    padding: 2px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
    min-height: 0;
    flex: 1;
    /* Скрыть системный скроллбар */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Кастомный скроллбар внутри скругленного контейнера */
.invoice-currency-dropdown-inner::-webkit-scrollbar {
    width: 6px;
}

.invoice-currency-dropdown-inner::-webkit-scrollbar-track {
    background: transparent;
}

.invoice-currency-dropdown-inner::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.invoice-currency-dropdown-inner::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.invoice-currency-wrapper.select-open .invoice-currency-dropdown-inner {
    max-height: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
}

/* Опции в dropdown */
.currency-option {
    background: transparent;
    color: var(--color-text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-md);
    font-family: var(--font-primary);
    min-height: 38px;
    line-height: var(--line-height-md);
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-width: fit-content;
    cursor: pointer;
    transition: background var(--transition-base), border-radius var(--transition-base);
    position: relative;
    border-radius: var(--radius-full);
    border: none;
}

.currency-option:hover {
    background: var(--color-bg-tertiary);
}

.currency-option.selected {
    background: var(--color-bg-tertiary);
    padding-right: var(--spacing-4xl);
}

.currency-option.selected::after {
    content: '✓';
    position: absolute;
    right: var(--spacing-md);
    color: var(--color-text-primary);
    font-weight: var(--font-weight-bold);
}

/* Hover для селекта обрабатывается через wrapper */
.invoice-currency-wrapper:hover select {
    background: rgba(255, 255, 255, 0.06);
}

/* Light theme: Invoice currency select - same as chat input */
body.light-theme .invoice-currency-select {
    background: var(--color-bg-input);
    border: 1px solid transparent;
    color: var(--color-text-inverse);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

body.light-theme .invoice-currency-select:hover {
    background: var(--color-bg-input-hover);
    border-color: var(--color-border-active);
}

body.light-theme .invoice-currency-wrapper.select-open .invoice-currency-select {
    background: var(--color-bg-input-focus);
    border-color: var(--color-border-active);
}

body.light-theme .currency-arrow {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(0,0,0,0.5)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    opacity: 0.6;
}

body.light-theme .invoice-currency-select:hover .currency-arrow {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(0,0,0,1)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    opacity: 1;
}

body.light-theme .invoice-currency-wrapper.select-open .currency-arrow {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(0,0,0,1)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body.light-theme .invoice-currency-dropdown {
    background: var(--color-bg-secondary) !important;
    border: 1px solid var(--color-border-secondary);
    border-top: none;
    box-shadow: var(--shadow-md);
}

body.light-theme .invoice-currency-wrapper.select-open .invoice-currency-dropdown {
    background: var(--color-bg-secondary) !important;
}

body.light-theme .invoice-currency-dropdown-inner {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

body.light-theme .invoice-currency-dropdown-inner::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

body.light-theme .invoice-currency-dropdown-inner::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

body.light-theme .currency-option {
    color: var(--color-text-inverse);
}

body.light-theme .currency-option:hover {
    background: var(--color-bg-primary);
}

body.light-theme .currency-option.selected {
    background: var(--color-bg-input);
}

body.light-theme .currency-option.selected::after {
    color: var(--color-text-inverse);
}

