/* ================================
   TIRSAIPTV — Premium Smart TV & Mobile Design System
   ================================ */

:root {
    --bg-dark:       #08090d;
    --surface-1:     #11131a;
    --surface-2:     #1a1d28;
    --surface-3:     #242938;
    --border:        rgba(255, 255, 255, 0.08);
    --border-bright: rgba(255, 255, 255, 0.16);
    
    --accent:        #e50914;
    --accent-hover:  #ff1e27;
    --accent-glow:   rgba(229, 9, 20, 0.35);
    --accent-dim:    rgba(229, 9, 20, 0.12);
    
    --text-primary:  #ffffff;
    --text-secondary:#9e9ea7;
    --text-muted:    #63657b;
    
    --radius-sm:     8px;
    --radius-md:     14px;
    --radius-lg:     20px;
    --radius-full:   999px;
    
    --header-height: 68px;
    --nav-height:    72px;
    
    --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
    --transition:    0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    width: 100%;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 50% 0%, rgba(30, 34, 48, 0.4) 0%, var(--bg-dark) 70%);
}

.hidden {
    display: none !important;
}

/* ================================
   HEADER
   ================================ */
.app-header {
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(8, 9, 13, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.8px;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.header-logo span {
    color: var(--accent);
}

.header-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-2);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.conn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f1c40f;
    box-shadow: 0 0 8px #f1c40f;
}

.conn-dot.connected {
    background: #2ecc71;
    box-shadow: 0 0 8px #2ecc71;
}

.conn-dot.error {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-wrap {
    position: relative;
}

.search-wrap input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 10px 20px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    width: 220px;
    outline: none;
    transition: all var(--transition);
}

.search-wrap input:focus,
.search-wrap input:focus-visible {
    border-color: var(--accent);
    background: var(--surface-3);
    box-shadow: 0 0 0 3px var(--accent-glow);
    width: 300px;
}

.search-wrap input::placeholder {
    color: var(--text-muted);
}

/* ================================
   FILTER BAR (PILLS)
   ================================ */
.filter-bar {
    flex-shrink: 0;
    padding: 12px 32px;
    background: rgba(8, 9, 13, 0.6);
    border-bottom: 1px solid var(--border);
    z-index: 90;
}

.pills-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding-bottom: 2px;
}

.pills-scroll::-webkit-scrollbar {
    display: none;
}
.pills-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.pill-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    outline: none;
    transition: all var(--transition);
}

.pill-item:hover,
.pill-item:focus-visible {
    color: var(--text-primary);
    border-color: var(--border-bright);
    background: var(--surface-3);
    transform: translateY(-1px);
}

.pill-item.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 4px 14px var(--accent-glow);
}

/* ================================
   MAIN SCROLL AREA
   ================================ */
.app-main {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 32px 32px;
    scroll-behavior: smooth;
}

.app-main::-webkit-scrollbar {
    width: 8px;
}
.app-main::-webkit-scrollbar-track {
    background: transparent;
}
.app-main::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: var(--radius-full);
}

/* ================================
   LOADER
   ================================ */
.loader-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 55vh;
    gap: 20px;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface-3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
}

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

/* ================================
   HERO SPOTLIGHT BANNER
   ================================ */
.hero-banner {
    position: relative;
    width: 100%;
    height: 320px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 36px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    filter: brightness(0.7);
    transition: background-image 0.5s ease-in-out;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(8, 9, 13, 0.95) 0%, rgba(8, 9, 13, 0.4) 50%, transparent 100%),
                linear-gradient(90deg, rgba(8, 9, 13, 0.95) 0%, transparent 60%);
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 32px 40px;
    max-width: 600px;
}

.hero-badge {
    display: inline-block;
    background: var(--accent);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.2px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.hero-title {
    font-size: 32px;
    font-weight: 900;
    line-height: 1.15;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-actions {
    display: flex;
    gap: 14px;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    outline: none;
    transition: all var(--transition);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--accent-hover);
    transform: scale(1.04);
    box-shadow: 0 10px 30px rgba(229, 9, 20, 0.5);
}

/* ================================
   CARDS & GRID
   ================================ */
.rows-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.row-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.see-more-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.see-more-btn:hover,
.see-more-btn:focus-visible {
    color: var(--accent);
    background: var(--accent-dim);
}

.row-cards {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 4px 12px;
    scroll-snap-type: x mandatory;
}

.row-cards::-webkit-scrollbar { display: none; }
.row-cards { -ms-overflow-style: none; scrollbar-width: none; }

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 20px;
    padding-top: 10px;
}

/* CARD SYSTEM */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    outline: none;
    position: relative;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.card:hover,
.card:focus-visible,
.card.tv-focused {
    transform: scale(1.05) translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), 0 0 0 3px var(--accent-glow);
    z-index: 10;
}

.hero-dots {
    position: absolute;
    bottom: 20px;
    right: 32px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.hero-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
}

.hero-dot.active,
.hero-dot:hover {
    background: var(--accent);
    width: 24px;
    border-radius: var(--radius-full);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Card Poster Types: 2:3 Portrait for Movies/Series & 16:9 Landscape for TV */
.card-poster {
    width: 100%;
    position: relative;
    background: var(--surface-2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Movies & Series: Portrait 2:3 */
.card-poster.poster-portrait {
    aspect-ratio: 2/3;
}

/* Live TV: Widescreen 16:9 */
.card-poster.poster-landscape {
    aspect-ratio: 16/9;
}

.card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s var(--ease-out);
}

.card-poster.poster-landscape img {
    object-fit: contain;
    padding: 10px;
}

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

.poster-fallback {
    font-size: 32px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.15);
    text-transform: uppercase;
    user-select: none;
}

/* Card Badges */
.card-tag {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(8, 9, 13, 0.8);
    backdrop-filter: blur(8px);
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 4px;
    border: 1px solid rgba(229, 9, 20, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface-1);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-group {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================
   BOTTOM NAVIGATION BAR
   ================================ */
.bottom-nav {
    height: var(--nav-height);
    flex-shrink: 0;
    background: rgba(17, 19, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    padding: 0 16px;
    z-index: 100;
}

.nav-tab {
    flex: 1;
    max-width: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-muted);
    outline: none;
    position: relative;
    transition: color var(--transition);
}

.tab-indicator {
    width: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: var(--radius-full);
    position: absolute;
    top: 0;
    transform: scaleX(0);
    transition: transform var(--transition);
}

.nav-tab.active {
    color: var(--text-primary);
}

.nav-tab.active .tab-indicator {
    transform: scaleX(1);
}

.nav-tab:hover,
.nav-tab:focus-visible {
    color: var(--text-primary);
}

.tab-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    transition: stroke var(--transition), transform var(--transition);
}

.nav-tab.active .tab-icon {
    stroke: var(--accent);
    transform: scale(1.1);
}

.nav-tab:hover .tab-icon,
.nav-tab:focus-visible .tab-icon {
    stroke: var(--text-primary);
}

.tab-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

/* ================================
   MODALS
   ================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 8, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 1;
    transition: opacity var(--transition);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-box {
    background: var(--surface-1);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    width: 100%;
    max-height: 90dvh;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    transform: scale(1);
    transition: transform var(--transition);
}

.modal.hidden .modal-box {
    transform: scale(0.95);
}

.modal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.modal-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--accent);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: all var(--transition);
}

.btn-close:hover,
.btn-close:focus-visible {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.player-box {
    max-width: 1000px;
}

.player-wrap {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

/* Series Modal Layout */
.series-box {
    max-width: 860px;
}

.series-body {
    display: flex;
    gap: 28px;
    padding: 24px;
    overflow: hidden;
    flex: 1;
}

.series-cover-col {
    width: 180px;
    flex-shrink: 0;
}

.series-cover-col img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.series-info-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.season-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.season-row label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

#season-selector {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

#season-selector:focus {
    border-color: var(--accent);
}

.episodes-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.episode-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
}

.episode-item:hover,
.episode-item:focus-visible {
    background: var(--accent-dim);
    border-color: var(--accent);
    transform: translateX(4px);
}

.episode-num {
    font-size: 14px;
    font-weight: 800;
    color: var(--accent);
    min-width: 24px;
}

.episode-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-play {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.episode-item:hover .episode-play {
    color: var(--accent);
}

.no-results {
    grid-column: 1/-1;
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    padding: 60px 0;
}

/* ================================
   SMART TV & RESPONSIVE BREAKPOINTS
   ================================ */
@media (min-width: 1200px) {
    :root {
        --header-height: 76px;
        --nav-height:    80px;
    }

    .app-header { padding: 0 48px; }
    .filter-bar { padding: 14px 48px; }
    .app-main { padding: 32px 48px 40px; }

    .header-logo { font-size: 28px; }
    .hero-title { font-size: 40px; }
    .hero-banner { height: 380px; }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 24px;
    }

    .row-cards .card {
        min-width: 190px;
        max-width: 190px;
    }
}

@media (max-width: 600px) {
    :root {
        --header-height: 60px;
        --nav-height:    64px;
    }

    .app-header { padding: 0 16px; }
    .header-status-badge { display: none; }
    .search-wrap input { width: 140px; }
    .search-wrap input:focus { width: 180px; }
    
    .filter-bar { padding: 10px 16px; }
    .app-main { padding: 16px 16px 24px; }
    
    .hero-banner { height: 260px; margin-bottom: 24px; }
    .hero-content { padding: 20px; }
    .hero-title { font-size: 22px; }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
        gap: 12px;
    }

    .row-cards .card {
        min-width: 135px;
        max-width: 135px;
    }

    .series-body {
        flex-direction: column;
        align-items: center;
        padding: 16px;
    }
    
    .series-cover-col { width: 120px; }
}
