/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a1a;
    color: #fff;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    width: 1920px;
    height: 1080px;
    position: relative;
}

/* ===== Dynamic Background (mirrors Roku's VideoBg + gradient) ===== */
#background-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 0.6s ease-in-out;
    z-index: 0;
}

#gradient-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(10, 10, 26, 0.95) 0%,
        rgba(10, 10, 26, 0.8) 35%,
        rgba(10, 10, 26, 0.4) 60%,
        rgba(10, 10, 26, 0.2) 100%
    ),
    linear-gradient(
        to top,
        rgba(10, 10, 26, 1) 0%,
        rgba(10, 10, 26, 0.8) 25%,
        transparent 50%
    );
    z-index: 1;
}

/* ===== Loading Overlay (mirrors Roku's CustomLoading) ===== */
#loading-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.4s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#loading-overlay p {
    margin-top: 16px;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.7);
}

/* ===== Error Overlay ===== */
#error-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#error-overlay p {
    font-size: 22px;
    margin-bottom: 20px;
}

#retry-btn {
    padding: 12px 32px;
    font-size: 18px;
    background: #533483;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#retry-btn:hover {
    background: #6a42a5;
}

.hidden {
    display: none !important;
}

/* ===== Banner Metadata (mirrors Roku's playlistInfoComponent) ===== */
#banner {
    position: absolute;
    top: 80px;
    left: 150px;
    z-index: 10;
    max-width: 650px;
    transition: opacity 0.3s ease;
}

#app-logo {
    height: 60px;
    margin-bottom: 16px;
    object-fit: contain;
}

#banner-title {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#banner-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

.badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
}

#banner-description {
    font-size: 16px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.75);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Netflix-specific banner elements: hidden by default */
#banner-match,
#banner-seasons,
#banner-audio,
#banner-category,
#banner-cast,
#banner-buttons {
    display: none;
}

/* ===== Content Rows Area (mirrors Roku's RowList at y=600) ===== */
#content-area {
    position: absolute;
    top: 520px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    overflow: hidden;
}

#rows-container {
    transition: transform 0.35s ease;
    padding-left: 150px;
}

/* ===== Row (mirrors each RowList row) ===== */
.content-row {
    margin-bottom: 8px;
}

.row-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.row-items {
    display: flex;
    gap: 10px;
    transition: transform 0.3s ease;
    padding-bottom: 10px;
}

/* ===== Card (mirrors Roku's PlaylistComponents: 345x194) ===== */
.card {
    flex-shrink: 0;
    width: 345px;
    height: 194px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: 3px solid transparent;
    outline-offset: 4px;
    background: #16213e;
}

.card:hover,
.card.focused {
    transform: scale(1.08);
    z-index: 5;
    outline-color: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Title gradient overlay at bottom (mirrors Roku's bgText + itemNameText) */
.card-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 12px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Video Player Overlay ===== */
#player-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #000;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

#video-player {
    width: 100%;
    height: 100%;
    background: #000;
}

#player-title-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(rgba(0, 0, 0, 0.8), transparent);
    z-index: 210;
}

#player-title {
    font-size: 24px;
    font-weight: 700;
}

#player-close {
    padding: 8px 20px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
}

#player-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== Navigation Hint Bar ===== */
#nav-hint {
    position: absolute;
    bottom: 12px;
    right: 24px;
    z-index: 20;
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

#nav-hint span {
    background: rgba(255, 255, 255, 0.08);
    padding: 4px 12px;
    border-radius: 4px;
}

/* ===============================================
   Fire TV / Android TV Platform Overrides
   =============================================== */
body[data-platform="firetv"] {
    background: #0f1114;
    font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* Darker, warmer gradient for Fire TV */
body[data-platform="firetv"] #gradient-overlay {
    background: linear-gradient(
        to right,
        rgba(15, 17, 20, 0.95) 0%,
        rgba(15, 17, 20, 0.75) 40%,
        rgba(15, 17, 20, 0.3) 65%,
        rgba(15, 17, 20, 0.1) 100%
    ),
    linear-gradient(
        to top,
        rgba(15, 17, 20, 1) 0%,
        rgba(15, 17, 20, 0.85) 20%,
        transparent 55%
    );
}

/* Fire TV cards: wider, less rounded, cyan focus */
body[data-platform="firetv"] .card {
    width: 380px;
    height: 214px;
    border-radius: 4px;
    outline-offset: 2px;
    background: #1a1d24;
}

body[data-platform="firetv"] .card:hover,
body[data-platform="firetv"] .card.focused {
    transform: scale(1.05);
    outline: 3px solid #00a4dc;
    box-shadow: 0 4px 20px rgba(0, 164, 220, 0.3), 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Fire TV row title: lighter weight */
body[data-platform="firetv"] .row-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.85);
}

/* Fire TV banner title: slightly different */
body[data-platform="firetv"] #banner-title {
    font-size: 40px;
    font-weight: 700;
}

/* Fire TV quality badge */
body[data-platform="firetv"] .badge {
    background: rgba(0, 164, 220, 0.25);
    border: 1px solid rgba(0, 164, 220, 0.4);
}

/* Fire TV accent buttons */
body[data-platform="firetv"] #retry-btn {
    background: #00a4dc;
}

body[data-platform="firetv"] #retry-btn:hover {
    background: #0cbcf5;
}

/* Fire TV content area: slightly higher to show more rows */
body[data-platform="firetv"] #content-area {
    top: 500px;
}

/* Fire TV card title overlay */
body[data-platform="firetv"] .card-title-overlay {
    font-size: 13px;
    font-weight: 600;
    padding: 20px 10px 8px;
}

/* Fire TV row spacing */
body[data-platform="firetv"] .row-items {
    gap: 12px;
}

body[data-platform="firetv"] .content-row {
    margin-bottom: 6px;
}

/* ===============================================
   Theme: Netflix Style
   Faithful recreation: large hero, green match %,
   Play/My List buttons, sharp cards, tight grid
   =============================================== */
body[data-theme="netflix"] {
    background: #141414;
    font-family: 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
}

/* --- Background & Gradient: hero fills upper 65%, fades to black --- */
body[data-theme="netflix"] #background-layer {
    height: 80%;
    background-position: center 20%;
}

body[data-theme="netflix"] #gradient-overlay {
    background:
        linear-gradient(
            to bottom,
            transparent 0%,
            transparent 30%,
            rgba(20, 20, 20, 0.4) 50%,
            rgba(20, 20, 20, 0.85) 65%,
            #141414 78%
        ),
        linear-gradient(
            to right,
            rgba(20, 20, 20, 0.9) 0%,
            rgba(20, 20, 20, 0.6) 25%,
            transparent 50%
        );
}

/* --- Banner: positioned mid-left over the hero image --- */
body[data-theme="netflix"] #banner {
    top: 240px;
    left: 60px;
    max-width: 620px;
}

body[data-theme="netflix"] #app-logo {
    height: 50px;
    margin-bottom: 12px;
}

/* Category tag above title */
body[data-theme="netflix"] #banner-category {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

body[data-theme="netflix"] #banner-title {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    margin-bottom: 14px;
}

/* --- Metadata row: green match, year, seasons, badges --- */
body[data-theme="netflix"] #banner-info {
    gap: 10px;
    margin-bottom: 12px;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

body[data-theme="netflix"] #banner-match {
    color: #46d369;
    font-weight: 700;
}

body[data-theme="netflix"] #banner-seasons {
    color: rgba(255, 255, 255, 0.8);
}

body[data-theme="netflix"] .badge {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.9);
}

/* --- Description --- */
body[data-theme="netflix"] #banner-description {
    font-size: 15px;
    line-height: 1.5;
    -webkit-line-clamp: 3;
    color: rgba(255, 255, 255, 0.82);
    margin-bottom: 6px;
}

/* --- Cast info --- */
body[data-theme="netflix"] #banner-cast {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 16px;
}

/* --- Play & My List buttons --- */
body[data-theme="netflix"] #banner-buttons {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

body[data-theme="netflix"] #btn-play {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px 10px 20px;
    font-size: 17px;
    font-weight: 700;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.3px;
}

body[data-theme="netflix"] #btn-play:hover {
    background: rgba(255, 255, 255, 0.8);
}

body[data-theme="netflix"] #btn-play .btn-icon {
    font-size: 22px;
    line-height: 1;
}

body[data-theme="netflix"] #btn-mylist {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px 10px 16px;
    font-size: 17px;
    font-weight: 600;
    background: rgba(109, 109, 110, 0.7);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.3px;
}

body[data-theme="netflix"] #btn-mylist:hover {
    background: rgba(109, 109, 110, 0.5);
}

body[data-theme="netflix"] #btn-mylist .btn-icon {
    font-size: 24px;
    line-height: 1;
}

/* --- Content rows: lower on screen, below hero fade --- */
body[data-theme="netflix"] #content-area {
    top: 620px;
}

body[data-theme="netflix"] #rows-container {
    padding-left: 60px;
}

/* --- Row titles: small, bold, white --- */
body[data-theme="netflix"] .row-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #e5e5e5;
    text-shadow: none;
}

/* --- Cards: sharp corners, tight spacing, no borders --- */
body[data-theme="netflix"] .card {
    border-radius: 2px;
    background: #181818;
    outline: none;
    outline-offset: 0;
    border: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease, z-index 0s;
}

body[data-theme="netflix"] .row-items {
    gap: 4px;
}

body[data-theme="netflix"] .content-row {
    margin-bottom: 24px;
}

/* --- Focus: Netflix-style pop with scale + shadow --- */
body[data-theme="netflix"] .card:hover,
body[data-theme="netflix"] .card.focused {
    outline: none;
    border: none;
    transform: scale(1.35);
    z-index: 10;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.85), 0 0 0 2px rgba(255, 255, 255, 0.15);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* --- Card title overlay: subtle gradient --- */
body[data-theme="netflix"] .card-title-overlay {
    background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.9));
    padding: 30px 8px 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* --- Retry/Error --- */
body[data-theme="netflix"] #retry-btn {
    background: #e50914;
    border-radius: 4px;
    font-weight: 700;
    border: none;
}

body[data-theme="netflix"] #retry-btn:hover {
    background: #f6121d;
}

body[data-theme="netflix"] .spinner {
    border-top-color: #e50914;
}

body[data-theme="netflix"] #nav-hint {
    color: rgba(255, 255, 255, 0.2);
}

body[data-theme="netflix"] #nav-hint span {
    background: rgba(255, 255, 255, 0.06);
}

/* ===============================================
   Theme: Disney+ Style
   Deep navy/indigo bg, bright blue accents,
   large rounded cards, playful feel, wide spacing
   =============================================== */
body[data-theme="disney"] {
    background: #040714;
    font-family: 'Avenir', 'Segoe UI', sans-serif;
}

body[data-theme="disney"] #gradient-overlay {
    background: linear-gradient(
        to right,
        rgba(4, 7, 20, 0.98) 0%,
        rgba(4, 7, 20, 0.85) 25%,
        rgba(4, 7, 20, 0.5) 50%,
        rgba(4, 7, 20, 0.2) 100%
    ),
    linear-gradient(
        to top,
        rgba(4, 7, 20, 1) 0%,
        rgba(4, 7, 20, 0.7) 30%,
        transparent 60%
    );
}

body[data-theme="disney"] #banner {
    top: 90px;
    max-width: 600px;
}

body[data-theme="disney"] #banner-title {
    font-size: 46px;
    font-weight: 800;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

body[data-theme="disney"] #banner-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
}

body[data-theme="disney"] #content-area {
    top: 500px;
}

body[data-theme="disney"] .card {
    border-radius: 14px;
    background: #0d1527;
    outline: none;
    outline-offset: 0;
    border: 2px solid transparent;
}

body[data-theme="disney"] .card:hover,
body[data-theme="disney"] .card.focused {
    outline: none;
    transform: scale(1.12);
    border-color: #f9f9f9;
    box-shadow: 0 8px 30px rgba(0, 114, 210, 0.4), 0 0 60px rgba(0, 114, 210, 0.15);
}

body[data-theme="disney"] .card-title-overlay {
    border-radius: 0 0 12px 12px;
    background: linear-gradient(transparent, rgba(4, 7, 20, 0.9));
    padding: 28px 14px 12px;
    font-size: 14px;
    font-weight: 700;
}

body[data-theme="disney"] .row-title {
    font-size: 17px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(249, 249, 249, 0.72);
    margin-bottom: 14px;
    text-shadow: none;
}

body[data-theme="disney"] .row-items {
    gap: 16px;
}

body[data-theme="disney"] .content-row {
    margin-bottom: 10px;
}

body[data-theme="disney"] .badge {
    background: rgba(0, 114, 210, 0.4);
    border: 1px solid rgba(0, 114, 210, 0.6);
    border-radius: 6px;
    font-size: 12px;
}

body[data-theme="disney"] #retry-btn {
    background: #0063e5;
    border-radius: 8px;
}

body[data-theme="disney"] #retry-btn:hover {
    background: #0080ff;
}

body[data-theme="disney"] .spinner {
    border-top-color: #0063e5;
}

body[data-theme="disney"] #nav-hint {
    color: rgba(255, 255, 255, 0.2);
}

body[data-theme="disney"] #nav-hint span {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

/* ===============================================
   Theme: HBO Style
   Pure black, ultra minimal, thin typography,
   square cards, muted purple accents, lots of space
   =============================================== */
body[data-theme="hbo"] {
    background: #000;
    font-family: 'Georgia', 'Times New Roman', serif;
}

body[data-theme="hbo"] #gradient-overlay {
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 1) 0%,
        rgba(0, 0, 0, 0.85) 25%,
        rgba(0, 0, 0, 0.4) 50%,
        transparent 100%
    ),
    linear-gradient(
        to top,
        rgba(0, 0, 0, 1) 0%,
        rgba(0, 0, 0, 0.95) 20%,
        rgba(0, 0, 0, 0.6) 40%,
        transparent 70%
    );
}

body[data-theme="hbo"] #banner {
    top: 100px;
    max-width: 580px;
}

body[data-theme="hbo"] #banner-title {
    font-size: 48px;
    font-weight: 400;
    font-family: 'Georgia', 'Times New Roman', serif;
    letter-spacing: -1px;
    line-height: 1.1;
}

body[data-theme="hbo"] #banner-info {
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
}

body[data-theme="hbo"] #banner-description {
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
    line-height: 1.6;
}

body[data-theme="hbo"] #content-area {
    top: 540px;
}

body[data-theme="hbo"] .card {
    border-radius: 2px;
    background: #111;
    outline: none;
    outline-offset: 0;
    border: 1px solid transparent;
}

body[data-theme="hbo"] .card:hover,
body[data-theme="hbo"] .card.focused {
    outline: none;
    transform: scale(1.06);
    border-color: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

body[data-theme="hbo"] .card-title-overlay {
    background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.9));
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

body[data-theme="hbo"] .row-title {
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    font-size: 16px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 14px;
    text-shadow: none;
}

body[data-theme="hbo"] .row-items {
    gap: 8px;
}

body[data-theme="hbo"] .content-row {
    margin-bottom: 16px;
}

body[data-theme="hbo"] .badge {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 1px;
}

body[data-theme="hbo"] #retry-btn {
    background: transparent;
    border: 1px solid #fff;
    border-radius: 2px;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 16px;
}

body[data-theme="hbo"] #retry-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

body[data-theme="hbo"] .spinner {
    border-color: rgba(255, 255, 255, 0.08);
    border-top-color: #fff;
}

body[data-theme="hbo"] #nav-hint {
    color: rgba(255, 255, 255, 0.2);
}

body[data-theme="hbo"] #nav-hint span {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    letter-spacing: 0.5px;
}
