/* ============ الواجهة الأمامية - تصميم شبيه بتيك توك ============ */

:root {
    --primary: #fe2c55;
    --primary-light: #ff6b81;
    --bg: #000000;
    --bg-overlay: rgba(0,0,0,0.5);
    --text: #ffffff;
    --text-muted: rgba(255,255,255,0.7);
    --like-active: #fe2c55;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== الحاوية الرئيسية ===== */
.app {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
}

/* ===== حاوية الفيديوهات (تمرير عمودي) ===== */
.feed{
    width:100%;
    height:100vh;
    overflow-y:scroll;
    scroll-snap-type:y mandatory;
    scrollbar-width:none;
    -ms-overflow-style:none;
}

.feed::-webkit-scrollbar { display: none; }

/* ===== بطاقة الفيديو الواحدة ===== */
.video-card {
    height: 95%;
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-card video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    background: #000;
    position: relative;
    z-index: 1;
}

/* مكان الفيديو غير المحمل */
.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 15px;
    gap: 12px;
    text-align: center;
    padding: 20px;
    z-index: 0;
    background: #000;
}

.video-placeholder .ph-icon {
    font-size: 42px;
    opacity: 0.5;
}

/* ===== التدرج السفلي لقراءة النص ===== */
.video-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.video-overlay::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(transparent, rgba(0,0,0,0.65));
}

/* ===== عمود الأزرار الجانبي (يمين في RTL) ===== */
.action-bar {
    position: absolute;
    bottom: 100px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    z-index: 3;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.15s;
}

.action-btn:active { transform: scale(0.85); }

.action-btn .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(22,24,35,0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn svg {
    width: 30px;
    height: 30px;
    fill: var(--text);
}

.action-btn .count {
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* زر اللايك - حالة نشطة */
.action-btn.like .icon-wrap {
    transition: transform 0.2s;
}

.action-btn.like.active svg {
    fill: var(--like-active);
    animation: heartPop 0.4s ease;
}

@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* الدوران (صورة الناشر) */
.avatar-disc {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--text);
    overflow: hidden;
    animation: spin 6s linear infinite;
    flex-shrink: 0;
}

.avatar-disc img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== معلومات الفيديو (أسفل يسار في RTL) ===== */
.video-info {
    position: absolute;
    bottom: 90px;
    right: 76px;
    left: 16px;
    z-index: 3;
    pointer-events: auto;
}

.video-info .username {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

.video-info .title {
    font-size: 14px;
    line-height: 1.4;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== الهيدر العلوي ===== */
.app-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: linear-gradient(rgba(0,0,0,0.4), transparent);
}

.app-header .logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text);
    text-shadow: 0 1px 6px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== مؤشر التحميل المركزي ===== */
.play-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.play-indicator.show { opacity: 1; }

.play-indicator svg {
    width: 64px;
    height: 64px;
    fill: rgba(255,255,255,0.85);
    filter: drop-shadow(0 2px 10px rgba(0,0,0,0.5));
}

/* ===== قلب الضغط المزدوج ===== */
.double-tap-heart {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 5;
    pointer-events: none;
}

.double-tap-heart.show {
    animation: doubleTapHeart 0.8s ease;
}

@keyframes doubleTapHeart {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-15deg); opacity: 0; }
    15% { transform: translate(-50%, -50%) scale(1.2) rotate(5deg); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(0.95) rotate(-5deg); }
    45% { transform: translate(-50%, -50%) scale(1.05) rotate(0deg); }
    70% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
}

.double-tap-heart svg {
    width: 90px;
    height: 90px;
    fill: var(--like-active);
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
}

/* ===== شاشة التحميل الأولي ===== */
.download-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: linear-gradient(160deg, #1a0a14 0%, #0a0a0f 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 24px;
    text-align: center;
    overflow-y: auto;
}

.download-screen.hidden { display: none; }

.download-screen .ds-logo {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.download-screen .ds-icon {
    width: 90px;
    height: 90px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--primary), #ff6b81);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 12px 40px rgba(254,44,85,0.4);
}

.download-screen .ds-icon svg {
    width: 50px;
    height: 50px;
    fill: #fff;
}

.download-screen .ds-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
}

.download-screen .ds-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 30px;
    max-width: 320px;
    line-height: 1.6;
}

/* شريط التحميل الرئيسي */
.download-progress-wrap {
    width: 100%;
    max-width: 360px;
    margin-bottom: 20px;
}

.download-progress-wrap .dp-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.download-progress-wrap .dp-meta .dp-count {
    color: var(--text);
    font-weight: 600;
}

.download-progress-wrap .dp-bar {
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    overflow: hidden;
}

.download-progress-wrap .dp-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    transition: width 0.3s;
}

/* قائمة حالة كل فيديو */
.download-list {
    width: 100%;
    max-width: 360px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.download-list::-webkit-scrollbar { width: 4px; }
.download-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.download-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.download-item .di-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.download-item .di-status {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.download-item.done .di-status { color: #25d077; }
.download-item.downloading .di-status { color: var(--primary-light); }
.download-item.queued .di-status { color: var(--text-muted); }

.download-item .di-spin {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinLoader 0.8s linear infinite;
}

@keyframes spinLoader {
    to { transform: rotate(360deg); }
}

.download-item.done .di-spin { display: none; }

.download-item.done::before {
    content: '✓';
    color: #25d077;
    font-size: 16px;
    font-weight: bold;
    width: 16px;
    text-align: center;
}

.download-item.done .di-spin { width: 0; }

/* أزرار شاشة التحميل */
.download-screen .ds-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 360px;
}

.ds-btn {
    padding: 15px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.ds-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 6px 20px rgba(254,44,85,0.4);
}

.ds-btn-primary:hover { transform: translateY(-2px); }
.ds-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.ds-btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.2);
}

.ds-btn-secondary:hover { background: rgba(255,255,255,0.15); }

/* ===== رسالة "فديوهات جديدة" ===== */
.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: linear-gradient(135deg, var(--primary), #ff5577);
    color: #fff;
    padding: 14px 20px;
    padding-top: max(14px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transform: translateY(-100%);
    transition: transform 0.4s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.update-banner.show { transform: translateY(0); }

.update-banner .ub-text {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}

.update-banner .ub-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.update-banner .ub-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.update-banner .ub-btn-download {
    background: #fff;
    color: var(--primary);
}

.update-banner .ub-btn-cancel {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ===== حالة عدم وجود فيديوهات ===== */
.no-videos {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    z-index: 50;
}

.no-videos .nv-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.6; }
.no-videos .nv-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.no-videos .nv-sub { font-size: 14px; max-width: 280px; line-height: 1.6; }

/* ===== شريط التنقل السفلي (اختياري) ===== */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* شريط مسطح شفاف بدون أيقونات فعلية، فقط لتجنب تغطية المحتوى */
@media (min-width: 768px) {
    .app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,0.5); }
    .bottom-nav, .app-header { max-width: 480px; left: 50%; transform: translateX(-50%); right: auto; }
    .update-banner { max-width: 480px; left: 50%; transform: translate(-50%, -100%); }
    .update-banner.show { transform: translate(-50%, 0); }
}

/* ===== أيقونة علامة الموسيقى ===== */
.music-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.music-tag svg { width: 14px; height: 14px; fill: var(--text); flex-shrink: 0; }

.music-marquee {
    overflow: hidden;
    white-space: nowrap;
    max-width: 200px;
}

.music-marquee span {
    display: inline-block;
    animation: marquee 8s linear infinite;
}

@keyframes marquee {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* ===== شاشة التحميل الأولي للموقع ===== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.4s;
}

.loading-screen.hidden { opacity: 0; pointer-events: none; }

.loading-screen .ls-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinLoader 0.8s linear infinite;
}
.bottom-nav{
    position:fixed;
    bottom:0;
    left:0;
    width:100%;
    height:72px;
    background:rgba(0,0,0,.95);
    backdrop-filter:blur(12px);
    display:flex;
    justify-content:space-around;
    align-items:center;
    z-index:9999;
    border-top:1px solid rgba(255,255,255,.08);
}

.nav-item{
    flex:1;
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
    color:#888;
    text-decoration:none;
    font-size:11px;
    transition:.25s;
}

.nav-item svg{
    width:24px;
    height:24px;
    fill:none;
    stroke:#888;
    stroke-width:2;
    stroke-linecap:round;
    stroke-linejoin:round;
    margin-bottom:3px;
}

.nav-item.active{
    color:#fff;
}

.nav-item.active svg{
    stroke:#fff;
}

.nav-item:hover{
    color:#fff;
}

.nav-item:hover svg{
    stroke:#fff;
}

.center-btn{
    width:56px;
    height:56px;
    background:#fe2c55;
    border-radius:16px;
    margin-top:-24px;
    flex:none;
}

.center-btn svg{
    width:30px;
    height:30px;
    stroke:#fff;
}

/* ===== الشريط العلوي ===== */

.app-header{
    position:fixed;
    top:0;
    left:0;
    width:100%;
    height:60px;
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:100;
    background:linear-gradient(to bottom,
        rgba(0,0,0,.55),
        rgba(0,0,0,0));
    pointer-events:none;
}

.top-tabs{
    display:flex;
    align-items:center;
    gap:30px;
    pointer-events:auto;
}

.tab-btn{
    position:relative;
    background:none;
    border:none;
    color:rgba(255,255,255,.55);
    font-size:18px;
    font-weight:700;
    cursor:default;
    font-family:inherit;
}

.tab-btn.active{
    color:#fff;
}

.tab-line{
    position:absolute;
    bottom:-8px;
    left:50%;
    transform:translateX(-50%);
    width:26px;
    height:3px;
    background:#fff;
    border-radius:10px;
}
.install-btn{
    position:fixed;
    left:20px;
    bottom:90px;
    z-index:99999;

    background:#ff0050;
    color:#fff;
    border:none;
    border-radius:50px;
    padding:14px 20px;
    font-size:15px;
    font-weight:bold;
    cursor:pointer;

    box-shadow:0 8px 20px rgba(0,0,0,.3);
}