/* ============================================
   AnimesHUB - Browse / Search Page Styles
   JustAnime-inspired design
   ============================================ */

.browse-page { background: var(--background); }

.browser-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 20px;
    letter-spacing: 1px;
}

/* ============================================
   FILTERS
   ============================================ */
.filters-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 28px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.search-box {
    position: relative;
    width: 100%;
}
.search-box input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--foreground);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 10px 14px 10px 40px;
    outline: none;
    transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--border-hover); }
.search-box input::placeholder { color: var(--text-muted); }
.search-box .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* Dropdown Group */
.dropdown-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dropdown {
    position: relative;
    flex: 1;
    min-width: 140px;
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    cursor: pointer;
    transition: border-color 0.2s;
    gap: 6px;
}
.dropdown-header:hover { border-color: var(--border-hover); }
.dropdown-header span {
    font-size: 12px;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dropdown-header .icon {
    color: var(--muted);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.dropdown.open .dropdown-header .icon { transform: rotate(180deg); }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.dropdown-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--foreground);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* Filter button */
.browse-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--foreground);
    color: var(--background);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
    align-self: flex-start;
}
.browse-filter-btn:hover { opacity: 0.9; }
.browse-filter-btn .icon { width: 16px; height: 16px; }

/* ============================================
   RESULTS GRID
   ============================================ */
.browse-page .anime-grid {
    margin-bottom: 28px;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.pagination .page-btn,
.pagination button,
.pagination a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--muted-foreground);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.pagination .page-btn:hover,
.pagination button:hover,
.pagination a:hover {
    border-color: var(--border-hover);
    color: var(--foreground);
}
.pagination .page-btn.active,
.pagination button.active,
.pagination a.active {
    background: var(--foreground);
    color: var(--background);
    border-color: var(--foreground);
    font-weight: 700;
}
.pagination .page-btn:disabled,
.pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* ── Mobile toggle button (hidden on desktop) ── */
.filters-top-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.filters-top-row .search-box { flex: 1; }

.filters-mob-toggle {
    display: none; /* shown only on ≤768px */
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
    flex-shrink: 0;
}
.filters-mob-toggle:hover { border-color: var(--border-hover); color: var(--foreground); }
.filters-mob-toggle .icon { width: 15px; height: 15px; }
.filters-mob-toggle .toggle-chevron {
    width: 14px; height: 14px;
    transition: transform 0.22s;
    color: var(--muted);
}
.filters-section.expanded .filters-mob-toggle .toggle-chevron { transform: rotate(180deg); }
.filters-mob-toggle .filter-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Filter body ── */
.filter-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

@media (max-width: 992px) {
    .browser-container { padding: 16px; }
    .dropdown-group { gap: 6px; }
    .dropdown { min-width: 120px; }
}

@media (max-width: 768px) {
    .filters-mob-toggle { display: flex; }

    /* Collapse filter body on mobile by default */
    .filter-body {
        display: none;
        padding-top: 10px;
        border-top: 1px solid var(--border);
        margin-top: 4px;
    }
    .filters-section.expanded .filter-body { display: flex; }

    /* 2-column grid for dropdowns */
    .dropdown-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .dropdown { min-width: unset; }

    /* Dropdown menu: open above or below as needed, full zindex */
    .dropdown-menu { z-index: 100; min-width: 160px; right: auto; }

    /* Filter button full width */
    .browse-filter-btn { width: 100%; justify-content: center; padding: 11px 24px; }
}

@media (max-width: 590px) {
    .browser-container { padding: 14px 10px; }
    .page-title { font-size: 19px; margin-bottom: 16px; }
    .filters-section { padding: 12px; }
    .dropdown-group { gap: 6px; }
    .dropdown-header span { font-size: 12px; }
}

@media (max-width: 480px) {
    .browser-container { padding: 8px 6px; }
    .page-title { font-size: 16px; margin-bottom: 12px; }
    .filters-section { padding: 10px; }
    .dropdown-group { grid-template-columns: 1fr 1fr; gap: 4px; }
    .dropdown-header span { font-size: 11px; }
    .browse-filter-btn { padding: 9px 16px; font-size: 12px; }
}

@media (max-width: 360px) {
    .browser-container { padding: 6px 4px; }
    .page-title { font-size: 14px; }
    .filters-section { padding: 8px; }
    .dropdown-group { grid-template-columns: 1fr; gap: 4px; }
    .dropdown-header span { font-size: 10px; }
}
