/*
 * Storefront Theme 2 — Linen
 * ألوان ثابتة هادئة — لا تعتمد على هوية التاجر
 * v4 complete rewrite
 */

*,
*::before,
*::after { box-sizing: border-box; }

/* ── TOKENS ─────────────────────────────────── */
:root {
    --ln-bg:           #F6F2EC;
    --ln-bg-2:         #EDE8DF;
    --ln-surface:      #FFFFFF;
    --ln-border:       #DDD8CF;
    --ln-border-2:     #EAE6DE;
    --ln-ink:          #1C1714;
    --ln-ink-2:        #5C5650;
    --ln-ink-3:        #9E9790;
    --ln-accent:       #3A7057;
    --ln-accent-2:     #27563F;
    --ln-accent-light: #E6F1EC;
    --ln-red:          #C44C2A;
    --ln-amber:        #B5800C;
    --ln-sh-sm:        0 1px 4px rgba(0,0,0,.07), 0 2px 12px rgba(0,0,0,.05);
    --ln-sh-md:        0 4px 20px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
    --ln-sh-lg:        0 8px 40px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.07);
    --ln-r-sm:         10px;
    --ln-r-md:         16px;
    --ln-r-lg:         22px;
    --ln-r-xl:         32px;
    --ln-t:            0.2s cubic-bezier(.4,0,.2,1);
}

/* ── BODY ───────────────────────────────────── */
body {
    background-color: var(--ln-bg) !important;
    color: var(--ln-ink) !important;
    font-family: "DM Sans", "Noto Sans Arabic", system-ui, sans-serif !important;
    padding-bottom: 0 !important;
    overflow-x: clip; /* clip لا يكسر position:sticky على iOS (عكس hidden) */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 0; height: 0; }

/* ── HEADER ─────────────────────────────────── */
.ln-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--ln-surface);
    border-bottom: 1px solid var(--ln-border-2);
    box-shadow: 0 1px 14px rgba(0,0,0,.07);
}

.ln-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 58px;
    gap: 8px;
    max-width: 880px;
    margin-inline: auto;
}

.ln-header__account {
    flex-shrink: 0;
    width: 3rem;
    font-size: 0.76rem;
    color: var(--ln-ink-2);
}

.ln-header__brand {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ln-header__brand .header-store-logo {
    max-height: 38px;
    max-width: min(200px, 52vw);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.ln-store-name {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--ln-ink);
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ln-header__actions {
    flex-shrink: 0;
    width: 3rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* ── SEARCH BAR ──────────────────────────────── */
.ln-search-wrap {
    display: none;
    background: var(--ln-surface);
    border-bottom: 1px solid var(--ln-border-2);
    padding: 10px 16px;
}

.ln-search-bar {
    width: 100%;
    padding: 11px 18px;
    border-radius: 50px;
    border: 1.5px solid var(--ln-border);
    background: var(--ln-bg);
    color: var(--ln-ink);
    font-size: .9rem;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    transition: border-color var(--ln-t);
}

.ln-search-bar:focus { border-color: var(--ln-accent); }
.ln-search-bar::placeholder { color: var(--ln-ink-3); }

/* ── CONTENT WRAPPER ─────────────────────────── */
.ln-content {
    padding: 16px 16px 100px;
    max-width: 880px;
    margin-inline: auto;
}

/* ── SLIDER ──────────────────────────────────── */
.ln-swiper {
    width: 100%;
    height: 176px;
    border-radius: var(--ln-r-lg);
    overflow: hidden;
    margin-bottom: 22px;
    box-shadow: var(--ln-sh-md);
}

.ln-swiper .swiper-slide {
    background: var(--ln-bg-2);
    border-radius: var(--ln-r-lg);
    overflow: hidden;
}

.ln-swiper .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ln-swiper .swiper-pagination-bullet {
    background: rgba(255,255,255,.5) !important;
    opacity: 1 !important;
    width: 6px;
    height: 6px;
    transition: width .2s, border-radius .2s;
}

.ln-swiper .swiper-pagination-bullet-active {
    background: #fff !important;
    width: 18px;
    border-radius: 3px;
}

@media (min-width: 600px) {
    .ln-swiper { height: 250px; }
}

/* ── SECTION TITLE ───────────────────────────── */
.ln-section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ln-ink-3);
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ln-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--ln-border);
}

[dir="rtl"] .ln-section-title {
    text-transform: none;
    letter-spacing: .02em;
    font-size: .82rem;
}

/* ── CATEGORY CHIPS ──────────────────────────── */
.ln-cat-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 26px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ln-cat-scroll::-webkit-scrollbar { display: none; }

.ln-cat-chip {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    background: var(--ln-surface);
    border: 1.5px solid var(--ln-border-2);
    border-radius: var(--ln-r-md);
    padding: 10px 12px 9px;
    cursor: pointer;
    min-width: 70px;
    box-shadow: var(--ln-sh-sm);
    touch-action: manipulation;
    transition: border-color var(--ln-t), box-shadow var(--ln-t), transform var(--ln-t);
    -webkit-tap-highlight-color: transparent;
}

.ln-cat-chip:active { transform: scale(.93); }

.ln-cat-chip.active,
.ln-cat-chip:hover {
    border-color: var(--ln-accent);
    box-shadow: 0 0 0 3px var(--ln-accent-light), var(--ln-sh-sm);
}

.ln-cat-chip__img {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--ln-bg);
    flex-shrink: 0;
}

.ln-cat-chip__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ln-cat-chip__label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--ln-ink-2);
    text-align: center;
    max-width: 68px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.ln-cat-chip.active .ln-cat-chip__label { color: var(--ln-accent); }

/* ── PRODUCT GRID ────────────────────────────── */
.ln-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (min-width: 560px) {
    .ln-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

@media (min-width: 860px) {
    .ln-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

/* ── PRODUCT CARD ────────────────────────────── */
.ln-card {
    background: var(--ln-surface);
    border-radius: var(--ln-r-md);
    border: 1px solid var(--ln-border-2);
    box-shadow: var(--ln-sh-sm);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    touch-action: manipulation;
    transition: transform var(--ln-t), box-shadow var(--ln-t);
    -webkit-tap-highlight-color: transparent;
}

.ln-card:active { transform: scale(.974); }

@media (hover: hover) and (pointer: fine) {
    .ln-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--ln-sh-md);
    }
}

.ln-card__img {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: var(--ln-bg-2);
    overflow: hidden;
    flex-shrink: 0;
}

.ln-card__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
    display: block;
}

@media (hover: hover) and (pointer: fine) {
    .ln-card:hover .ln-card__img img { transform: scale(1.06); }
}

.ln-card__badge {
    position: absolute;
    inset-inline-end: 8px;
    top: 8px;
    background: var(--ln-red);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: .02em;
    white-space: nowrap;
    line-height: 1.5;
}

.ln-card__body {
    padding: 10px 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 7px;
}

.ln-card__name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--ln-ink);
    line-height: 1.38;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.3em;
}

.ln-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: wrap;
}

.ln-card__price {
    font-size: .9rem;
    font-weight: 800;
    color: var(--ln-accent);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.ln-card__add {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ln-accent);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: background var(--ln-t), transform .15s;
    touch-action: manipulation;
    pointer-events: none;
}

.ln-card:active .ln-card__add {
    transform: scale(.88);
    background: var(--ln-accent-2);
}

/* ── VIEW HEADER (back row) ──────────────────── */
.ln-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 10px;
}

.ln-view-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ln-ink);
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ln-back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ln-surface);
    border: 1.5px solid var(--ln-border);
    color: var(--ln-ink-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    cursor: pointer;
    touch-action: manipulation;
    flex-shrink: 0;
    transition: background var(--ln-t);
}

.ln-back-btn:hover { background: var(--ln-bg-2); }

/* ── BOTTOM NAV ──────────────────────────────── */
.ln-bottomnav {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 800;
    background: var(--ln-surface);
    border-top: 1px solid var(--ln-border-2);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 24px rgba(0,0,0,.08);
}

.ln-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px;
    background: none;
    border: none;
    color: var(--ln-ink-3);
    font-size: .6rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    touch-action: manipulation;
    font-family: inherit;
    letter-spacing: .02em;
    transition: color var(--ln-t);
    -webkit-tap-highlight-color: transparent;
}

.ln-nav-item i {
    font-size: 1.2rem;
    line-height: 1;
}

.ln-nav-item.active { color: var(--ln-accent); }

.ln-nav-item.active i {
    filter: drop-shadow(0 0 8px rgba(58,112,87,.35));
}

.ln-nav-item span[id="dock-cart-badge"] {
    position: absolute;
    top: 8px;
    inset-inline-end: calc(50% - 20px);
    background: var(--ln-red);
    color: #fff;
    font-size: .6rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ln-surface);
    padding: 0 2px;
    line-height: 1;
    pointer-events: none;
}

/* ── PRODUCT MODAL SHEET ─────────────────────── */
#itemSheet .modal-dialog.modal-fullscreen-sm-down {
    align-items: flex-end;
    margin: 0;
}

#itemSheet .modal-content {
    background: var(--ln-surface);
    color: var(--ln-ink);
    border-radius: 26px 26px 0 0;
    border: none;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    margin: 0 auto;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 -8px 40px rgba(0,0,0,.15);
}

.ln-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--ln-border);
    margin: 12px auto 8px;
}

.ln-sheet-body { padding: 0 18px 24px; }

.ln-product-img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: 18px;
    display: block;
    background: var(--ln-bg-2);
    margin-bottom: 14px;
}

.ln-modal-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ln-ink);
    margin: 0 0 4px;
    line-height: 1.3;
}

.ln-modal-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ln-accent);
    margin: 0 0 3px;
}

.ln-modal-price-total {
    font-size: .78rem;
    font-weight: 600;
    color: var(--ln-ink-3);
    margin-bottom: 16px;
    min-height: 1em;
}

.ln-field-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--ln-ink-2);
    letter-spacing: .04em;
    margin-bottom: 6px;
    display: block;
}

.ln-form-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--ln-r-sm);
    border: 1.5px solid var(--ln-border);
    background: var(--ln-bg);
    color: var(--ln-ink);
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    margin-bottom: 14px;
    appearance: none;
    -webkit-appearance: none;
}

.ln-form-select:focus { border-color: var(--ln-accent); }

.ln-addon-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--ln-r-sm);
    border: 1.5px solid var(--ln-border-2);
    background: var(--ln-bg);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color var(--ln-t), background var(--ln-t);
}

.ln-addon-row:has(input:checked) {
    border-color: var(--ln-accent);
    background: var(--ln-accent-light);
}

.ln-addon-price {
    font-weight: 700;
    font-size: .8rem;
    color: var(--ln-accent);
}

.ln-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ln-bg);
    border-radius: var(--ln-r-sm);
    padding: 10px 14px;
    margin-bottom: 12px;
}

.ln-qty-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--ln-ink-2);
}

.ln-qty-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ln-qty-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--ln-border);
    background: var(--ln-surface);
    color: var(--ln-ink);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: background var(--ln-t), border-color var(--ln-t);
}

.ln-qty-btn:active { background: var(--ln-bg-2); border-color: var(--ln-ink-2); }

.ln-qty-val {
    font-weight: 900;
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
}

.ln-wishlist-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 13px;
    border-radius: var(--ln-r-md);
    border: 1.5px solid var(--ln-border);
    background: var(--ln-surface);
    color: var(--ln-ink-2);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    touch-action: manipulation;
    font-family: inherit;
    transition: border-color var(--ln-t), color var(--ln-t);
}

.ln-wishlist-btn:hover { border-color: var(--ln-accent); color: var(--ln-accent); }

.ln-add-btn {
    width: 100%;
    padding: 15px;
    border-radius: var(--ln-r-md);
    border: none;
    background: var(--ln-accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    touch-action: manipulation;
    transition: background var(--ln-t);
    font-family: inherit;
}

.ln-add-btn:active { background: var(--ln-accent-2); }

.ln-modal-x {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ln-bg);
    border: 1px solid var(--ln-border);
    color: var(--ln-ink-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .9rem;
    z-index: 10;
    touch-action: manipulation;
}

/* ── CART DRAWER ─────────────────────────────── */
#cartDrawer {
    background: var(--ln-surface) !important;
    border-radius: 0 0 26px 26px !important;
    box-shadow: 0 10px 50px rgba(0,0,0,.18) !important;
    height: auto !important;
    max-height: 80vh !important;
    border: none !important;
}

#cartDrawer .offcanvas-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--ln-border-2) !important;
    color: var(--ln-ink);
}

#cartDrawer .offcanvas-header .btn-close { opacity: .45; }

#cartDrawer .offcanvas-body {
    padding: 14px 18px;
    background: var(--ln-surface);
}

.ln-cart-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--ln-r-sm);
    background: var(--ln-bg);
    border: 1px solid var(--ln-border-2);
    margin-bottom: 10px;
}

.ln-cart-row img {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--ln-bg-2);
    flex-shrink: 0;
}

.ln-cart-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--ln-ink);
    line-height: 1.35;
}

.ln-cart-meta {
    font-size: .7rem;
    color: var(--ln-ink-3);
    margin-top: 2px;
}

.ln-cart-price {
    font-size: .8rem;
    font-weight: 700;
    color: var(--ln-accent);
    margin-top: 3px;
}

.ln-cart-qty-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ln-cart-qty-btn {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    border: 1.5px solid var(--ln-border);
    background: var(--ln-surface);
    color: var(--ln-ink);
    font-weight: 700;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: background var(--ln-t);
}

.ln-cart-qty-btn:active { background: var(--ln-bg-2); }

.ln-cart-footer {
    padding: 14px 18px 18px;
    border-top: 1px solid var(--ln-border-2);
    background: var(--ln-surface);
}

.ln-cart-total-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--ln-ink-2);
}

.ln-cart-total-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ln-accent);
}

.ln-cart-checkout-btn {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border-radius: var(--ln-r-md);
    border: none;
    background: var(--ln-accent);
    color: #fff;
    font-size: .95rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    transition: background var(--ln-t);
}

.ln-cart-checkout-btn:active { background: var(--ln-accent-2); }

/* ── EMPTY STATE ─────────────────────────────── */
.ln-empty {
    text-align: center;
    padding: 52px 20px;
    color: var(--ln-ink-3);
    font-size: .9rem;
    font-weight: 500;
    grid-column: 1 / -1;
}

.ln-empty i {
    display: block;
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: .4;
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 380px) {
    .ln-card__name   { font-size: .77rem; }
    .ln-card__price  { font-size: .84rem; }
    .ln-cat-chip     { min-width: 64px; padding: 8px 10px 8px; }
    .ln-cat-chip__img { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
