/* Guyana IPTV theme — Tailwind CSS companion */

:root {
    --accent: #9ef01a;
    --accent-dim: #7ed60a;
    --surface: #171717;
    --surface-light: #262626;
    --bg: #0a0a0a;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: #fff;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
}

/* TV remote focus ring */
[data-focusable]:focus,
[data-focusable].focus,
button:focus,
a:focus,
input:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.6) !important;
    border-radius: 0.5rem;
    transform: scale(1.03);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* Hide scrollbars but keep functionality */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Horizontal row */
.row-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scroll-snap-type: x mandatory;
}

.row-scroll > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

/* Card hover lift */
.media-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.media-card:hover,
.media-card:focus {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* Gradient fallback for cards without images */
.gradient-fallback {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Skeleton loading */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, #262626 25%, #404040 50%, #262626 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Player overlay controls */
.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 25%, transparent 75%, rgba(0,0,0,0.8) 100%);
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.player-overlay.hidden-controls {
    opacity: 0;
    pointer-events: none;
}
.player-overlay > * {
    pointer-events: auto;
}

/* Custom range / volume slider */
input[type="range"] {
    -webkit-appearance: none;
    background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -5px;
    cursor: pointer;
}
input[type="range"]::-moz-range-track {
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
    height: 14px;
    width: 14px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

/* Progress bar */
.progress-track {
    background: rgba(255,255,255,0.2);
    height: 6px;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}
.progress-track:hover {
    height: 8px;
}
.progress-buffered {
    background: rgba(255,255,255,0.25);
    height: 100%;
    border-radius: 3px;
    width: 0%;
    position: absolute;
    top: 0;
    left: 0;
}
.progress-fill {
    background: var(--accent);
    height: 100%;
    border-radius: 3px;
    width: 0%;
    position: absolute;
    top: 0;
    left: 0;
    transition: width 0.1s linear;
}
.progress-track:hover .progress-fill {
    background: var(--accent-dim);
}
.progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    z-index: 5;
}
.progress-track:hover .progress-handle,
.progress-track.dragging .progress-handle {
    display: block !important;
}

/* Player menus / overlays */
.player-menu {
    position: absolute;
    right: 1rem;
    bottom: 5rem;
    width: 16rem;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(15,15,15,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.75rem;
    padding: 0.5rem;
    z-index: 60;
    color: white;
}
.player-menu h4 {
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 0.25rem;
}
.player-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: rgba(255,255,255,0.9);
    transition: background 0.15s;
}
.player-menu button:hover,
.player-menu button:focus {
    background: rgba(255,255,255,0.1);
}
.player-menu button.active {
    color: var(--accent);
    font-weight: 600;
}
.player-menu .season-label {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-top: 0.25rem;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(23, 23, 23, 0.95);
    border: 1px solid #262626;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    color: #fff;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.toast.show {
    opacity: 1;
}

/* Splash screen QR */
.tv-qr {
    text-align: center;
    margin: 1.5rem auto;
    width: 200px;
    height: 200px;
}

.tv-qr img {
    display: block;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (min-width: 768px) {
    .tv-qr {
        width: 260px;
        height: 260px;
    }
}

/* Device info frame on splash */
.info-card {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: 1rem;
    padding: 1.25rem;
    margin: 1rem 0 1.5rem;
    text-align: left;
}

.info-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.info-row:last-of-type {
    margin-bottom: 0;
}

.info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a3a3a3;
}

.info-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1rem;
    color: var(--accent);
    word-break: break-all;
}

.copy-btn {
    width: 100%;
    margin-top: 1rem;
}

.header-logo-link {
    border-radius: 0.5rem;
}

/* Home hero background cross-fade */
.home-hero {
    transition: background-image 0.8s ease-in-out;
}

/* Netflix-style home rows use existing .row-section; ensure spacing */
#latestMoviesRow1,
#latestMoviesRow2,
#latestSeriesRow1,
#latestSeriesRow2,
#trendingSportsRow {
    min-height: 0;
}

.header-logo {
    height: 32px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.splash-logo {
    max-width: 100%;
    height: auto;
    width: 320px;
    margin: 0 auto 0.5rem;
}

/* Netflix-style row enhancements */
.row-section {
    position: relative;
}

.row-chevron {
    opacity: 0;
    pointer-events: none;
}

.group\/row:hover .row-chevron,
.row-chevron:focus {
    opacity: 1;
    pointer-events: auto;
}

/* Enhanced card hover for Netflix feel */
.media-card-v2 {
    transition: transform 0.2s ease, box-shadow 0.2s ease, z-index 0s;
}

.media-card-v2:hover,
.media-card-v2:focus {
    transform: scale(1.08) translateY(-6px);
    z-index: 20;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

.media-card-v2:hover .gradient-fallback,
.media-card-v2:focus .gradient-fallback {
    transform: scale(1.1);
}

.media-card-v2:hover .more-info-btn,
.media-card-v2:focus .more-info-btn,
.media-card-v2:hover .favorite-btn,
.media-card-v2:focus .favorite-btn {
    opacity: 1 !important;
}

.media-card-v2:hover [class*="line-clamp"],
.media-card-v2:focus [class*="line-clamp"] {
    white-space: normal;
}

/* Detail modal typography */
#detailModal h1 {
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

#detailModal .skeleton {
    border-radius: 0.5rem;
}

/* Season / episode selector */
.season-tab.active {
    background: #fff;
    color: #000;
}

.episode-row {
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.episode-row:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

/* Modal focus trap */
#detailModal [data-focusable]:focus,
#detailModal button:focus,
#detailModal a:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(158, 240, 26, 0.6);
    transform: scale(1.02);
}

/* Splash / pending TV classes */
.tv-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.tv-card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 720px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.tv-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--accent);
}

.tv-subtitle {
    color: #a3a3a3;
    margin-bottom: 1.5rem;
}

.tv-device-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.25rem;
    letter-spacing: 0.03em;
    background: var(--surface-light);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    margin: 0.75rem 0;
    word-break: break-all;
}

.tv-status {
    font-size: 0.95rem;
    color: #a3a3a3;
    margin-top: 1rem;
}

.tv-status.active { color: #22c55e; }
.tv-status.pending { color: #facc15; }
.tv-status.blocked { color: #ef4444; }

.tv-loading {
    font-size: 1rem;
    color: #a3a3a3;
}

.tv-error {
    color: #ef4444;
    font-size: 1rem;
}

.tv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    min-height: 48px;
    padding: 0.65rem 1.25rem;
    margin: 0.35rem;
    border: 2px solid transparent;
    border-radius: 0.75rem;
    background: var(--surface-light);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}

.tv-btn:focus,
.tv-btn.focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.25);
}

.tv-btn-primary {
    background: var(--accent);
    color: #000;
}

.tv-btn-primary:focus,
.tv-btn-primary.focus {
    background: var(--accent-dim);
}

.tv-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .tv-card {
        padding: 2.5rem;
    }
    .tv-title {
        font-size: 2.5rem;
    }
}

/* ── 3-Panel Live TV Layout ─────────────────────────────────────── */
.live-tv-mode header { display: none !important; }
.live-tv-mode main   { padding-top: 0 !important; }

.live-panels {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    position: relative;
}

#categorySidebar {
    width: 200px;
    min-width: 200px;
    background: #111;
    border-right: 1px solid #222;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

#channelListPanel {
    width: 380px;
    min-width: 380px;
    background: #0d0d0d;
    border-right: 1px solid #222;
    display: flex;
    flex-direction: column;
    /* overflow: hidden is NOT set here — .panels-collapsed applies it instantly (overflow isn't animated).
       Leaving it out lets #channelScroll receive pointer scroll events on LG/Samsung TV browsers. */
    position: relative;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

#playerPanel {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    flex-direction: column;
}

/* Collapsed state — panels slide away, player goes fullscreen */
.panels-collapsed #categorySidebar {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right: none;
    overflow: hidden;
    pointer-events: none;
}
.panels-collapsed #channelListPanel {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right: none;
    overflow: hidden;
    pointer-events: none;
}

/* Guide tab — always visible on left edge when collapsed */
#guideTab {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    background: rgba(30,30,30,0.7);
    border: 1px solid #333;
    border-left: none;
    border-radius: 0 0.5rem 0.5rem 0;
    padding: 0.75rem 0.4rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s, background 0.15s;
    pointer-events: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.panels-collapsed #guideTab {
    opacity: 0.5;
    pointer-events: auto;
}
.panels-collapsed #guideTab:hover,
.panels-collapsed #guideTab:focus {
    opacity: 1;
    background: rgba(50,50,50,0.9);
}
#guideTab svg {
    display: block;
}

/* Collapse tab — centered vertically between channel list and player */
.collapse-tab {
    position: absolute;
    left: 580px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    background: rgba(30,30,30,0.85);
    border: 1px solid #444;
    border-radius: 0.5rem;
    padding: 0.75rem 0.35rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s, background 0.15s, left 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #999;
}
.collapse-tab:hover,
.collapse-tab:focus {
    opacity: 1;
    background: rgba(50,50,50,0.95);
    color: var(--accent);
}
.collapse-tab svg { display: block; }
.panels-collapsed .collapse-tab {
    display: none;
}
@media (max-width: 1200px) {
    .collapse-tab { left: 470px; }
}
@media (max-width: 768px) {
    .collapse-tab { display: none; }
}

/* Category sidebar items */
.cat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #a3a3a3;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cat-item:hover { background: #1a1a1a; color: #fff; }
.cat-item.active {
    background: #1a1a1a;
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}
.cat-item .cat-count {
    margin-left: auto;
    font-size: 0.7rem;
    color: #555;
    font-weight: 400;
}
.cat-item.cat-sub {
    padding-left: 1.75rem;
    font-size: 0.78rem;
    border-left-width: 3px;
}

/* Channel list rows */
#channelSearch {
    margin: 0.5rem;
    padding: 0.6rem 0.75rem 0.6rem 2.25rem;
    background: #171717;
    border: 1px solid #333;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
}
#channelSearch:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(158,240,26,0.2);
}

#channelScroll {
    flex: 1;
    overflow-y: auto;
}

/* ── Channel list scroll buttons ── */
.ch-scroll-btn {
    width: 100%;
    height: 36px;
    background: linear-gradient(to bottom, #0d0d0d, #151515);
    border: none;
    border-top: 1px solid #1e1e1e;
    border-bottom: 1px solid #1e1e1e;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.8;
    transition: background 0.15s, opacity 0.15s;
}
.ch-scroll-btn:hover,
.ch-scroll-btn:focus {
    background: #1a1a1a;
    opacity: 1;
    outline: none;
}
.ch-scroll-btn:disabled {
    pointer-events: none;
}

/* ── Glow click feedback ── */
@keyframes glowPulse {
    0%   { background-color: rgba(158, 240, 26, 0.0); box-shadow: none; }
    25%  { background-color: rgba(158, 240, 26, 0.22); box-shadow: inset 0 0 14px rgba(158, 240, 26, 0.35); }
    100% { background-color: rgba(158, 240, 26, 0.0); box-shadow: none; }
}
.glow-click {
    animation: glowPulse 0.55s ease-out forwards;
}

.ch-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s;
    min-height: 44px;
}
.ch-row:hover { background: #1a1a1a; }
.ch-row.active {
    background: rgba(158,240,26,0.08);
    border-left-color: var(--accent);
}
.ch-row.active .ch-name { color: var(--accent); }

.ch-num {
    width: 28px;
    text-align: right;
    font-size: 0.7rem;
    color: #555;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.ch-logo {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    background: #222;
    flex-shrink: 0;
}
.ch-logo-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #555;
    flex-shrink: 0;
    font-weight: 700;
}
.ch-name {
    font-size: 0.82rem;
    color: #e5e5e5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.ch-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: auto;
    background: #555;
}
.ch-status.online { background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.ch-status.offline { background: #ef4444; box-shadow: 0 0 4px #ef4444; }
.ch-epg {
    font-size: 0.7rem;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* Player panel placeholder */
.player-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #555;
    gap: 1rem;
}
.player-placeholder svg { opacity: 0.3; }

/* Channel info overlay on player */
.channel-info-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
    padding: 2rem 1.5rem 1.25rem;
    opacity: 1;
    transition: opacity 0.4s;
    pointer-events: none;
    z-index: 10;
}
.channel-info-bar.hidden-info { opacity: 0; }

/* Responsive: collapse for smaller screens */
@media (max-width: 1200px) {
    #categorySidebar { width: 170px; min-width: 170px; }
    #channelListPanel { width: 300px; min-width: 300px; }
}
@media (max-width: 768px) {
    .live-panels { flex-direction: column; }
    #categorySidebar { display: none; }
    #channelListPanel { width: 100%; min-width: 100%; height: 50vh; }
    #playerPanel { height: 50vh; }
    .panels-collapsed #channelListPanel { height: 0; }
    .panels-collapsed #playerPanel { height: 100vh; }
}
