/* YouTube page - channels grid, video grid, player */

.yt-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 15px 20px;
}

/* Search */
.search-wrapper {
    position: relative;
    margin-bottom: 25px;
}

.search-wrapper .search-input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 16px;
    font-family: 'Cairo', sans-serif;
    outline: none;
    transition: 0.3s;
    box-sizing: border-box;
}

.search-wrapper .search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

.search-wrapper .search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Toolbar */
.yt-video-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.yt-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    font-family: inherit;
}

.yt-back-btn:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* --- Channels Grid --- */
.yt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (min-width: 600px) {
    .yt-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.yt-no-results {
    color: var(--text-secondary);
    text-align: center;
    width: 100%;
    grid-column: 1 / -1;
    padding: 40px;
}

.yt-channel-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 10px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.yt-channel-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(0,242,255,0.1) 0%, transparent 100%);
    opacity: 0;
    transition: 0.3s;
}

.yt-channel-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 10px 30px -10px rgba(0, 242, 255, 0.2);
}

.yt-channel-card:hover::before {
    opacity: 1;
}

.yt-channel-card:active {
    transform: scale(0.96);
}

.yt-avatar {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: #111;
    transition: 0.3s;
    z-index: 2;
}

.yt-channel-card:hover .yt-avatar {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
    transform: scale(1.05);
}

.yt-channel-name {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    z-index: 2;
}

.yt-channel-meta {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 5px;
    z-index: 2;
}

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

.yt-video-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
}

.yt-video-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(0,242,255,0.1) 0%, transparent 100%);
    opacity: 0;
    transition: 0.3s;
    pointer-events: none;
    z-index: 1;
}

.yt-video-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px -10px rgba(0, 242, 255, 0.2);
}

.yt-video-card:hover::before {
    opacity: 1;
}

.yt-video-card:active {
    transform: scale(0.98);
}

.yt-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.yt-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.4s ease;
}

.yt-video-card:hover .yt-thumb {
    transform: scale(1.08);
}

.yt-video-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
    z-index: 2;
}

.yt-video-title {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

.yt-video-meta {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'Fira Code';
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: auto;
}

.badge-vid {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: bold;
    background: rgba(0, 242, 255, 0.1);
    color: var(--primary);
}

.yt-dl-btn {
    position: absolute;
    right: 15px;
    bottom: 15px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    color: #ff0033;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: 0.3s;
    z-index: 5;
    font-size: 16px;
}

.yt-video-card:hover .yt-dl-btn {
    background: #ff0033;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.4);
}

/* --- YouTube Player Page --- */
.yt-player-root {
    flex: 1;
    min-height: 0;
    background: #000;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.yt-player-root .yt-player-body {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.yt-iframe-wrap {
    width: 100%;
    height: 100%;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    box-sizing: border-box;
}

.yt-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#yt-player-container {
    width: 100%;
    height: 100%;
}

#yt-player-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Controls */
.yt-player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.95), transparent);
    padding: 15px 20px;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.yt-player-root.idle .yt-player-controls,
.yt-player-root.idle .yt-player-header {
    opacity: 0 !important;
    pointer-events: none;
}

.yt-progress-area {
    width: 100%;
    height: 15px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    touch-action: none;
    margin-bottom: 8px;
}

.yt-progress-bg {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    position: absolute;
}

.yt-progress-bar {
    height: 4px;
    width: 0%;
    background: var(--primary);
    border-radius: 5px;
    position: absolute;
    left: 0;
    box-shadow: 0 0 10px var(--primary);
}

.yt-progress-thumb {
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    left: 0%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.yt-progress-area:hover .yt-progress-thumb {
    opacity: 1;
}

.yt-range {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    margin: 0;
}

.yt-time-current,
.yt-time-duration {
    font-family: 'Fira Code';
    font-size: 12px;
    color: white;
    position: absolute;
    top: -18px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.yt-time-current {
    left: 0;
}

.yt-time-duration {
    right: 0;
}

.yt-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.yt-left-controls,
.yt-right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.yt-ctrl-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.85;
    transition: 0.2s;
    padding: 0;
    width: 30px;
    text-align: center;
}

.yt-ctrl-btn:hover {
    opacity: 1;
    color: var(--primary);
    transform: scale(1.1);
}

.yt-speed-btn {
    font-family: 'Fira Code';
    font-size: 14px;
    width: 35px;
}

.yt-volume-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yt-vol-icon {
    font-size: 12px;
    opacity: 0.7;
}

.yt-volume-range {
    width: 60px;
    height: 3px;
    accent-color: var(--primary);
    cursor: pointer;
}

.loading-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 50px;
    font-family: 'Fira Code', monospace;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
