/* ==============================================
   كىپىنەك كىنوخانىسى - ئاساسىي ئۇسلۇب
   مۇكەممەل رېسپونسىۋ نۇسخا v2.0
   iPhone + Android + Desktop ماسلىشىدۇ
   ============================================== */

/* ===== فونت ===== */
@font-face {
    font-family: 'UKIJ Ekran';
    src: url('https://dilkan.ulunix.cn/Static/home/fonts/UKIJEKRAN.ttf') format('truetype');
    font-display: swap;
    font-weight: normal;
    font-style: normal;
}

/* ===== CSS ئۆزگەرگۈچىلەر ===== */
:root {
    --primary: #ff4757;
    --primary-light: #ff6348;
    --secondary: #ffa502;
    --bg-dark: #0a0a15;
    --bg-card: #151525;
    --bg-elevated: #1e1e35;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6b7280;
    --success: #2ed573;
    --gradient-primary: linear-gradient(135deg, #ff4757 0%, #ff6348 100%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --nav-height: 60px;
    --mobile-nav-height: 65px;
}

[data-theme="light"] {
    --bg-dark: #f0f2f5;
    --bg-card: #ffffff;
    --bg-elevated: #e4e6eb;
    --text-primary: #050505;
    --text-secondary: #65676b;
    --text-muted: #8a8d91;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* ===== ئاساس ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'UKIJ Ekran', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 10px);
    padding-top: 0;
}

/* ===== سىيرىلش بالدىقى ===== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,71,87,0.4);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,71,87,0.7);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,71,87,0.4) transparent;
}

/* ===== تېكىست تاللاش ===== */
::selection {
    background: rgba(255,71,87,0.3);
    color: #fff;
}

/* ===== رەسىم ===== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== كۇنۇپكىلار ===== */
.btn, button {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border: none;
    outline: none;
}

.btn:active {
    transform: scale(0.95);
}

/* ===== قاۋاق (Header) ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-dark);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    min-height: var(--nav-height);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.header-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.header-logo i {
    margin-left: 6px;
}

/* ===== ئىزدەش ===== */
.search-box {
    flex: 1;
    max-width: 500px;
    position: relative;
    border-radius: 25px;
    overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid rgba(255,255,255,0.08);
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    padding-right: 40px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

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

.search-box .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

/* ===== كاتېگورىيە كۇنۇپكىلىرى ===== */
.category-pills {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
}

.category-pills::-webkit-scrollbar {
    display: none;
}

.category-pill {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
}

.category-pill.active {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

.category-pill:active {
    transform: scale(0.95);
}

/* ===== كىنو كارتا سېتكىسى ===== */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 12px 20px;
}

/* ===== كىنو كارتا ===== */
.movie-card {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.movie-card:active {
    transform: scale(0.97);
}

/* ===== كىنو پوسېتىرى ===== */
.movie-poster {
    position: relative;
    aspect-ratio: 2/3;
    overflow: hidden;
    background: var(--bg-elevated);
}

.movie-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

/* Hover: پەقەت transform ئىشلىتىمىز، backdrop-filter ئەمەس */
.movie-card:hover .movie-poster img {
    transform: scale(1.08);
}

/* ===== قويۇش قەۋىتى (Play Overlay) ===== */
.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 10;
}

.movie-card:hover .play-overlay,
.movie-card:active .play-overlay {
    opacity: 1;
}

.play-icon {
    width: 46px;
    height: 46px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    transform: scale(0.8);
    transition: transform 0.25s ease;
}

.movie-card:hover .play-icon {
    transform: scale(1);
}

/* ===== كىنو بەلگىسى ===== */
.movie-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
}

.movie-badge.series {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.movie-badge.wxv {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.movie-badge.vip {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #000;
}

/* ===== كارتا ھەرىكەت كۇنۇپكىلىرى ===== */
.card-actions {
    position: absolute;
    bottom: 50px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 6px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s ease;
    z-index: 11;
}

.movie-card:hover .card-actions {
    opacity: 1;
    transform: translateY(0);
}

.card-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.card-action-btn:active {
    background: var(--primary);
    border-color: var(--primary);
}

/* ===== كىنو ئۇچۇرى ===== */
.movie-info {
    padding: 10px 8px;
    text-align: center;
}

.movie-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.movie-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.movie-rating {
    color: var(--secondary);
    font-weight: 600;
}

.movie-rating i {
    font-size: 0.7rem;
    margin-left: 2px;
}

/* ===== تۆۋەنكى يول بېكەت (Mobile Nav) ===== */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(21, 21, 37, 0.95);
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0;
    padding-bottom: calc(6px + var(--safe-bottom));
    z-index: 999;
    height: calc(var(--mobile-nav-height) + var(--safe-bottom));
}

.mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 8px;
    transition: color 0.2s;
    min-width: 50px;
}

.mobile-nav button i {
    font-size: 1.1rem;
}

.mobile-nav button.active {
    color: var(--primary);
}

/* ===== بوش ھالەت ===== */
.empty-state {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state.show {
    display: block;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ===== يۈكلەش ===== */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(90deg, 
        var(--bg-elevated) 25%, 
        rgba(255,255,255,0.05) 50%, 
        var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
}

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

/* ===== تېلېۋىزىيە قاناللىرى ===== */
.tv-channels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 12px 20px;
}

.tv-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.tv-card:active {
    transform: scale(0.97);
}

/* ===== ئەسكەرتىش (Toast) ===== */
.toast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(21, 21, 37, 0.95);
    border-radius: 12px;
    color: #fff;
    font-size: 0.88rem;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    transform: translateX(120%);
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
    max-width: 85vw;
    pointer-events: auto;
}

#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

/* ===== ئۈستىگە قايتۇرۇش ===== */
.back-to-top {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 20px);
    right: 16px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid rgba(255,71,87,0.3);
    color: var(--primary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:active {
    transform: scale(0.9);
}

/* ===== يورۇقلۇق تەڭشەش ===== */
.brightness-toggle {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 20px);
    left: 16px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s;
}

/* ===== بەت ئىلگىرىلەش بالدىقى ===== */
.page-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #ff4757, #ff6b9d, #ffd700);
    z-index: 999999;
    transition: width 0.15s linear;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 10px rgba(255,71,87,0.5);
}

/* ===== مودال ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== تور ھالىتى ===== */
#networkStatus {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #ff4757;
    color: #fff;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    z-index: 9999999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

/* ===== iOS سىيرىلش مۇقىمچانلىقى ===== */
@supports (-webkit-touch-callout: none) {
    .mobile-nav {
        padding-bottom: var(--safe-bottom);
    }
    
    body {
        padding-bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 10px);
    }
}

/* ===== ھەرىكەت ئازايتىش ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 320px-480px (كىچىك تېلېفون) ==================== */
@media (max-width: 359px) {
    .movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 8px 20px;
    }
    
    .movie-title {
        font-size: 0.75rem;
    }
    
    .movie-meta {
        font-size: 0.68rem;
    }
    
    .mobile-nav button {
        font-size: 0.6rem;
        padding: 3px 5px;
        min-width: 40px;
    }
    
    .mobile-nav button i {
        font-size: 1rem;
    }
    
    .category-pill {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .header {
        padding: 6px 10px;
        min-height: 50px;
    }
    
    .header-logo {
        font-size: 1.1rem;
    }
    
    .search-box input {
        font-size: 0.8rem;
        padding: 8px 12px;
        padding-right: 35px;
    }
}

/* ==================== 480px+ (ئوتتۇرا تېلېفون) ==================== */
@media (min-width: 480px) {
    .movies-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        padding: 0 16px 24px;
    }
    
    .tv-channels-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==================== 768px+ (پىلانشېت) ==================== */
@media (min-width: 768px) {
    :root {
        --mobile-nav-height: 0px;
    }
    
    body {
        padding-bottom: 20px;
        padding-right: 85px;
    }
    
    .header {
        padding: 10px 24px;
    }
    
    .mobile-nav {
        display: none;
    }
    
    .movies-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
        padding: 0 20px 30px;
    }
    
    .tv-channels-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .movie-title {
        font-size: 0.9rem;
    }
    
    .back-to-top {
        bottom: 24px;
        right: 100px;
    }
    
    .brightness-toggle {
        bottom: 24px;
        left: 24px;
    }
}

/* ==================== 1024px+ (كىچىك دېسكتاپ) ==================== */
@media (min-width: 1024px) {
    .movies-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 16px;
        padding: 0 24px 30px;
    }
    
    .tv-channels-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .movie-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    }
}

/* ==================== 1200px+ (چوڭ دېسكتاپ) ==================== */
@media (min-width: 1200px) {
    .movies-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 18px;
        max-width: 1400px;
        margin: 0 auto;
        padding: 0 32px 30px;
    }
    
    .category-pills {
        max-width: 1400px;
        margin: 0 auto;
        padding: 14px 32px;
    }
    
    .header {
        max-width: 1400px;
        margin: 0 auto;
        padding: 10px 32px;
    }
}

/* ==================== گورىزونتال مود (Landscape) ==================== */
@media (max-width: 900px) and (orientation: landscape) {
    .movies-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .mobile-nav {
        height: 50px;
    }
    
    .mobile-nav button {
        padding: 2px 6px;
    }
    
    body {
        padding-bottom: 60px;
    }
}

/* ==================== قاراڭغۇ مودا ==================== */
@media (prefers-color-scheme: dark) {
    .movie-card {
        border: 1px solid rgba(255,255,255,0.05);
    }
}