/* =============================================
   Custom Select — стиль как на shop.master-server.com
   Accent green: #7a9757
   ============================================= */

/* ---------- Wrapper ---------- */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
    user-select: none;
    flex: 1 1 auto;
    width: 100%;
}
.custom-select-wrapper select {
    display: none;
}

/* ---------- Container ---------- */
.custom-select {
    position: relative;
    display: inline-block;
    width: 100%;
    user-select: none;
}

/* ---------- Trigger (закрытый селект) ---------- */
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 48px;
    padding: 0.625rem 0.75rem;
    padding-right: 2rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: inherit;
    font-weight: 500;
    color: #2d3748;
    line-height: 1.4;
    text-align: left;
}

.custom-select-trigger:hover {
    border-color: #7a9757;
    box-shadow: 0 0 0 3px rgba(122, 151, 87, 0.1);
}

/* Когда открыт — зелёная рамка, нижние углы прямые */
.custom-select.opened .custom-select-trigger {
    border-color: #7a9757;
    box-shadow: 0 0 0 3px rgba(122, 151, 87, 0.15);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* ---------- Шеврон (стрелка) ---------- */
.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 0.875rem;
    top: 50%;
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-right: 2px solid #6b7280;
    border-bottom: 2px solid #6b7280;
    transform: translateY(-65%) rotate(45deg);
    transition: all 0.2s ease;
}

.custom-select-trigger:hover::after {
    border-color: #7a9757;
}

.custom-select.opened .custom-select-trigger::after {
    transform: translateY(-30%) rotate(-135deg);
    border-color: #7a9757;
}

/* ---------- Убираем старый треугольник ---------- */
.custom-options::before {
    display: none;
}

/* ---------- Dropdown (список опций) ---------- */
.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 100%;
    background: white;
    border: 1px solid #7a9757;
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* скрыт */
    visibility: hidden;
}

.custom-select.opened .custom-options {
    visibility: visible;
    max-height: 300px;
    opacity: 1;
    overflow-y: auto;
    pointer-events: all;
    transform: translateY(0);
}

/* ---------- Зелёный скроллбар ---------- */
.custom-options::-webkit-scrollbar {
    width: 8px;
}
.custom-options::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 0 0 0.5rem 0;
}
.custom-options::-webkit-scrollbar-thumb {
    background: #7a9757;
    border-radius: 4px;
}
.custom-options::-webkit-scrollbar-thumb:hover {
    background: #6a8747;
}

/* ---------- Опция ---------- */
.custom-option {
    display: block;
    width: 100%;
    text-align: left;
    cursor: pointer;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    color: #2d3748;
    font-size: inherit;
    line-height: 1.4;
    position: relative;
    transition: all 0.15s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.custom-option:first-of-type {
    border-radius: 0;
}
.custom-option:last-of-type {
    border-radius: 0 0 calc(0.5rem - 1px) calc(0.5rem - 1px);
}

.custom-option:hover {
    background: #f9fafb;
    color: #7a9757;
}

/* ---------- Выбранная опция — зелёный фон + галочка ✓ ---------- */
.custom-option.selection {
    background: #f0f7ed;
    color: #7a9757;
    font-weight: 600;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
}

.custom-option.selection::after {
    content: '✓';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #7a9757;
    font-weight: bold;
    font-size: 0.9em;
}

/* Убираем старый круглый индикатор */
.custom-option::before,
.custom-option.selection::before {
    display: none;
}

/* ---------- Анимация появления опций ---------- */
@keyframes customSelectSlideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-select.opened .custom-option {
    animation: customSelectSlideIn 0.2s ease-out backwards;
}
.custom-select.opened .custom-option:nth-child(1) { animation-delay: 0.02s; }
.custom-select.opened .custom-option:nth-child(2) { animation-delay: 0.04s; }
.custom-select.opened .custom-option:nth-child(3) { animation-delay: 0.06s; }
.custom-select.opened .custom-option:nth-child(4) { animation-delay: 0.08s; }
.custom-select.opened .custom-option:nth-child(5) { animation-delay: 0.1s; }
.custom-select.opened .custom-option:nth-child(6) { animation-delay: 0.12s; }
.custom-select.opened .custom-option:nth-child(7) { animation-delay: 0.14s; }
.custom-select.opened .custom-option:nth-child(8) { animation-delay: 0.16s; }

/* ---------- Hover на первом элементе ---------- */
.option-hover::before {
    display: none;
}

/* ---------- Opened шеврон цвет ---------- */
.opened .custom-select-trigger::after {
    border-color: #7a9757;
}

/* ---------- Неактивные поля в карточках — размер = селектам ---------- */
.filter-block .item-card__video-card {
    height: auto !important;
    min-height: 48px !important;
    padding: 0.625rem 0.75rem !important;
    border-radius: 0.5rem !important;
    border: 1px solid #e5e7eb !important;
    background-color: #f5f5f5 !important;
}

/* ---------- Убираем подпись CUDA/TFLOPS под видеокартой ---------- */
.item-card__video-card::before {
    display: none !important;
}

/* ---------- Увеличенный отступ между строками в карточках ---------- */
.filter-block .card__item:not(:last-child) {
    margin-bottom: 0.625rem !important;
}

/* ---------- Сайдбар: dropdown раздвигает контент (аккордеон) ---------- */
.filter-block__sidebar .custom-options,
.filter-selection .custom-options {
    position: relative;
    top: 0;
    box-shadow: none;
    border-radius: 0 0 0.5rem 0.5rem;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.filter-block__sidebar .custom-select.opened .custom-options,
.filter-selection .custom-select.opened .custom-options {
    max-height: 160px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Триггер в сайдбаре: при открытии нижние углы прямые */
.filter-block__sidebar .custom-select.opened .custom-select-trigger,
.filter-selection .custom-select.opened .custom-select-trigger {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

/* ---------- Уменьшаем gap между иконкой и полем ---------- */
.filter-block .item-card {
    gap: 0.375rem !important;
}
.filter-block .item-card__image {
    flex: 0 0 3.5rem !important;
}

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 768px) {
    .custom-select-trigger {
        min-height: 40px;
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }

    .custom-option {
        padding: 0.75rem 2.25rem 0.75rem 0.875rem;
    }

    .custom-select.opened .custom-options {
        max-height: 220px;
    }
}

@media (max-width: 480px) {
    .custom-select-trigger {
        min-height: 38px;
        font-size: 0.85rem;
    }

    .custom-option {
        font-size: 0.85rem;
    }
}
