/* ============================================================================
   iMiCharm — Compact Luxury Header & Top Instagram Stories
   Shared across index.php & category.php (Cached 30d)
   ============================================================================ */

/* إصلاح تقطّع الحروف العربية في متصفح iPhone Safari وتوحيد الخط مع الكمبيوتر */
html[lang="ar"] body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    font-feature-settings: "liga" 1, "calt" 1;
    -webkit-font-smoothing: antialiased;
}

html[lang="ar"] body,
html[lang="ar"] body *:not(.imi-brand-name):not(.logo-text) {
    letter-spacing: 0 !important;
}

/* ---------- 1. Compact Space-Saving Header ---------- */
.imi-hdr {
    position: sticky;
    top: 0;
    z-index: 95;
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #ecebe8;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

.imi-hdr-inner {
    max-width: 1400px;
    margin: 0 auto;
    height: 44px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.imi-brand-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
    color: #0f1626;
    padding: 4px 8px;
    border-radius: 8px;
    transition: opacity 0.2s ease;
}

.imi-brand-link:hover {
    opacity: 0.78;
}

.imi-brand-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.imi-brand-name {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    line-height: 1;
    color: #0f1626;
}

/* ---------- 2. Top Stories Bar (Replaces Old Nav Bar) ---------- */
.imi-stories-bar {
    background: #ffffff;
    border-bottom: 1px solid #ecebe8;
    padding: 6px 10px 8px;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

.imi-stories-title {
    text-align: center;
    font-family: 'Cairo', sans-serif;
    font-size: 42px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1.25;
    margin: 2px 0 8px;
    letter-spacing: 0;
}

@media (max-width: 768px) {
    .imi-stories-title {
        font-size: 22px;
        margin: 0 0 6px;
    }
}

@media (max-width: 480px) {
    .imi-stories-title {
        font-size: 20px;
        margin: 0 0 5px;
    }
}

/* تقليص الفراغ العلوي لقسم المنتجات مباشرة أسفل شريط الستوريات لتوفير المساحة */
.imi-stories-bar ~ .section-header,
.imi-hdr ~ .section-header {
    padding-top: 22px;
    padding-bottom: 12px;
}

@media (max-width: 768px) {
    .imi-stories-bar ~ .section-header,
    .imi-hdr ~ .section-header {
        padding-top: 12px;
        padding-bottom: 6px;
    }
}

.imi-stories-track {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2px 4px;
    justify-content: flex-start;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
}

.imi-stories-track::-webkit-scrollbar {
    display: none;
}

@media (min-width: 769px) {
    .imi-hdr-inner {
        height: 52px;
        padding: 0 24px;
    }

    .imi-brand-logo {
        width: 26px;
        height: 26px;
    }

    .imi-brand-name {
        font-size: 14.5px;
    }

    .imi-stories-bar {
        padding: 10px 20px 11px;
    }

    .imi-stories-track {
        justify-content: center;
        gap: 16px;
    }
}

.ig-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    gap: 6px;
    width: 72px;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    line-height: normal;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.ig-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(225deg, #feda75 0%, #fa7e1e 28%, #d62976 55%, #962fbf 80%, #4f5bd5 100%);
    padding: 2.5px;
    box-sizing: border-box;
    transition: transform 0.18s ease, background 0.25s ease;
    box-shadow: 0 2px 8px rgba(214, 41, 118, 0.14);
}

.ig-thumb.is-seen .ig-ring {
    background: #d4d4d8;
    box-shadow: none;
}

.ig-thumb:hover .ig-ring {
    transform: scale(1.05);
}

.ig-thumb:active .ig-ring {
    transform: scale(0.93);
}

.ig-ava {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid #ffffff;
    background: #f5f5f3;
    box-sizing: border-box;
    flex-shrink: 0;
}

.ig-ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.ig-thumb p {
    display: block;
    font-family: 'Cairo', sans-serif;
    font-size: 11px;
    color: #262626;
    max-width: 72px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    line-height: 1.3;
    font-weight: 600;
}

/* ---------- 4. Instagram-Exact Full-Screen Story Viewer ---------- */
.ig-m {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0d0d0f;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.ig-m.on {
    display: flex;
}

.ig-m-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.ig-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 2;
    position: relative;
    height: calc(100vh - 36px);
    height: calc(100dvh - 36px);
    max-height: 880px;
}

.ig-side {
    width: 280px;
    height: 76%;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.25s ease, transform 0.25s ease;
    background: #1c1c1f;
    flex-shrink: 0;
    position: relative;
    opacity: 0.55;
}

.ig-side:hover {
    opacity: 0.78;
    transform: scale(1.02);
}

.ig-side .ig-side-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
}

.ig-side .ig-side-blur {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.36);
    z-index: 1;
}

.ig-side .ig-side-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    text-align: center;
    pointer-events: none;
}

.ig-side .ig-side-logo img {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.ig-side .ig-side-logo span {
    display: block;
    color: #fff;
    font-family: 'Cairo', sans-serif;
    font-size: 12px;
    font-weight: 700;
    margin-top: 8px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.ig-side.hidden {
    visibility: hidden;
    pointer-events: none;
}

.ig-card {
    position: relative;
    width: min(430px, 92vw);
    flex-shrink: 0;
    height: 100%;
    background: #000000;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
    z-index: 3;
}

.ig-card.anim-l {
    animation: igSlideNext 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.ig-card.anim-r {
    animation: igSlidePrev 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes igSlideNext {
    0% { transform: translateX(-22px); opacity: 0.65; }
    100% { transform: none; opacity: 1; }
}

@keyframes igSlidePrev {
    0% { transform: translateX(22px); opacity: 0.65; }
    100% { transform: none; opacity: 1; }
}

/* Full-bleed blurred backdrop + smart foreground image */
.ig-card-bg {
    position: absolute;
    inset: -18px;
    background-size: cover;
    background-position: center;
    filter: blur(26px) brightness(0.45);
    transform: scale(1.08);
    z-index: 0;
}

.ig-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    display: block;
}

.ig-img.is-contain {
    object-fit: contain;
}

/* Top dark scrim for crisp legibility over bright screenshots */
.ig-top-scrim {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.32) 55%, transparent 100%);
    z-index: 18;
    pointer-events: none;
}

.ig-bars {
    display: flex;
    gap: 4px;
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    z-index: 22;
}

.ig-bar {
    flex: 1;
    height: 2.5px;
    background: rgba(255, 255, 255, 0.34);
    border-radius: 99px;
    overflow: hidden;
}

.ig-bar-f {
    height: 100%;
    width: 0;
    background: #ffffff;
    border-radius: 99px;
    will-change: width;
}

.ig-bar.d .ig-bar-f {
    width: 100% !important;
}

.ig-head {
    position: absolute;
    top: calc(20px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 25;
}

.ig-head-l {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.ig-head-pic {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: #262626;
    flex-shrink: 0;
}

.ig-head-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ig-head-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.ig-head-name {
    color: #ffffff;
    font-family: 'Cairo', sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-head-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.16);
    padding: 1px 7px;
    border-radius: 999px;
    flex-shrink: 0;
}

.ig-head-r {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ig-xbtn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.34);
    border: none;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: background-color 0.16s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.ig-xbtn:hover {
    background: rgba(0, 0, 0, 0.58);
}

.ig-xbtn:active {
    transform: scale(0.92);
}

/* إخفاء ناعم للشريط العلوي أثناء الضغط المطوّل للقراءة بوضوح مثل إنستغرام */
.ig-card.is-holding .ig-head,
.ig-card.is-holding .ig-bars,
.ig-card.is-holding .ig-top-scrim {
    opacity: 0;
    transition: opacity 0.18s ease;
}

/* Tap zones: وسط الشاشة لإيقاف/استئناف، الحواف للتنقل (يسار = التالي، يمين = السابق) */
.ig-tap-l {
    position: absolute;
    top: 76px;
    left: 0;
    bottom: 0;
    width: 22%;
    z-index: 15;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ig-tap-c {
    position: absolute;
    top: 76px;
    left: 22%;
    right: 22%;
    bottom: 0;
    z-index: 15;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ig-tap-r {
    position: absolute;
    top: 76px;
    right: 0;
    bottom: 0;
    width: 22%;
    z-index: 15;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Prev/Next Navigation Arrows (Visible on BOTH Desktop & Mobile!) */
.ig-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 35;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.92);
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32);
    transition: transform 0.16s ease, background-color 0.16s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.ig-arrow:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.07);
}

.ig-arrow:active {
    transform: translateY(-50%) scale(0.92);
}

.ig-arrow svg {
    width: 20px;
    height: 20px;
}

.ig-arrow svg path {
    stroke: currentColor;
    stroke-width: 2.5;
}

.ig-arrow-l {
    left: calc(50% - 268px);
}

.ig-arrow-r {
    right: calc(50% - 268px);
}

.ig-arrow.hidden {
    display: none;
}

/* ---------- 5. TRUE FULL-SCREEN MOBILE EXPERIENCE (Instagram Native!) ---------- */
@media (max-width: 768px) {
    .ig-m {
        background: #000000;
    }

    .ig-carousel {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        gap: 0;
        padding: 0;
    }

    .ig-side {
        display: none !important;
    }

    .ig-card {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* Crisp floating Instagram arrows inside full-screen mobile view */
    .ig-arrow {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.42);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.32);
        color: #ffffff;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
    }

    .ig-arrow:hover {
        background: rgba(0, 0, 0, 0.62);
        color: #ffffff;
    }

    .ig-arrow-l {
        left: 10px;
    }

    .ig-arrow-r {
        right: 10px;
    }
}

@media (max-width: 480px) {
    .ig-thumb {
        width: 64px;
    }

    .ig-ring {
        width: 58px;
        height: 58px;
    }

    .ig-thumb p {
        font-size: 10.5px;
        max-width: 64px;
    }
}

/* ============================================================================
   Unified Luxury Product Cards (Name Above Image + Larger Harmonious CTA)
   Shared across index.php & category.php
   ============================================================================ */
.products-grid .product-card {
    background: #ffffff;
    border: 1px solid #ecebe8;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.products-grid .product-card:hover {
    border-color: #d7d5ce;
    box-shadow: 0 14px 32px -18px rgba(15, 22, 38, 0.24);
    transform: translateY(-2px);
}

.product-card-head {
    padding: 12px 12px 10px;
    background: #ffffff;
    border-bottom: 1px solid #f2f1ee;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
}

.products-grid .product-card-head .product-name {
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #141414;
    line-height: 1.35;
    margin: 0;
    text-transform: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.products-grid .product-card .product-image {
    margin-bottom: 0;
    background: #f6f6f4;
    border-radius: 0;
}

.products-grid .product-card .product-info {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
    background: #ffffff;
    text-align: center;
}

.products-grid .product-card .product-price {
    margin-bottom: 12px;
    gap: 8px;
}

.products-grid .product-card .current-price {
    font-family: 'Cairo', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: #0f1626;
}

.products-grid .product-card .original-price {
    font-size: 13.5px;
    color: #9ca3af;
}

/* زر اطلب الآن — كبير وواضح ومنسجم مع هوية المتجر الفاخرة */
.products-grid .product-card .buy-btn {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 56px;
    padding: 14px 22px;
    border-radius: 12px;
    font-family: 'Cairo', sans-serif;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    text-transform: none;
    box-shadow: 0 10px 22px -10px rgba(15, 22, 38, 0.46);
    transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.2s ease;
}

.products-grid .product-card .buy-btn i {
    margin: 0;
    font-size: 15px;
    transition: transform 0.2s ease;
}

.products-grid .product-card .buy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 26px -10px rgba(15, 22, 38, 0.54);
}

.products-grid .product-card .buy-btn:hover i {
    transform: translateX(-3px);
}

.products-grid .product-card .buy-btn:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .products-grid .product-card {
        border-radius: 12px;
    }

    .product-card-head {
        padding: 8px 7px 7px;
        min-height: 44px;
    }

    .products-grid .product-card-head .product-name {
        font-size: 13px;
        line-height: 1.3;
    }

    .products-grid .product-card .product-info {
        padding: 9px 8px 10px;
    }

    .products-grid .product-card .product-price {
        margin-bottom: 10px;
        gap: 6px;
    }

    .products-grid .product-card .current-price {
        font-size: 15.5px;
    }

    .products-grid .product-card .original-price {
        font-size: 12px;
    }

    .products-grid .product-card .buy-btn {
        min-height: 50px;
        padding: 12px 12px;
        font-size: 16.5px;
        font-weight: 800;
        border-radius: 11px;
        gap: 7px;
    }

    .products-grid .product-card .buy-btn i {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .product-card-head {
        padding: 7px 6px 6px;
        min-height: 42px;
    }

    .products-grid .product-card-head .product-name {
        font-size: 12.5px;
    }

    .products-grid .product-card .product-info {
        padding: 8px 7px 9px;
    }

    .products-grid .product-card .buy-btn {
        min-height: 48px;
        padding: 11px 10px;
        font-size: 16px;
        font-weight: 800;
        border-radius: 10px;
    }

    .products-grid .product-card .buy-btn i {
        font-size: 13.5px;
    }
}
