/* ==========================================================================
   واجهة ريلز ايوان سنتر (Front Reels - Isolated Styles)
   Prefix: .rl-* (Zero collision with front-style.css & cart-sidebar.css)
   ========================================================================== */

:root {
    --rl-primary: #19a59b;
    --rl-primary-dark: #148a81;
    --rl-bg: #070b12;
    --rl-glass: rgba(15, 23, 42, 0.48);
    --rl-glass-border: rgba(255, 255, 255, 0.16);
    --rl-text: #ffffff;
    --rl-tt-red: #fe2c55;
    --rl-tt-icon: rgba(255, 255, 255, 0.96);
    --rl-safe-top: env(safe-area-inset-top, 0px);
    --rl-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==========================================================================
   إصلاح تداخل أزرار الهاتف في التطبيق المثبّت (PWA Standalone / Fullscreen)
   ========================================================================== */
@media (max-width: 767px) and (display-mode: standalone),
       (max-width: 767px) and (display-mode: fullscreen) {
    :root {
        --rl-safe-top: max(env(safe-area-inset-top, 0px), 12px);
        --rl-safe-bottom: max(env(safe-area-inset-bottom, 0px), 52px);
    }
}

@media (max-width: 767px) {
    html.rl-pwa-mode {
        --rl-safe-top: max(env(safe-area-inset-top, 0px), 12px);
        --rl-safe-bottom: max(env(safe-area-inset-bottom, 0px), 52px);
    }
}

html.rl-html,
body.rl-body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--rl-bg);
    color: var(--rl-text);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

.rl-shell,
.rl-shell *,
.rl-shell *::before,
.rl-shell *::after {
    box-sizing: border-box;
}

.rl-nums {
    font-variant-numeric: tabular-nums;
    font-family: ui-sans-serif, system-ui, -apple-system, 'Cairo', sans-serif;
}

/* الغلاف الرئيسي لشاشة الريلز */
.rl-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: radial-gradient(circle at top, #10202b 0%, #070b12 65%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 10;
}

/* شريط الترويسة العائم (زر رجوع متوسّط بدقة أفقياً وعمودياً) */
.rl-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    padding: calc(var(--rl-safe-top) + 14px) 12px 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    pointer-events: none;
}

.rl-back-btn {
    pointer-events: auto;
    height: 34px;
    padding: 0 13px;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    color: rgba(255, 255, 255, 0.96);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    transition: background-color 0.18s ease, opacity 0.18s ease;
}

.rl-back-btn:hover {
    background: rgba(0, 0, 0, 0.48);
}

.rl-back-btn:active {
    opacity: 0.78;
}

.rl-back-btn svg {
    width: 8px;
    height: 13px;
    display: block;
    flex-shrink: 0;
}

.rl-back-btn span {
    display: block;
    line-height: 1;
    margin: 0;
    padding: 0;
    transform: translateY(-0.5px);
}

/* حاوية التقليب العمودي السريع (Scroll Snap Feed) */
.rl-feed {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
}

.rl-feed::-webkit-scrollbar {
    display: none;
}

/* بطاقة الريل الواحدة */
.rl-slide {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #05080f;
}

/* إطار الفيديو */
.rl-stage {
    position: relative;
    width: 100%;
    height: 100%;
    background: #05080f;
    overflow: hidden;
}

.rl-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    background: #05080f;
    cursor: pointer;
}

/* التدرج السفلي الناعم والمتوازن لضوح النصوص بدون تعتيم مبالغ فيه */
.rl-gradient-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.74) 0%, rgba(0, 0, 0, 0.28) 54%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
    z-index: 12;
}

/* مؤشر التحميل الخفيف والسريع بهوية المتجر */
.rl-loader {
    position: absolute;
    inset: 0;
    z-index: 14;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rl-slide.is-loading .rl-loader {
    opacity: 1;
}

.rl-spinner {
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--rl-primary);
    background: transparent;
    animation: rl-spin 0.72s linear infinite;
}

@keyframes rl-spin {
    to {
        transform: rotate(360deg);
    }
}

/* أيقونة التشغيل/الإيقاف المؤقت في المنتصف عند اللمس */
.rl-center-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    z-index: 15;
    width: 62px;
    height: 62px;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.rl-slide.is-paused .rl-center-indicator {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ==========================================================================
   عمود الأيقونات الجانبي (بدون شادو ومرفوع تلقائياً فوق أزرار الهاتف في PWA)
   ========================================================================== */
.rl-actions {
    position: absolute;
    left: 9px;
    bottom: calc(var(--rl-safe-bottom) + 124px);
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* زر فتح الصوت بخلفية بيضاء فوق أيقونة المتجر — يختفي تلقائياً فور فتح الصوت */
.rl-sound-action {
    width: 38px;
    height: 38px;
    margin-bottom: 4px;
    padding: 0;
    border-radius: 9999px;
    background: #ffffff;
    border: none;
    color: var(--rl-tt-red);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.14s ease, opacity 0.18s ease;
}

.rl-sound-action:active {
    transform: scale(0.9);
}

.rl-sound-action svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* دائرة شعار ايوان سنتر ثابتة وبدون شادو + شارة تيك توك الحمراء الفاتحة */
.rl-store-avatar-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 9px;
}

.rl-store-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    border: 1.5px solid #ffffff;
    background: #ffffff;
    display: block;
    text-decoration: none;
    box-shadow: none;
    transform: none !important;
    transition: none !important;
}

.rl-store-avatar:hover,
.rl-store-avatar:active,
.rl-store-avatar:focus {
    transform: none !important;
}

.rl-store-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 9999px;
    object-fit: cover;
    display: block;
}

.rl-store-avatar-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 19px;
    height: 19px;
    border-radius: 9999px;
    background: var(--rl-tt-red);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.rl-store-avatar-badge svg {
    width: 10.5px;
    height: 10.5px;
    display: block;
}

.rl-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.rl-action-item.is-icon-only {
    padding: 0;
}

.rl-action-btn {
    position: relative;
    width: 44px;
    height: 37px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--rl-tt-icon);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    filter: none;
    transition: transform 0.14s ease, color 0.18s ease;
}

.rl-action-btn:active {
    transform: scale(0.88);
}

.rl-action-btn.is-static {
    cursor: default;
}

.rl-action-btn.is-static:active {
    transform: none;
}

/* مقاسات أيقونات تيك توك المكبّرة والمتناسقة لجميع الشاشات */
.rl-tt-icon {
    width: 37px;
    height: 37px;
    display: block;
}

.rl-tt-icon.rl-tt-heart {
    width: 39px;
    height: 39px;
}

.rl-tt-icon.rl-tt-eye {
    width: 39px;
    height: 39px;
}

.rl-tt-icon.rl-tt-bag {
    width: 32px;
    height: 32px;
}

.rl-tt-icon.rl-tt-share {
    width: 38px;
    height: 38px;
}

.rl-action-btn.is-liked {
    color: var(--rl-tt-red);
    animation: rl-heart-pop 0.28s ease;
}

@keyframes rl-heart-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* شارة الإشعار الأحمر بدون إطار أسود وتوسيط دقيق للرقم في منتصف الدائرة */
.rl-action-badge {
    position: absolute;
    top: -1px;
    right: 3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9999px;
    background: var(--rl-tt-red);
    color: #ffffff;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: none;
    filter: none;
}

.rl-action-label {
    margin-top: -3px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.94);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    line-height: 1;
    letter-spacing: 0.1px;
}

/* ==========================================================================
   منطقة اسم المنتج والتفاصيل المختصرة وشريط السعر والطلب المباشر
   ========================================================================== */
.rl-info {
    position: absolute;
    right: 12px;
    left: 12px;
    bottom: calc(var(--rl-safe-bottom) + 22px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* مساحة ضغط العنوان والتفاصيل معزولة تماماً عن عمود الأيقونات اليساري */
.rl-text-block {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 14px;
    margin-left: 64px;
    text-decoration: none;
    color: #ffffff;
    max-width: calc(100% - 64px);
}

.rl-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.38;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.82);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.18s ease;
}

.rl-text-block:hover .rl-title {
    color: #99f6e4;
}

.rl-desc {
    margin: 0;
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.42;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.78);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* شريط السعر وزر الطلب المباشر بخلفية زجاجية خفيفة وأنيقة */
.rl-cta-bar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 14px 7px 8px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.rl-price-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding-right: 2px;
}

.rl-price-now {
    font-size: 18px;
    font-weight: 700;
    color: #5eead4;
    line-height: 1.2;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.rl-price-currency {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.86);
    margin-right: 2px;
}

.rl-price-old {
    font-size: 10.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.62);
    text-decoration: line-through;
    line-height: 1.15;
    margin-top: 1px;
}

.rl-cta-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rl-order-btn {
    height: 35px;
    padding: 0 14px;
    border-radius: 6px;
    background: linear-gradient(135deg, #19a59b 0%, #148f86 100%);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(25, 165, 155, 0.32);
    transition: opacity 0.18s ease, transform 0.12s ease;
}

.rl-order-btn:hover {
    opacity: 0.94;
}

.rl-order-btn:active {
    transform: scale(0.96);
}

.rl-order-btn.is-added {
    background: rgba(25, 165, 155, 0.26);
    border: 1px solid rgba(94, 234, 212, 0.7);
    color: #99f6e4;
    box-shadow: none;
}

.rl-order-btn.is-soldout {
    background: rgba(100, 116, 139, 0.45);
    color: rgba(255, 255, 255, 0.72);
    box-shadow: none;
    cursor: not-allowed;
}

.rl-details-btn {
    width: 35px;
    height: 35px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.rl-details-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    border-color: rgba(255, 255, 255, 0.36);
}

/* ==========================================================================
   شريط التقدم التفاعلي من اليمين إلى اليسار باللون الأبيض (مرفوع فوق أزرار الهاتف في PWA)
   ========================================================================== */
.rl-progress-track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--rl-safe-bottom);
    height: 22px;
    display: flex;
    align-items: flex-end;
    z-index: 26;
    cursor: pointer;
    touch-action: none;
    direction: rtl;
    user-select: none;
    -webkit-user-select: none;
}

.rl-progress-rail {
    position: relative;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.24);
    transition: height 0.15s ease, background-color 0.15s ease;
}

.rl-progress-track:hover .rl-progress-rail,
.rl-progress-track.is-seeking .rl-progress-rail {
    height: 6px;
    background: rgba(255, 255, 255, 0.34);
}

.rl-progress-fill {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.92);
    transition: width 0.1s linear;
}

.rl-progress-track.is-seeking .rl-progress-fill {
    background: #ffffff;
    transition: none;
}

.rl-progress-thumb {
    position: absolute;
    left: -6px;
    right: auto;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    border-radius: 9999px;
    background: #ffffff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
    transition: transform 0.14s ease;
    pointer-events: none;
}

.rl-progress-track:hover .rl-progress-thumb,
.rl-progress-track.is-seeking .rl-progress-thumb {
    transform: translateY(-50%) scale(1);
}

.rl-progress-time {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    border-radius: 9999px;
    background: rgba(10, 15, 26, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    direction: ltr;
}

.rl-progress-track.is-seeking .rl-progress-time {
    opacity: 1;
}

/* إشعار ناعم لنسخ رابط المشاركة فقط */
.rl-toast {
    position: fixed;
    top: calc(var(--rl-safe-top) + 58px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px) scale(0.96);
    z-index: 40;
    max-width: min(86vw, 320px);
    padding: 9px 16px;
    border-radius: 10px;
    background: rgba(22, 24, 35, 0.84);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: rgba(255, 255, 255, 0.96);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1), transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.rl-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* أسهم التنقل السريع لشاشات الكمبيوتر فقط */
.rl-desktop-nav {
    display: none;
}

/* روابط السيو الداخلية المخفية بصرياً بأسلوب متوافق مع محركات البحث */
.rl-seo-links {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   تجاوب شاشات الكمبيوتر والتابلت (Desktop 9:16 Centered Frame - Zero Clipping)
   ========================================================================== */
@media (min-width: 768px) {
    .rl-topbar {
        padding: 18px 24px 0;
    }

    .rl-slide {
        padding: 20px 16px;
        background: transparent;
    }

    .rl-stage {
        height: min(820px, calc(100dvh - 40px));
        width: min(410px, calc((100dvh - 40px) * 9 / 16), calc(100vw - 140px));
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
    }

    .rl-actions {
        left: 10px;
        bottom: 128px;
        gap: 9px;
    }

    .rl-store-avatar {
        width: 46px;
        height: 46px;
    }

    .rl-title {
        font-size: 15.5px;
    }

    .rl-desc {
        font-size: 12px;
    }

    .rl-toast {
        top: 34px;
    }

    .rl-desktop-nav {
        position: fixed;
        left: 28px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 30;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .rl-nav-arrow {
        width: 44px;
        height: 44px;
        border-radius: 9999px;
        background: var(--rl-glass);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid var(--rl-glass-border);
        color: #ffffff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.14s ease;
    }

    .rl-nav-arrow:hover {
        background: rgba(25, 165, 155, 0.35);
        border-color: var(--rl-primary);
        transform: scale(1.06);
    }

    .rl-nav-arrow:disabled {
        opacity: 0.3;
        cursor: not-allowed;
        transform: none;
    }
}