/* TV UI Styles - RTL & Persian */

:root {
    --primary-color: #e50914;
    --secondary-color: #564d4d;
    --background-dark: #141414;
    --background-darker: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --focus-color: #ffffff;
    --card-width: 210px;
    --card-height: 320px;
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-primary);
    direction: rtl;
    overflow-x: hidden;
    line-height: 1.6;
}

.tv-app {
    width: 100%;
    min-height: 100vh;
}

/* Hero Section */
.hero-section {
    position: relative;
    width: 100%;
    height: 68vh;
    min-height: 520px;
    overflow: hidden;
    margin-bottom: 32px;
}

.hero-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            rgba(20, 20, 20, 0.3) 0%,
            rgba(20, 20, 20, 0.7) 50%,
            rgba(20, 20, 20, 1) 100%);
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 0 60px;
    max-width: 48%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-title {
    font-size: 3.6rem;
    font-weight: 700;
    margin-bottom: 18px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
}

.hero-original-title {
    font-size: 1.4rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
    font-weight: 300;
}

.hero-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.meta-item {
    color: var(--text-secondary);
}

.hero-description {
    font-size: 1.3rem;
    line-height: 1.7;
    margin-bottom: 28px;
    max-width: 540px;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
}

.hero-actions {
    display: flex;
    gap: 16px;
}

.btn-primary,
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 38px;
    font-size: 1.4rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--text-primary);
    color: var(--background-dark);
}

.btn-secondary {
    background-color: rgba(109, 109, 110, 0.7);
    color: var(--text-primary);
}

.btn-icon {
    font-size: 1.6rem;
}

/* Content Sections */
.content-section {
    margin-bottom: 38px;
    padding: 0 48px;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.content-row {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
}

.content-row::-webkit-scrollbar {
    display: none;
}

.content-row-container {
    position: relative;
}

.content-row-container .content-row {
    padding-inline: 80px;
    padding-left: 80px;
    padding-right: 80px;
}

.section-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 108px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(20, 20, 20, 0.9) 0%, rgba(20, 20, 20, 0.7) 100%);
    border: 3px solid rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    font-size: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition-speed), border-color var(--transition-speed), background var(--transition-speed), box-shadow var(--transition-speed);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    z-index: 5;
}

.section-nav-button:hover,
.section-nav-button:focus {
    transform: translateY(-50%) scale(1.04);
    border-color: rgba(255, 255, 255, 0.7);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.06) 100%);
    box-shadow: 0 0 28px rgba(255, 255, 255, 0.4);
}

.section-nav-button:focus {
    outline: 4px solid rgba(255, 255, 255, 0.65);
    outline-offset: 8px;
}

.section-nav-button:disabled {
    opacity: 0.25;
    pointer-events: none;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(20, 20, 20, 0.6);
    box-shadow: none;
}

.section-nav-button--prev {
    right: -1.5rem;
}

.section-nav-button--next {
    left: -1.5rem;
}

.section-nav-icon {
    pointer-events: none;
}

.section-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.82), rgba(10, 10, 10, 0.6));
    color: var(--text-primary);
    font-size: 1.4rem;
    z-index: 4;
    transition: opacity var(--transition-speed);
}

.section-loading[hidden] {
    display: none;
}

.loader-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.85);
    animation: spin 1s linear infinite;
}

.section-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.78);
    color: var(--text-secondary);
    font-size: 1.3rem;
    z-index: 3;
    text-align: center;
    padding: 1.5rem;
}

.section-empty[hidden] {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --card-width: 150px;
        --card-height: 225px;
    }

    body {
        line-height: 1.5;
    }

    .search-bar-container {
        padding: 1rem 0.75rem;
    }

    .search-form {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0;
    }

    .search-input {
        font-size: 1rem;
        padding: 0.9rem 1.2rem;
        border-radius: 22px;
    }

    .search-btn {
        width: 100%;
        position: static;
        top: auto;
        left: auto;
        transform: none;
        padding: 0.95rem 1.2rem;
        font-size: 1rem;
        border-radius: 22px;
    }

    .search-btn:hover {
        transform: none;
    }

    .hero-section {
        height: auto;
        min-height: 0;
        margin-bottom: 24px;
    }

    .hero-content {
        max-width: 100%;
        padding: 24px 16px 48px;
        align-items: flex-start;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .hero-original-title {
        font-size: 1.1rem;
    }

    .hero-meta {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 1rem;
    }

    .hero-description {
        font-size: 1rem;
        max-width: none;
        margin-bottom: 20px;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .hero-actions .btn-primary,
    .hero-actions .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 1rem;
    }

    .home-refresh-indicator {
        top: 80px;
        right: 16px;
        left: 16px;
        width: calc(100% - 32px);
        justify-content: center;
    }

    .content-section {
        padding: 0 16px;
        margin-bottom: 32px;
    }

    .section-title {
        font-size: 1.6rem;
        margin-bottom: 16px;
    }

    .content-row-container .content-row {
        padding-inline: 0;
    }

    .row-wrapper {
        gap: 12px;
        padding: 8px 0 16px;
        overflow-x: auto;
    }

    .content-card {
        min-width: var(--card-width);
        max-width: var(--card-width);
        height: var(--card-height);
    }

    .card-overlay {
        padding: 12px;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-meta {
        font-size: 0.85rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 14px 24px;
        font-size: 1rem;
    }
}

@media (max-width: 1024px) {
    .content-row-container .content-row {
        padding-inline: 0;
        padding-left: 0;
        padding-right: 0;
    }

.section-nav-button {
    display: none;
}
}

@media (min-width: 769px) and (max-width: 1200px) {
    :root {
        --card-width: 180px;
        --card-height: 270px;
    }

    .hero-section {
        height: 56vh;
        min-height: 420px;
    }

    .hero-content {
        max-width: 65%;
        padding: 0 40px;
    }

    .hero-title {
        font-size: 2.6rem;
    }

    .hero-description {
        font-size: 1.1rem;
        max-width: 480px;
    }

    .hero-actions .btn-primary,
    .hero-actions .btn-secondary {
        padding: 14px 28px;
        font-size: 1.05rem;
    }

    .content-section {
        padding: 0 32px;
    }
}

.row-wrapper {
    display: flex;
    gap: 18px;
    padding: 12px 0;
    align-items: stretch;
}

.content-card-link {
    display: block;
    flex: 0 0 var(--card-width);
    flex-shrink: 0;
    width: var(--card-width);
    text-decoration: none;
}

.row-wrapper>a {
    display: block;
    margin-left:5px;
}

/* Content Cards */
.content-card {
    position: relative;
    min-width: var(--card-width);
    max-width: var(--card-width);
    width: 100%;
    height: var(--card-height);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all var(--transition-speed);
    cursor: pointer;
}

.card-poster {
    width: 100%;
    height: 100%;
    position: relative;
}

.card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
}

.poster-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--secondary-color), var(--background-darker));
    display: flex;
    align-items: center;
    justify-content: center;
}

.poster-placeholder span {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.92), transparent);
    padding: 20px 16px;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.card-info {
    color: var(--text-primary);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.25;
}

.card-rating {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Focus States for TV Navigation */
.focusable:focus {
    outline: 3px solid var(--focus-color);
    outline-offset: 6px;
    transform: scale(1.06);
    z-index: 10;
}

.content-card.focusable:focus {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.35);
}

.content-card.focusable:focus .card-overlay {
    opacity: 1;
}

.content-card.focusable:focus .card-poster img {
    transform: scale(1.05);
}

.btn-primary.focusable:focus {
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

.btn-secondary.focusable:focus {
    background-color: rgba(109, 109, 110, 0.9);
    transform: scale(1.1);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 30px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-state p {
    font-size: 1.8rem;
    color: var(--text-secondary);
}

/* Responsive for different TV sizes */
@media (max-width: 1920px) {
    .hero-title {
        font-size: 3.2rem;
    }

    .hero-description {
        font-size: 1.2rem;
    }
}

@media (max-width: 1280px) {
    .hero-content {
        padding: 0 60px;
        max-width: 60%;
    }

    .hero-title {
        font-size: 2.8rem;
    }

    .hero-section {
        height: 60vh;
        min-height: 460px;
    }

    .content-section {
        padding: 0 1rem;
    }

    :root {
        --card-width: 180px;
        --card-height: 270px;
    }

    .row-wrapper {
        gap: 14px;
    }
}

@media (min-width: 1400px) and (max-width: 1919px) {
    .hero-section {
        height: 64vh;
    }

    .hero-content {
        max-width: 52%;
        padding: 0 80px;
    }

    .hero-title {
        font-size: 3.4rem;
    }

    :root {
        --card-width: 220px;
        --card-height: 330px;
    }

    .row-wrapper {
        gap: 22px;
    }

    .content-section {
        padding: 0 80px;
    }
}

/* TV Optimizations - Large Screens */
@media (min-width: 1920px) {
    .row-wrapper {
        gap: 30px;
        /* ????? ????? ???? ???????? ???? */
    }

    .content-section {
        margin-bottom: 80px;
        padding: 0 100px;
    }

    :root {
        --card-width: 240px;
        --card-height: 350px;
    }
}

/* High contrast mode for better visibility on TV */
@media (prefers-contrast: high) {
    .focusable:focus {
        outline-width: 6px;
        outline-offset: 10px;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
