/* ============================================================
   MOOD PROVIDERS — фильтр по провайдерам: модалка, список, чипы.
   Раньше эти стили жили в mood-theme.css и casino-surface-polish.css,
   которые не подключены в index.html, — фильтр открывался без вёрстки.
   ============================================================ */

/* — Кнопка тулбара с активным фильтром — */
.games-provider-btn--active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}
.games-provider-btn-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--btn-primary-text);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

/* — Чипы выбранных провайдеров — */
.provider-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 200px;
    padding: 4px 6px 4px 8px;
    border-radius: var(--radius-pill);
    background: var(--accent-dim);
    border: 1px solid var(--accent-muted);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.provider-filter-tag:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}
.provider-filter-tag-logo,
.provider-filter-tag-logo-ph {
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    object-fit: contain;
    background: var(--surface-2);
}
.provider-filter-tag-logo--broken { display: none; }
.provider-filter-tag-logo-ph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 800;
}
.provider-filter-tag-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.provider-filter-tag-remove {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
}
.provider-filter-tag:hover .provider-filter-tag-remove {
    background: var(--danger-dim);
    color: var(--danger);
}

/* ============================================================
   Модалка фильтра — Provider Picker v2
   ============================================================ */
.provider-popup {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}
.provider-popup.hidden { display: none !important; }

.provider-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 13, 0.66);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: mood-provider-fade var(--dur-2) var(--ease-out);
}

.provider-popup-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(640px, 100%);
    max-height: min(82vh, 720px);
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: mood-provider-in var(--dur-3) var(--ease-out);
}

.provider-popup-handle {
    display: none;
    flex: none;
    width: 36px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
}

@keyframes mood-provider-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes mood-provider-in {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.provider-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5) var(--space-3);
}
.provider-popup-head__text { min-width: 0; }
.provider-popup-head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}
.provider-popup-subtitle {
    margin: 4px 0 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dim);
    line-height: 1.35;
}
.provider-popup-subtitle--active { color: var(--accent); }

.provider-popup-close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.provider-popup-close:hover { background: var(--surface-3); color: var(--text); }

/* Toolbar: search + quick actions */
.provider-popup-toolbar {
    flex: none;
    padding: 0 var(--space-5) var(--space-3);
}
.provider-popup-search-wrap {
    position: relative;
}
.provider-popup-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    color: var(--text-dim);
    pointer-events: none;
}
input.provider-popup-search {
    width: 100%;
    padding: 11px 16px 11px 42px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
input.provider-popup-search::placeholder { color: var(--text-dim); }
input.provider-popup-search:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(68, 235, 213, 0.12);
}

.provider-popup-quick {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
}
.provider-popup-quick.hidden { display: none; }
.provider-popup-quick-btn {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.provider-popup-quick-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
}

/* — Прокручиваемый список — */
.provider-list {
    flex: 1;
    min-height: min(320px, 46vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 var(--space-5) var(--space-4);
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}
.provider-list::-webkit-scrollbar { width: 8px; }
.provider-list::-webkit-scrollbar-thumb {
    border-radius: var(--radius-pill);
    background: var(--surface-3);
}

.provider-group + .provider-group {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}
.provider-group__letter {
    display: inline-block;
    width: auto;
    max-width: max-content;
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 0 6px;
    padding: 0 2px;
    background: var(--bg-elevated);
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
    line-height: 1;
}
.provider-group__items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

/* — Logo-only tile: компактная pill-капсула — */
.provider-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    height: 54px;
    min-height: 54px;
    max-height: 54px;
    padding: 0 10px 0 12px;
    margin: 0;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}
.provider-item.selected {
    padding-left: 28px;
}
.provider-item:hover {
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
}
.provider-item:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.provider-item.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 0 1px rgba(68, 235, 213, 0.18);
}

.provider-item-check {
    position: absolute;
    top: 50%;
    left: 7px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: var(--btn-primary-text);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity var(--transition), transform var(--transition);
}
.provider-item.selected .provider-item-check {
    opacity: 1;
    transform: scale(1);
}
.provider-item-check svg { width: 10px; height: 10px; }

.provider-item-count {
    position: relative;
    top: auto;
    right: auto;
    z-index: 1;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 22px;
    margin: 0;
    padding: 0 2px;
    border-radius: 0;
    background: transparent;
    border: none;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-dim);
    letter-spacing: 0;
    pointer-events: none;
}
.provider-item.selected .provider-item-count {
    color: var(--text-muted);
}

.provider-item-logo-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 100%;
    min-width: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
}
.provider-item.selected .provider-item-logo-wrap {
    padding-left: 0;
}
.provider-item-logo {
    display: block;
    max-width: 100%;
    max-height: 38px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.provider-item-logo--broken { display: none; }
.provider-item-logo-ph {
    width: 40%;
    height: 22px;
    min-height: 22px;
    border-radius: var(--radius-pill);
    border: 1px dashed var(--border-strong);
    background: transparent;
}
.provider-item-fallback {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.provider-item--no-logo .provider-item-logo-wrap {
    flex-direction: column;
    gap: 4px;
}

.provider-item-body,
.provider-item-name,
.provider-item-meta { display: none !important; }

/* — Состояния списка — */
.provider-list-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-7) var(--space-4);
    text-align: center;
}
.provider-list-state__title {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text);
}
.provider-list-state__text {
    max-width: 40ch;
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text-muted);
}
.provider-list-state--error .provider-list-state__title { color: var(--danger); }
.provider-list-state__retry { margin-top: var(--space-1); }

.provider-list-skeleton {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding-top: var(--space-3);
}
.provider-item-skel {
    height: 46px;
    min-height: 46px;
    border-radius: var(--radius-pill);
    background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
    background-size: 220% 100%;
    animation: mood-provider-shimmer 1.25s linear infinite;
}
@keyframes mood-provider-shimmer {
    from { background-position: 130% 0; }
    to { background-position: -30% 0; }
}

/* Список провайдеров в drawer фильтров — те же плитки */
.mood-filters-provider-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding-top: 12px;
    max-height: 360px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Desktop: центрированная модалка, сетка 3 колонки
   ============================================================ */
@media (min-width: 701px) {
    .provider-popup {
        align-items: center;
        justify-content: center;
        padding: var(--space-5);
    }
    .provider-popup-panel {
        width: min(580px, calc(100vw - 40px));
        max-height: min(84vh, 760px);
        border-radius: var(--radius-xl);
    }
    .provider-group__items,
    .provider-list-skeleton {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }
    .mood-filters-provider-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ============================================================
   Адаптив: на телефоне модалка становится нижним листом
   ============================================================ */
@media (max-width: 700px) {
    .provider-popup {
        padding: 0;
        align-items: flex-end;
    }
    .provider-popup-panel {
        width: 100%;
        max-height: min(92dvh, 92vh);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        border-bottom: none;
        animation: mood-provider-sheet-in var(--dur-3) var(--ease-out);
    }
    .provider-popup-handle { display: block; }
    @keyframes mood-provider-sheet-in {
        from { transform: translateY(14%); opacity: 0; }
        to { transform: none; opacity: 1; }
    }
    .provider-popup-head { padding: var(--space-3) var(--space-4) var(--space-2); }
    .provider-popup-toolbar {
        position: sticky;
        top: 0;
        z-index: 3;
        padding: 0 var(--space-4) var(--space-3);
        background: var(--bg-elevated);
    }
    .provider-list {
        padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    }
    .provider-item {
        height: 44px;
        min-height: 44px;
        max-height: 44px;
    }
    .provider-item-logo {
        max-height: 26px;
    }
    .provider-filter-tag { max-width: 150px; }
}

/* ============================================================
   Светлая тема
   ============================================================ */
html[data-theme="light"] .provider-popup-backdrop {
    background: rgba(16, 24, 40, 0.4);
}
html[data-theme="light"] .provider-item {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .provider-item:hover {
    background: #f8f9fc;
    border-color: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .provider-item.selected {
    border-color: var(--accent-deep);
    background: rgba(254, 215, 165, 0.18);
    box-shadow: 0 0 0 1px rgba(201, 165, 116, 0.28);
}
html[data-theme="light"] .provider-item-count {
    color: var(--text-dim);
}
html[data-theme="light"] .provider-item.selected .provider-item-count {
    color: var(--text-muted);
}
html[data-theme="light"] .provider-group__letter {
    background: var(--bg-elevated);
}
