/* =============================================================================
   UNIVERSAL CONTROLS - Consistent across all pages
   ============================================================================= */

/* Controls Bar */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Search */
.search-box {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
}

.search-box input::placeholder {
    color: var(--text-light);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-box::before {
    content: "⌕";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 14px;
}

/* Filter Dropdowns */
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    color: var(--text-light);
    white-space: nowrap;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    min-width: 120px;
}

.filter-select option {
    background: var(--surface);
    color: var(--text);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Filter Pills/Tags */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-pill {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    background: var(--bg);
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.15s;
}

.filter-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* View Mode Toggle */
.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-left: auto;
}

.view-btn {
    padding: 8px 12px;
    background: var(--bg);
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-light);
    border-right: 1px solid var(--border);
}

.view-btn:last-child {
    border-right: none;
}

.view-btn:hover {
    background: var(--surface);
    color: var(--accent);
}

.view-btn.active {
    background: var(--accent);
    color: white;
}

/* Results Count */
.results-count {
    font-size: 13px;
    color: var(--text-light);
    padding: 8px 0;
}

/* =============================================================================
   VIEW MODES - Grid, List, Detail
   ============================================================================= */

/* Grid View (default) */
.items-container {
    display: grid;
    gap: 16px;
}

.items-container.view-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.items-container.view-list {
    grid-template-columns: 1fr;
}

.items-container.view-detail {
    grid-template-columns: 1fr;
}

/* Item Card - Base */
.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: border-color 0.15s;
}

.item-card:hover {
    border-color: var(--accent);
}

.item-card a {
    text-decoration: none;
    color: inherit;
}

/* Grid View Card */
.view-grid .item-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.view-grid .item-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-grid .item-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.view-grid .item-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.view-grid .item-subtitle {
    font-size: 12px;
    color: var(--text-light);
}

.view-grid .item-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
}

.view-grid .item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

/* List View Card */
.view-list .item-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
}

.view-list .item-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 14px;
}

.view-list .item-main {
    flex: 1;
    min-width: 0;
}

.view-list .item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.view-list .item-subtitle {
    font-size: 12px;
    color: var(--text-light);
}

.view-list .item-desc {
    display: none;
}

.view-list .item-meta {
    display: flex;
    gap: 16px;
    flex-shrink: 0;
}

.view-list .item-meta-item {
    text-align: right;
    min-width: 80px;
}

.view-list .item-meta-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
}

.view-list .item-meta-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

/* Detail View Card */
.view-detail .item-card {
    padding: 24px;
}

.view-detail .item-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.view-detail .item-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.view-detail .item-title {
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
    margin-bottom: 4px;
}

.view-detail .item-subtitle {
    font-size: 13px;
    color: var(--text-light);
}

.view-detail .item-desc {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.view-detail .item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.view-detail .item-meta-item {
    min-width: 100px;
}

.view-detail .item-meta-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.view-detail .item-meta-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

/* Tags/Badges */
.tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-light);
}

.tag.primary {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.tag.success {
    background: #dcfce7;
    color: #16a34a;
    border-color: #16a34a;
}

.tag.warning {
    background: #fef3c7;
    color: #d97706;
    border-color: #d97706;
}

.tag.info {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #1d4ed8;
}

/* Provider badges */
.provider-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: white;
}

.provider-badge.openai { background: #10a37f; }
.provider-badge.anthropic { background: #d97757; }
.provider-badge.google { background: #4285f4; }
.provider-badge.meta { background: #0668E1; }
.provider-badge.mistral { background: #ff7000; }
.provider-badge.deepseek { background: #0066ff; }
.provider-badge.alibaba { background: #ff6a00; }
.provider-badge.microsoft { background: #00a4ef; }
.provider-badge.xai { background: #000000; }
.provider-badge.cohere { background: #39594d; }

/* Price formatting */
.price {
    font-variant-numeric: tabular-nums;
}

.price.free {
    color: #16a34a;
    font-weight: 600;
}

.price.cheap {
    color: #059669;
}

.price.medium {
    color: #d97706;
}

.price.expensive {
    color: #dc2626;
}

/* Hidden items (filtered out) */
.item-card.hidden {
    display: none;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text);
}

/* =============================================================================
   RESPONSIVE - Clean Mobile Design
   ============================================================================= */

@media (max-width: 768px) {
    /* Controls bar - stacked clean layout */
    .controls-bar {
        padding: 12px;
        gap: 10px;
    }

    .search-box {
        flex: 1 1 100%;
        max-width: none;
        order: 1;
    }

    .search-box input {
        padding: 12px 14px 12px 40px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Filters in a clean row */
    .filter-group {
        flex: 1;
        min-width: calc(50% - 5px);
    }

    .filter-group label {
        display: none; /* Hide labels on mobile for cleaner look */
    }

    .filter-select {
        width: 100%;
        padding: 10px 12px;
        font-size: 14px;
    }

    /* View toggle centered */
    .view-toggle {
        margin-left: 0;
        order: 10;
        flex: 1 1 100%;
        justify-content: center;
    }

    .view-btn {
        flex: 1;
        padding: 10px;
        text-align: center;
    }

    /* Filter pills - horizontal scroll */
    .filter-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin: 0 -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .filter-pill {
        flex-shrink: 0;
        padding: 8px 14px;
    }

    /* Grid always single column on mobile */
    .items-container.view-grid,
    .items-container.view-list,
    .items-container.view-detail {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Cards - compact but readable */
    .item-card {
        padding: 16px;
    }

    .view-grid .item-header {
        gap: 10px;
    }

    .view-grid .item-icon {
        width: 36px;
        height: 36px;
    }

    .view-grid .item-title {
        font-size: 14px;
    }

    .view-grid .item-desc {
        font-size: 13px;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .view-grid .item-meta {
        gap: 6px;
    }

    .view-grid .item-meta-item {
        flex: 1;
        min-width: 0;
    }

    /* List view on mobile */
    .view-list .item-card {
        padding: 12px 16px;
        gap: 12px;
    }

    .view-list .item-meta {
        display: none;
    }

    /* Detail view on mobile */
    .view-detail .item-card {
        padding: 16px;
    }

    .view-detail .item-header {
        gap: 12px;
    }

    .view-detail .item-icon {
        width: 40px;
        height: 40px;
    }

    .view-detail .item-title {
        font-size: 16px;
    }

    .view-detail .item-meta {
        gap: 12px;
    }

    .view-detail .item-meta-item {
        flex: 1;
        min-width: calc(50% - 6px);
    }

    /* Results count */
    .results-count {
        font-size: 12px;
        padding: 6px 0;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .filter-group {
        min-width: 100%;
    }

    .view-grid .item-meta-item {
        min-width: calc(50% - 3px);
    }
}
