/* =========================================
   1. FONTS & VARIABLES
   ========================================= */
@font-face {
    font-family: 'NRT';
    src: url('https://www.nrttv.com/css/fonts/NRT-Reg.woff2') format('woff2');
    font-weight: normal;
}

:root {
    --primary-color: #1a365d;   /* شینی تۆخ */
    --secondary-color: #2a4365; /* شینی کاڵتر */
    --accent-color: #e53e3e;    /* سوور */
    --gold-color: #f6ad55;      /* زێڕی - بۆ فۆکەس و ئایکۆنەکان */
    --bg-color: #f7fafc;        /* پاشبنەمای گشتی */
    --text-color: #2d3748;      /* ڕەنگی نووسین */
    --card-bg: #ffffff;         /* ڕەنگی کاردەکان */
    --card-radius: 16px;        /* چەمانەوەی قەراغەکان */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --nav-height: 65px;
}

/* =========================================
   2. GLOBAL RESET
   ========================================= */
* { 
    margin: 0; padding: 0; box-sizing: border-box; 
    font-family: 'NRT', sans-serif; 
    -webkit-tap-highlight-color: transparent; 
    outline: none;
}

body { 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    direction: rtl; 
    padding-bottom: calc(var(--nav-height) + 20px); 
    overflow-x: hidden;
    user-select: none;
}

/* لابردنی دوگمە فەرمییەکانی ڤیدیۆ */
video::-webkit-media-controls { display: none !important; }
video::-webkit-media-controls-enclosure { display: none !important; }

/* =========================================
   3. HEADER STYLES
   ========================================= */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white; 
    padding: 10px 15px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 15px;
    position: sticky; top: 0; z-index: 1000; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    height: 60px;
}

.logo { 
    font-size: 18px; font-weight: bold; white-space: nowrap;
    display: flex; align-items: center; gap: 8px;
}
.logo i { color: var(--gold-color); font-size: 22px; }
.logo span { display: none; } 
@media (min-width: 380px) { .logo span { display: inline; } }

.header-search { flex: 1; position: relative; max-width: 100%; margin-right: 10px; }
.header-search input {
    width: 100%; padding: 8px 40px 8px 15px; border-radius: 25px;
    border: 2px solid transparent; 
    background: rgba(255,255,255,0.15); 
    color: white; font-size: 14px; outline: none;
    transition: all 0.3s ease; 
}
.header-search input::placeholder { color: rgba(255,255,255,0.7); }

.header-search input:focus { 
    background: rgba(255,255,255,0.25); 
    border-color: var(--gold-color);
    box-shadow: 0 0 10px rgba(246, 173, 85, 0.3);
}

.header-search i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.8); font-size: 14px; pointer-events: none; }

/* =========================================
   4. BOTTOM NAVIGATION
   ========================================= */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; width: 100%; height: var(--nav-height);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex; justify-content: space-around; align-items: center;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.2);
    z-index: 900; 
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: none; border: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px; font-weight: bold; gap: 4px;
    width: 100%; height: 100%; cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item i { font-size: 20px; margin-bottom: 2px; transition: transform 0.2s; }

/* Custom Colors for Specific Buttons */
#tvModeBtn, #logoutBtn, #reportsBtn { color: #fc8181; }
#generateCodeBtn { color: #48bb78; }

/* Active & Focus States */
.nav-item.active-nav, 
.nav-item.active-filter { 
    color: var(--gold-color) !important; 
    opacity: 1; 
    text-shadow: 0 0 12px rgba(246, 173, 85, 0.5);
}
.nav-item.active-nav i,
.nav-item.active-filter i { transform: scale(1.1); }

.nav-item:focus, 
.nav-item:focus-visible { 
    color: var(--gold-color) !important;
    outline: none; 
    transform: scale(1.15); 
    text-shadow: 0 0 15px rgba(246, 173, 85, 0.6);
    background: rgba(255, 255, 255, 0.05);
}
.nav-item:active { transform: scale(0.95); }

/* =========================================
   5. TOAST & SKELETON LOADERS
   ========================================= */
#toast-box {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 10px; z-index: 3000;
    width: 90%; max-width: 350px; pointer-events: none;
}
.toast {
    background: white; color: #333; padding: 14px 18px;
    border-radius: 12px; box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; font-weight: bold; border-right: 5px solid; 
    animation: slideUp 0.4s, fadeOut 0.5s ease 2.5s forwards; pointer-events: auto;
}
.toast.success { border-color: #48bb78; } .toast.success i { color: #48bb78; }
.toast.error { border-color: #f56565; } .toast.error i { color: #f56565; }
.toast.info { border-color: #4299e1; } .toast.info i { color: #4299e1; }

@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #edf2f7 50%, #e2e8f0 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px;
}
.skeleton-card { height: 140px; width: 100%; border-radius: 14px; }
.skeleton-text { height: 20px; width: 60%; margin: 10px auto; }

/* =========================================
   6. CARDS & SECTIONS
   ========================================= */
.category-section {
    background: var(--card-bg); margin: 15px 10px; padding: 15px; 
    border-radius: var(--card-radius); box-shadow: var(--shadow-sm);
    transition: opacity 0.3s ease;
}

.section-header { 
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px dashed #e2e8f0;
}
.section-title { font-size: 18px; font-weight: 700; color: var(--primary-color); }

.header-more-btn {
    background: rgba(49, 130, 206, 0.1); color: var(--primary-color); border: none;
    padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: bold;
    cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all 0.3s ease;
}
.header-more-btn:hover, .header-more-btn:focus { 
    background: var(--primary-color); color: white; outline: none; 
}

/* Grid Layout for Channels */
.products-container { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 8px; 
}

.product-card {
    position: relative; background: #fff; border-radius: 14px; 
    overflow: hidden; aspect-ratio: 1/1; box-shadow: var(--shadow-sm); 
    border: 2px solid #edf2f7; 
    cursor: pointer; transition: transform 0.2s, border-color 0.2s;
}
.product-card:active { transform: scale(0.96); }
.product-image { width: 100%; height: 100%; object-fit: contain; padding: 8px; background: white; }

.product-card:focus {
    outline: none;
    border: 3px solid var(--gold-color);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(246, 173, 85, 0.4);
    z-index: 10;
}

/* --- FAV ICON --- */
.fav-btn {
    position: absolute; top: 6px; left: 6px; width: 28px; height: 28px;
    background: rgba(255,255,255,0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); z-index: 10; color: #cbd5e0; transition: all 0.2s;
}
.fav-btn.active { color: var(--accent-color); transform: scale(1.1); }
.fav-btn:focus { outline: none; }

/* --- REORDER BUTTON --- */
.reorder-btn {
    position: absolute;
    top: 6px; left: 42px; /* Next to the heart icon */
    background: rgba(255, 255, 255, 0.95);
    border: none; border-radius: 8px; padding: 3px 6px;
    display: flex; align-items: center; gap: 4px;
    cursor: pointer; z-index: 15;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    color: var(--primary-color); transition: all 0.2s;
}
.reorder-btn span { font-size: 11px; font-weight: 800; font-family: sans-serif; }
.reorder-btn:hover { background: var(--gold-color); color: white; transform: scale(1.1); }

/* Admin Controls on Card */
.admin-controls {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 6px; 
    background: rgba(0,0,0,0.7); display: flex; justify-content: center; gap: 10px; opacity: 0; transition: opacity 0.2s;
}
.product-card:hover .admin-controls, .product-card:focus .admin-controls, body.admin-mode .admin-controls { opacity: 1; }
.edit-btn, .delete-btn { width: 30px; height: 30px; border-radius: 50%; border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.edit-btn { background-color: #3182ce; } .delete-btn { background-color: #e53e3e; }

/* =========================================
   7. MODALS & FORMS
   ========================================= */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; }
.modal-content { background: white; margin: 15% auto; padding: 25px; border-radius: 24px; width: 90%; max-width: 400px; animation: slideInUp 0.3s; }
@keyframes slideInUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.form-group { margin-bottom: 16px; }
.form-group input, .form-group select { width: 100%; padding: 14px; border: 2px solid #edf2f7; border-radius: 12px; font-size: 15px; background: #f8fafc; outline: none; }
.form-group input:focus, .form-group select:focus { border-color: var(--primary-color); background: white; }

button[type="submit"] { width: 100%; padding: 14px; background: var(--primary-color); color: white; border: none; border-radius: 12px; font-weight: bold; margin-bottom: 10px; cursor: pointer; }
button[type="submit"]:focus { border: 2px solid var(--gold-color); }

.close-modal-btn { width: 100%; padding: 14px; background: #edf2f7; color: #4a5568; border: none; border-radius: 12px; font-weight: bold; cursor: pointer; }

/* Score & Reports Modals */
.score-content { width: 95%; height: 90%; margin: 5% auto; max-width: 1000px; padding: 0; overflow: hidden; display: flex; flex-direction: column; background: #1a1a1a; }
.score-header { display: flex; justify-content: space-between; align-items: center; padding: 0 15px; background: var(--primary-color); color: white; height: 50px; }
.close-score-btn { background: rgba(255,255,255,0.15); border: none; color: white; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#scoreFrame { width: 100%; height: 100%; background: #fff; border: none; flex: 1; }

.reports-container { max-height: 400px; overflow-y: auto; padding: 15px; }
.report-item { background: #fff5f5; border: 1px solid #feb2b2; padding: 12px; border-radius: 8px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.fix-btn { background: #48bb78; color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

/* =========================================
   8. MOBILE PLAYER & PIP (Picture-in-Picture)
   ========================================= */
#playerModal.pip-active { background: transparent !important; pointer-events: none !important; width: 0 !important; height: 0 !important; }

.video-modal-content { 
    background: black; width: 100%; height: 100%; margin: 0; 
    display: flex; align-items: center; justify-content: center; 
    position: relative; overflow: hidden; pointer-events: auto;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1); 
}

/* PiP Styling */
.video-modal-content.pip-mode {
    position: fixed; bottom: 85px; left: 20px; width: 280px; height: 160px; 
    border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 9999; border: 2px solid rgba(255,255,255,0.1); cursor: move; touch-action: none;
}
.pip-mode .related-channels-bar, .pip-mode .maximize-btn { display: none !important; }

/* --- Video Player Fix for Grey Placeholder --- */
video { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
    /* ئەم سێ دێڕە زیادکراون بۆ لابردنی ڕەنگی ڕەساسی لە Median.co */
    background: #000 !important;
    background-color: #000 !important;
    border: none !important;
}

.click-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 201; }

.player-btn {
    position: absolute; top: 25px; color: white; background: rgba(0, 0, 0, 0.6); 
    width: 45px; height: 45px; border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    cursor: pointer; z-index: 220; font-size: 18px; opacity: 0; transition: all 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.2);
}
.player-btn:focus { border-color: var(--gold-color); background: var(--primary-color); opacity: 1; }

.video-modal-content.ui-visible .player-btn { opacity: 1; }
.close-video { right: 25px; background: rgba(229, 62, 62, 0.85); }
.maximize-btn { left: 25px; } .pip-toggle-btn { left: 80px; }

/* Related Channels Bar in Player */
.related-channels-bar {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 110px;
    display: flex; align-items: center; gap: 12px; overflow-x: auto; 
    padding: 10px 20px 30px 20px; z-index: 210; opacity: 0; transform: translateY(100%); transition: all 0.3s;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}
.video-modal-content.ui-visible .related-channels-bar { opacity: 1; transform: translateY(0); }
.related-card { min-width: 70px; height: 70px; border-radius: 14px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 4px; }
.related-card.active { border-color: var(--accent-color); }
.related-card:focus { border-color: var(--gold-color); transform: scale(1.1); }
.related-card img { width: 100%; height: 100%; object-fit: contain; }

.loader-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: black; display: flex; align-items: center; justify-content: center; z-index: 202; 
}
.spinner {
    width: 50px; height: 50px; border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%; border-top-color: var(--gold-color);
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: black; color: white; display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 205; text-align: center;
}

.add-fab { 
    position: fixed; bottom: 85px; right: 25px; width: 56px; height: 56px; 
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); 
    color: white; border-radius: 50%; display: none; align-items: center; justify-content: center; 
    z-index: 150; font-size: 24px; box-shadow: 0 4px 15px rgba(26, 54, 93, 0.4); 
    border: 2px solid white; 
}

/* =========================================
   9. TV INTERFACE STYLES (Smart TV Mode)
   ========================================= */
.tv-interface {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000; z-index: 5000; display: flex;
    direction: rtl; overflow: hidden;
}

.tv-sidebar {
    position: absolute; right: 0; top: 0; height: 100%; width: 320px;
    background: #111; 
    z-index: 5010;
    transform: translateX(100%); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 2px solid #333;
    display: flex; flex-direction: column;
}

.tv-sidebar.visible { transform: translateX(0); }

.tv-category-header {
    height: 80px; background: #0a0a0a;
    color: white; display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; font-size: 18px; font-weight: bold;
    border-bottom: 3px solid var(--gold-color);
}
.tv-category-header button { 
    background: transparent; border: none; color: white; 
    font-size: 24px; cursor: pointer; padding: 5px; border-radius: 5px;
    transition: all 0.2s ease;
}
.tv-category-header button:focus {
    background: #e53e3e; color: white !important; transform: scale(1.1); outline: none;
}

.tv-channel-list { flex: 1; overflow-y: auto; padding: 15px; scroll-behavior: smooth; }

.tv-channel-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; margin-bottom: 12px;
    background: #222; border-radius: 10px;
    color: #e2e8f0; cursor: pointer; transition: none; 
    border: 3px solid transparent;
}
.tv-channel-item span.num { background: #333; color: #cbd5e0; padding: 2px 10px; border-radius: 6px; font-size: 16px; font-weight: bold; margin-left: 15px; }
.tv-channel-item span.name { flex: 1; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Focus State for TV Remote */
.tv-channel-item.focused {
    background: var(--primary-color);
    border-color: var(--gold-color);
    transform: scale(1.05); color: white;
    box-shadow: 0 0 20px rgba(246, 173, 85, 0.4);
}
.tv-channel-item.focused span.num { background: var(--gold-color); color: #1a202c; }

.tv-player-area { width: 100%; height: 100%; position: relative; background: black; }
#tvVideoPlayer { width: 100%; height: 100%; object-fit: contain; }

.tv-maximize-btn {
    position: absolute; top: 30px; left: 30px; 
    background: rgba(0, 0, 0, 0.7); color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    width: 60px; height: 60px; border-radius: 50%;
    cursor: pointer; font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    z-index: 5020;
}
.tv-maximize-btn:hover, .tv-maximize-btn:focus {
    background: var(--gold-color); color: black; border-color: white; outline: none; transform: scale(1.1);
}

.tv-info-bar {
    position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
    width: 70%; min-width: 300px; padding: 25px 40px;
    background: rgba(10, 10, 10, 0.95);
    border-radius: 50px; color: white;
    display: flex; align-items: center; gap: 30px;
    opacity: 0; transition: opacity 0.4s ease;
    border: 2px solid #333;
    z-index: 5015;
}
.tv-info-bar.show { opacity: 1; }
.tv-ch-num { font-size: 48px; font-weight: 800; color: var(--gold-color); }
.tv-ch-details h2 { margin: 0; font-size: 32px; font-weight: bold; }
.tv-ch-details span { color: #cbd5e0; font-size: 20px; }

.tv-input-display {
    position: absolute; top: 50px; right: 50px;
    font-size: 80px; color: var(--gold-color); font-weight: bold;
    text-shadow: 4px 4px 0px #000;
    display: none; z-index: 5020;
}

.tv-loader {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; display: flex; align-items: center; justify-content: center;
    z-index: 5005;
}

@media (max-width: 768px) {
    .tv-sidebar { width: 80%; max-width: 300px; }
    .tv-maximize-btn { top: auto; bottom: 30px; left: 20px; width: 55px; height: 55px; background: rgba(229, 62, 62, 0.9); }
    .tv-info-bar { width: 90%; bottom: 100px; padding: 15px 20px; border-radius: 20px; }
    .tv-ch-num { font-size: 32px; }
    .tv-ch-details h2 { font-size: 20px; }
}