/* tv.css - Specific styles for the TV page and TV Overlay */

/* TV Page Specific Layout */
.tv-page-body {
    padding-top: 100px;
    min-height: 100vh;
    background: var(--bg-alt);
}

.tv-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 5%;
}

.tv-header {
    text-align: center;
    margin-bottom: 50px;
}

.tv-header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.tv-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-bottom: 100px;
}

.tv-category-header {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding: 10px 0 6px;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
    margin-bottom: 4px;
}

.tv-category-header span {
    background: linear-gradient(90deg, var(--accent-color), #ff0055);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tv-category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Logo image inside card */
.tv-logo-img {
    width: 80px;
    height: 55px;
    object-fit: contain;
    border-radius: 6px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
    transition: transform 0.3s ease;
}

.tv-card:hover .tv-logo-img {
    transform: scale(1.08);
}

@media (max-width: 1100px) {
    .tv-category-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .tv-category-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .tv-category-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}


.tv-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 35px 20px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.5s ease;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--shadow-sm);
}

.tv-card-content {
    padding: 15px 20px 25px 20px;
}

#live-grid-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

@media (max-width: 900px) {
    #live-grid-container { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    #live-grid-container { grid-template-columns: 1fr; gap: 20px; }
}

#live-grid-container .tv-card {
    padding: 0;
    text-align: left;
}

.live-hover-iframe {
    position: absolute;
    top: 50%; left: 50%;
    width: 150%; height: 150%;
    transform: translate(-50%, -50%);
    border: none;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 3;
}
.tv-card:hover .live-hover-iframe {
    opacity: 1;
}

/* Premium gradient sweep light (holographic/neon feel) */
.tv-card::before {
    content: '';
    position: absolute;
    top: -100%; left: -100%; right: -100%; bottom: -100%;
    background: conic-gradient(from 0deg, transparent 60%, var(--accent-color) 80%, #ff0055 100%);
    animation: sweepLight 6s linear infinite;
    z-index: 0;
    opacity: 0.4;
    filter: blur(4px);
    transition: opacity 0.5s ease, filter 0.5s ease;
    will-change: transform;
    backface-visibility: hidden;
}

/* The inner solid card */
.tv-card::after {
    content: '';
    position: absolute;
    inset: 1px;
    background: linear-gradient(150deg, var(--bg-card) 0%, var(--bg-alt) 150%);
    border-radius: calc(var(--radius-lg) - 1px);
    border: 1px solid var(--border-color);
    z-index: 1;
}

/* Sheen effect traveling across the card */
.tv-card-sheen {
    position: absolute;
    top: 0; left: -150%; width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.08), transparent);
    transform: skewX(-20deg);
    z-index: 3;
    pointer-events: none;
    transition: 0.1s;
}

@keyframes sweepLight {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shineSweep {
    0% { left: -150%; }
    100% { left: 200%; }
}

.tv-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent-dim);
}

.tv-card:focus-visible {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent-dim);
    outline: 2px solid var(--accent-color);
    outline-offset: 4px;
}

.tv-card:hover .tv-card-sheen {
    animation: shineSweep 1.2s ease-out;
}

.tv-card:hover::before {
    opacity: 1;
    animation: sweepLight 2.5s linear infinite;
    background: conic-gradient(from 0deg, transparent 40%, var(--accent-color) 80%, #ff0055 100%);
    filter: blur(2px);
}

.tv-icon {
    margin-bottom: 15px;
    position: relative;
    z-index: 2;
    display: inline-flex;
    justify-content: center;
    color: var(--text-muted); /* Changed from hardcoded white */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tv-icon svg {
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.tv-card:hover .tv-icon {
    color: rgba(239, 35, 60, 0.9);
    transform: scale(1.1) translateY(-3px);
    filter: drop-shadow(0 0 15px rgba(239, 35, 60, 0.4));
}

.tv-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    position: relative;
    z-index: 2;
}

/* Enhancements for Light Mode Flatness */
[data-theme="light"] .tv-card {
    box-shadow: var(--shadow-sm);
}
[data-theme="light"] .tv-card:hover {
    box-shadow: var(--shadow-md);
}

.tv-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(239, 35, 60, 0.1);
    border: 1px solid rgba(239, 35, 60, 0.4);
    color: #ef233c;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 20px;
    z-index: 2;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(239, 35, 60, 0.15);
}

.live-dot {
    width: 6px;
    height: 6px;
    background: #ef233c;
    border-radius: 50%;
    animation: flashLive 1.5s infinite;
}

@keyframes flashLive {
    0% { box-shadow: 0 0 0 0 rgba(239, 35, 60, 0.8); }
    70% { box-shadow: 0 0 0 6px rgba(239, 35, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 35, 60, 0); }
}

/* TV Overlay Player Interface */
#tv-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Mobile Browser Support */
    background: var(--bg-main);
    z-index: 999999;
    display: none; /* Hidden by default */
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#tv-overlay.active {
    display: flex;
    opacity: 1;
}

/* 
  Hack to prevent clicking native youtube elements 
  while keeping the iframe visible.
*/
.tv-iframe-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

.tv-iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none; /* Crucial: Disables all click interaction with the iframe! */
}

/* Overlay that catches clicks to prevent pausing if they click the video */
.tv-click-catcher {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10;
    cursor: default;
}

/* Static Noise Effect before video loads fully */
.tv-static {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: repeating-radial-gradient(#000 0 0.0001%, #fff 0 0.0002%);
    background-size: 100% 100%;
    opacity: 0.15;
    z-index: 5;
    pointer-events: none;
    animation: staticNoise 0.2s steps(2) infinite;
    display: none;
}

@keyframes staticNoise {
    0% { background-position: 0 0; }
    100% { background-position: 100% 100%; }
}

/* Floating Custom TV Controls */
.tv-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 20px;
    opacity: 1; /* Always visible on Smart TVs to ensure they can be selected */
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 1024px) {
    .tv-controls {
        opacity: 0; /* Fade out only on desktop systems until hovered */
    }
}

/* INTERACTIVE LIVE MODE OVRRIDES */
.interactive-tv-mode iframe {
    pointer-events: auto !important; /* Enable native click to access gear icon */
}

.interactive-tv-mode .tv-click-catcher {
    display: none !important;
}

.interactive-tv-mode .tv-controls {
    top: 30px;
    bottom: auto;
    right: 30px;
    left: auto;
    transform: none;
    padding: 10px 15px;
}

.interactive-tv-mode #tv-vol-up, 
.interactive-tv-mode #tv-vol-down, 
.interactive-tv-mode #tv-vol-display,
.interactive-tv-mode #tv-fullscreen {
    display: none !important;
}

/* Custom TV Toast Notification */
.tv-toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.tv-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.tv-iframe-wrapper:hover .tv-controls,
.tv-controls:hover {
    opacity: 1; /* Show on hover */
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--bg-alt);
    transform: scale(1.1);
}

.control-btn:focus-visible {
    background: var(--bg-alt);
    transform: scale(1.1);
    outline: 2px solid var(--accent-light);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.btn-danger {
    color: #ef233c;
}
.btn-danger:hover {
    background: rgba(239, 35, 60, 0.15);
}

.btn-danger:focus-visible {
    background: rgba(239, 35, 60, 0.15);
    outline: 2px solid #ef233c;
}

.volume-indicator {
    color: var(--text-main);
    font-weight: 600;
    font-size: 14px;
    min-width: 40px;
    text-align: center;
    font-family: monospace;
}

.tv-channel-info {
    position: absolute;
    top: 30px;
    left: 30px;
    z-index: 100;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s;
}
.tv-iframe-wrapper:hover .tv-channel-info {
    opacity: 1;
}

.info-dot {
    width: 10px;
    height: 10px;
    background: #ef233c;
    border-radius: 50%;
    animation: pulse 2s infinite;
}
