/* ============================================================
   WikiLive — YouTube Video Search Styles
   ============================================================ */

/* ── Panel shell ── */
#yt-panel {
    margin: 12px 0 0;
    border-radius: 14px;
    overflow: hidden;
    background: #0f111a;
    border: 1px solid #252a3a;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: all 0.25s ease;
    font-family: system-ui, -apple-system, sans-serif;
}
#yt-panel.yt-hidden { display: none; }
#yt-panel.yt-collapsed .yt-grid,
#yt-panel.yt-collapsed .yt-player-area,
#yt-panel.yt-collapsed .yt-footer { display: none; }

/* ── Header ── */
.yt-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #1a0a0a 0%, #0a0a2a 100%);
    border-bottom: 1px solid #252a3a;
}
.yt-header-left  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.yt-header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.yt-logo  { font-size: 1.3em; color: #ff0000; }
.yt-title { font-size: 0.97em; font-weight: 700; color: #fff; letter-spacing: 0.3px; }
.yt-count { font-size: 0.75em; color: #8b949e; padding: 2px 8px; background: rgba(255,255,255,0.06); border-radius: 10px; }

/* ── Sort tabs ── */
.yt-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.yt-tab {
    padding: 5px 13px; border-radius: 16px; border: 1px solid #333;
    background: transparent; color: #8b949e; font-size: 0.78em; cursor: pointer;
    transition: all 0.15s; font-family: inherit; white-space: nowrap;
}
.yt-tab:hover  { background: #1a2030; color: #ddd; }
.yt-tab-active { background: #ff0000; color: #fff; border-color: #ff0000; font-weight: 600; }

/* ── Saved / Collapse buttons ── */
.yt-saved-btn, .yt-collapse-btn {
    background: transparent; border: 1px solid #333; color: #8b949e;
    border-radius: 8px; padding: 5px 10px; font-size: 0.8em; cursor: pointer;
    transition: all 0.15s; font-family: inherit;
}
.yt-saved-btn:hover, .yt-collapse-btn:hover { background: #1a2030; color: #fff; }

/* ── Player area ── */
.yt-player-area { background: #050507; padding: 16px 18px 20px; border-bottom: 1px solid #252a3a; overflow: visible; }
.yt-player-area.yt-hidden { display: none; }

/* Vertical stack: video on top, details below — nothing gets clipped */
.yt-player-inner { display: flex; flex-direction: column; gap: 14px; }
.yt-player-embed-wrap {
    width: 100%; max-width: 800px; margin: 0 auto;
    aspect-ratio: 16/9; background: #000; border-radius: 10px; overflow: hidden;
}
.yt-player-iframe { width: 100%; height: 100%; border: none; display: block; }

/* Details row: channel thumb + text side by side, then stats/desc/actions below */
.yt-player-details { width: 100%; max-width: 800px; margin: 0 auto; }
.yt-player-title   { font-size: 1.08em; font-weight: 700; color: #e6edf3; line-height: 1.4; margin-bottom: 10px; }
.yt-player-meta    { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.yt-player-chan-thumb { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.yt-player-channel { font-size: 0.9em; font-weight: 600; color: #c9d1d9; }
.yt-player-subs    { font-size: 0.78em; color: #8b949e; font-weight: 400; }
.yt-player-stats   { font-size: 0.82em; color: #8b949e; margin-top: 3px; }
.yt-player-desc    { font-size: 0.83em; color: #8b949e; line-height: 1.5; margin: 10px 0;
                     max-height: 72px; overflow: hidden; background: rgba(255,255,255,0.03);
                     border-radius: 8px; padding: 8px 12px; }
.yt-desc-more      { background: none; border: none; color: #4a90d9; cursor: pointer; font-size: inherit; padding: 0; }

/* Action buttons — full row, always visible */
.yt-player-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 12px;
    border-top: 1px solid #1e2535;
    align-items: center;
}
.yt-player-yt-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px; border-radius: 22px; font-size: 0.85em; font-weight: 700;
    text-decoration: none; background: #ff0000; color: #fff; transition: all 0.15s;
    white-space: nowrap;
}
.yt-player-yt-link:hover { background: #cc0000; transform: translateY(-1px); }
.yt-player-chan-link { background: #2a3a5a; }
.yt-player-chan-link:hover { background: #3a4f7a; }
.yt-player-close {
    padding: 9px 20px; border-radius: 22px; font-size: 0.85em; font-weight: 700;
    background: #1e2535; color: #8b949e; border: 1px solid #333; cursor: pointer;
    transition: all 0.15s; font-family: inherit; white-space: nowrap; margin-left: auto;
}
.yt-player-close:hover { background: #e74c3c; color: #fff; border-color: #e74c3c; }

/* ── Video grid ── */
.yt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding: 16px 18px;
    min-height: 60px;
}

/* ── Video card ── */
.yt-card {
    background: #161b27;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #252a3a;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    display: flex;
    flex-direction: column;
}
.yt-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(255,0,0,0.18);
    border-color: #ff3333;
}
.yt-card.yt-watched { opacity: 0.75; }
.yt-card.yt-watched:hover { opacity: 1; }

/* Thumbnail */
.yt-thumb-wrap { position: relative; aspect-ratio: 16/9; background: #050507; overflow: hidden; flex-shrink: 0; }
.yt-thumb { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.22s; }
.yt-card:hover .yt-thumb { transform: scale(1.04); }
.yt-play-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.18s;
}
.yt-card:hover .yt-play-overlay { opacity: 1; }
.yt-play-icon {
    width: 50px; height: 50px; background: rgba(255,0,0,0.9);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.2em; color: #fff; padding-left: 4px;
    box-shadow: 0 4px 16px rgba(255,0,0,0.5);
}
.yt-duration {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.85); color: #fff;
    font-size: 0.72em; font-weight: 700; padding: 1px 5px; border-radius: 4px;
}
.yt-watched-badge {
    position: absolute; top: 6px; left: 6px;
    background: rgba(0,0,0,0.75); color: #2ecc71;
    font-size: 0.68em; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}
.yt-save-btn {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,0.75); border: none; color: #fff;
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    font-size: 0.85em; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.yt-card:hover .yt-save-btn, .yt-save-btn.yt-saved { opacity: 1; }
.yt-save-btn.yt-saved { background: #ff0000; }
.yt-save-btn:hover { background: #cc0000 !important; }

/* Card body */
.yt-card-body  { padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.yt-card-title { font-size: 0.84em; font-weight: 600; color: #e6edf3; line-height: 1.35;
                 display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-card-meta  { display: flex; align-items: center; gap: 6px; }
.yt-chan-thumb  { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.yt-card-meta-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.yt-channel    { font-size: 0.75em; color: #8b949e; font-weight: 600;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yt-stats      { font-size: 0.7em; color: #6a737d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yt-desc       { font-size: 0.72em; color: #6a737d; line-height: 1.4;
                 display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Loading skeletons ── */
.yt-loading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    width: 100%;
}
.yt-skeleton {
    background: linear-gradient(90deg, #161b27 25%, #1f2637 50%, #161b27 75%);
    background-size: 200% 100%;
    animation: yt-shimmer 1.4s infinite;
    border-radius: 10px;
    aspect-ratio: 16/9;
    min-height: 140px;
}
@keyframes yt-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── States ── */
.yt-placeholder, .yt-error {
    color: #6a737d; font-size: 0.88em; text-align: center;
    padding: 32px 20px; grid-column: 1 / -1;
}
.yt-error { color: #e74c3c; }

/* ── Footer (load more) ── */
.yt-footer { padding: 0 18px 14px; display: flex; justify-content: center; }
.yt-load-more {
    padding: 9px 28px; border-radius: 20px; background: #ff0000; color: #fff;
    border: none; font-size: 0.85em; font-weight: 700; cursor: pointer;
    transition: all 0.18s; font-family: inherit;
}
.yt-load-more:hover { background: #cc0000; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(255,0,0,0.3); }

/* ── Responsive ── */
@media (max-width: 600px) {
    .yt-grid { grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
    .yt-player-close { margin-left: 0; width: 100%; justify-content: center; }
    .yt-player-actions { gap: 8px; }
}
@media (max-width: 400px) {
    .yt-grid { grid-template-columns: 1fr; }
    .yt-tabs { flex-wrap: wrap; gap: 4px; }
}
