/* Header & Search Styles */
.glass-header {
    background: rgba(5, 5, 5, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.3s ease;
}

.filter-btn-icon {
    color: var(--primary);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.filter-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.filter-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 0 4px;
    height: 16px;
    min-width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 2px solid #000;
    /* Matches header bg for cutout look */
    box-sizing: content-box;
}

.search-input-modern {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 36px 10px 40px;
    font-size: 15px;
    color: var(--text);
    transition: all 0.2s ease;
    font-family: var(--font-body);
}

.search-input-modern:focus {
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    border-color: rgba(59, 130, 246, 0.5);
}

.search-input-modern::placeholder {
    color: var(--muted);
}

.search-icon-modern {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.clear-search-modern {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    z-index: 2;
}

.clear-search-modern:hover {
    color: var(--text);
}

.clear-search-modern.visible {
    display: flex;
}

/* Category Pills */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-pill {
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.category-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.category-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.filter-content-wrapper.expanded {
    max-height: 500px;
    opacity: 1;
}

.filter-info {
    padding: 0 16px 12px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin-top: -8px;
}

.filter-info strong {
    color: var(--text);
    font-weight: 600;
}

.filter-subtitle {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.commission-range {
    width: 100%;
    accent-color: var(--primary);
}

.clear-all-filters {
    margin-left: 8px;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.clear-all-filters:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Brand List & Cards */
#brand-list-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Always 2 columns */
    gap: 12px;
    /* Tighter gap */
    padding-bottom: 80px;
}

@media (min-width: 768px) {
    #brand-list-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    #brand-list-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

.brand-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    /* Slightly smaller radius */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease;
    cursor: pointer;
    opacity: 0;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    position: relative;
}

.brand-card:hover {
    transform: translateY(-2px);
}

.brand-card:active {
    transform: translateY(0);
}

.media {
    position: relative;
    width: 100%;
    padding-top: 50%;
    /* 2:1 Aspect Ratio - Sleek & Horizontal */
    background: #1a1a1a;
    /* Solid dark background instead of gradient to reduce visual noise */
    overflow: hidden;
}

.media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    /* Force cover to eliminate empty space */
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.media img.loaded {
    opacity: 1;
}

.top-right-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #7c3aed;
    color: white;
    font-weight: 700;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
    z-index: 2;
    border: none;
}

.card-content {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Consistent gap between elements */
    min-height: auto;
    flex: 1;
    justify-content: flex-start;
    /* Don't spread vertically */
}

/* ... existing styles ... */

.brand-name {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 19px;
    /* Reserve space for one line */
}

.brand-category {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 15px;
    /* Reserve space */
}

.badge-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 2px 0 0;
    /* Tighten up */
    min-height: 16px;
    /* Reserve space */
}

.badge {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 2px 0;
    font-size: 6.8px;
    line-height: 1.1;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge.badge-lg {
    font-size: 8.5px;
    /* Slight increase, not too big */
    font-weight: 600;
    padding: 3px 0;
    letter-spacing: normal;
}

.badge.badge-commission {
    flex: 1.25 1 0;
    /* Reduced from 1.5 to give Free Samples more room */
}

.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
}

/* Fix stat alignment - left align instead of center to remove "gap" at start */
.stat-item {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    background: #27272a;
    padding: 3px 8px;
    /* More padding on sides */
    border-radius: 4px;
    white-space: nowrap;
    justify-content: flex-start;
    /* Left align content */
    text-align: left;
}

.join-button {
    display: block;
    background: linear-gradient(135deg, var(--primary) 0%, #1757c7 100%);
    color: #ffffff;
    text-align: center;
    padding: 8px 12px;
    /* Smaller button */
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    margin-top: auto;
    /* Push to bottom */
}

.join-button:hover {
    box-shadow: 0 4px 16px rgba(31, 111, 235, 0.3);
    transform: translateY(-1px);
}

.join-button:active {
    transform: translateY(0);
}

.list-chevron {
    display: none;
    /* Hidden in grid view */
    padding-right: 14px;
    color: var(--muted);
    opacity: 0.6;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    line-height: 1.5;
}

.content-vis {
    content-visibility: auto;
    contain-intrinsic-size: 256px 200px;
}

/* --- LIST VIEW STYLES --- */
#brand-list-container.list-view {
    grid-template-columns: 100% !important;
    gap: 10px;
}

#brand-list-container.list-view .brand-card {
    flex-direction: row;
    align-items: stretch;
    /* Enforce full height stretch */
    padding: 0;
    height: auto;
    /* Allow growth for content */
    min-height: 115px;
    /* Slightly taller minimum */
    content-visibility: visible;
    contain-intrinsic-size: auto;
}

#brand-list-container.list-view .media {
    width: 170px;
    /* Wider aspect ratio (~1.55) to show more image content */
    height: 100%;
    /* Full height */
    padding-top: 0;
    flex: 0 0 170px;
    border-radius: 0;
    margin-right: 0;
    background: #1a1a1a;
}

#brand-list-container.list-view .media img {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: cover !important;
    /* Fill properly */
    padding: 0;
}

/* Badge styling in list view - clean tag on image */
#brand-list-container.list-view .top-right-badge {
    display: block;
    top: auto;
    bottom: 6px;
    left: 6px;
    right: auto;
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(124, 58, 237, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transform: none;
    /* Reset any scaling */
}

#brand-list-container.list-view .card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center vertically */
    padding: 6px 12px;
    /* Compact padding */
    flex: 1;
    min-width: 0;
    gap: 3px;
    /* Tight gap */
    border-right: 1px solid rgba(255, 255, 255, 0.03);
    /* subtle divider before chevron */
}

#brand-list-container.list-view .brand-name {
    font-size: 15px;
    /* Slightly smaller to fit 2 lines of stats if needed */
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#brand-list-container.list-view .brand-category {
    margin-bottom: 1px;
    font-size: 12px;
}

#brand-list-container.list-view .stats-row {
    margin-bottom: 0;
    gap: 6px;
}

#brand-list-container.list-view .stat-item {
    background: rgba(255, 255, 255, 0.05);
    /* Slightly lighter background */
}

#brand-list-container.list-view .badge-row {
    display: flex;
    flex-wrap: nowrap;
    /* Force side-by-side */
    gap: 2px;
    margin: 2px 0 0;
    min-height: 0;
}

#brand-list-container.list-view .badge {
    display: none;
}

#brand-list-container.list-view .badge.badge-free-samples,
#brand-list-container.list-view .badge.badge-commission {
    display: inline-flex;
    flex: 0 1 auto;
    width: auto;
    font-size: 7px;
    /* Smallest readable size */
    padding: 2px 4px;
    line-height: 1.1;
    margin: 0;
    letter-spacing: -0.02em;
    text-overflow: clip;
}

#brand-list-container.list-view .join-button {
    display: none;
}

/* Show chevron in list view */
#brand-list-container.list-view .list-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    color: var(--muted);
    opacity: 0.5;
    width: 50px;
    /* Fixed width click area */
}

/* Mobile Adjustment for really small screens */
@media (max-width: 380px) {
    #brand-list-container.list-view .media {
        width: 125px;
        /* Slightly smaller on very small screens */
        flex: 0 0 125px;
    }

    #brand-list-container.list-view .brand-name {
        font-size: 15px;
    }
}

/* Go to Top Button */
.go-to-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.go-to-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.go-to-top-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.go-to-top-btn:active {
    transform: translateY(0);
}