/* Tube Search Frontend Styles */
.tube-search-form {
    position: relative;
    display: flex;
    gap: 8px;
    max-width: 520px;
}

.tube-search-form input[type="search"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border, #333);
    border-radius: 8px;
    background: var(--bg-elevated, #1a1a1a);
    color: var(--text, #fff);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tube-search-form input[type="search"]:focus {
    outline: none;
    border-color: var(--accent, #e63946);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.2);
}

.tube-search-form button {
    padding: 12px 24px;
    background: var(--accent, #e63946);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.tube-search-form button:hover { opacity: 0.9; }
.tube-search-form button:active { transform: scale(0.98); }

/* Suggestions dropdown */
.tube-search-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-elevated, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background: var(--accent-bg, rgba(230, 57, 70, 0.15));
}

/* Facets sidebar */
.tube-search-facets {
    background: var(--bg-elevated, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    padding: 20px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.facet-group summary {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted, #888);
    cursor: pointer;
    padding: 8px 0;
    border-bottom: 1px solid var(--border, #333);
    margin-bottom: 8px;
}

.facet-group summary::-webkit-details-marker { display: none; }
.facet-group summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.2s;
}
.facet-group[open] summary::before { transform: rotate(90deg); }

.facet-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.facet-list li { margin-bottom: 4px; }

.facet-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.9rem;
}

.facet-list label:hover { background: var(--hover-bg, rgba(255,255,255,0.05)); }

.facet-list input[type="checkbox"],
.facet-list input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent, #e63946);
    flex-shrink: 0;
}

.facet-list .count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--muted, #888);
    background: var(--bg, #111);
    padding: 2px 8px;
    border-radius: 10px;
}

.clear-filters {
    display: inline-block;
    margin-top: 16px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border, #333);
    border-radius: 6px;
    color: var(--text, #fff);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.clear-filters:hover {
    border-color: var(--accent, #e63946);
    color: var(--accent, #e63946);
}

/* Video grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.video-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.video-grid.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 40px auto;
    border: 3px solid var(--border, #333);
    border-top-color: var(--accent, #e63946);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.video-card {
    background: var(--bg-elevated, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: var(--accent, #e63946);
}

.video-card .thumb {
    position: relative;
    display: block;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.video-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.video-card:hover .thumb img { transform: scale(1.05); }

.video-card .no-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent, #e63946), #c1121f);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
}

.video-card .duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.video-card .play-ico {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-card:hover .play-ico { opacity: 1; }

.video-card .play-ico svg { width: 64px; height: 64px; }

.video-card .info { padding: 12px; }

.video-card h3 {
    margin: 0 0 6px;
    font-size: 0.9rem;
    line-height: 1.4;
    font-weight: 600;
}

.video-card h3 a { color: inherit; text-decoration: none; }
.video-card h3 a:hover { color: var(--accent, #e63946); }

.video-card .meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--muted, #888);
}

.video-card .cat {
    color: var(--accent, #e63946);
    text-decoration: none;
    font-weight: 500;
}

.video-card .cat:hover { text-decoration: underline; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    color: var(--text, #fff);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.pagination a:hover {
    border-color: var(--accent, #e63946);
    color: var(--accent, #e63946);
}

.pagination .current {
    background: var(--accent, #e63946);
    border-color: var(--accent, #e63946);
    color: #fff;
}

.pagination .dots { color: var(--muted, #888); }
.pagination .prev, .pagination .next { font-weight: 600; }

/* Search page */
.search-page .archive-head {
    margin-bottom: 24px;
}

.search-page .archive-head h1 {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.count-pill {
    background: var(--accent-bg, rgba(230, 57, 70, 0.15));
    color: var(--accent, #e63946);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Layout: sidebar + grid */
.search-layout,
.category-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    align-items: start;
}

@media (max-width: 960px) {
    .search-layout,
    .category-layout {
        grid-template-columns: 1fr;
    }
    .tube-search-facets {
        position: static;
        max-height: none;
    }
}

/* Error state */
.tube-search-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted, #888);
}

/* Category page enhancements */
.category-layout .section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.category-layout .more {
    font-size: 0.85rem;
    color: var(--accent, #e63946);
    text-decoration: none;
    font-weight: 500;
}

.category-layout .more:hover { text-decoration: underline; }

/* Parent category link */
.parent-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--muted, #888);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 12px;
    background: var(--bg-elevated, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 20px;
    transition: all 0.2s;
}

.parent-link:hover {
    color: var(--accent, #e63946);
    border-color: var(--accent, #e63946);
    text-decoration: none;
}

/* Related categories section */
.related-categories {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border, #333);
}

.related-categories h2 {
    font-size: 1.1rem;
    margin: 0 0 16px;
    color: var(--text, #fff);
}

/* Category card */
.category-card {
    background: var(--bg-elevated, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: var(--accent, #e63946);
}

.category-card .thumb {
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.category-card .cat-icon {
    font-size: 3rem;
    opacity: 0.9;
}

.category-card .info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.category-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text, #fff);
    text-align: center;
}