/* Customer-facing warehouse magazine (مجله موجودی).
   Colours come from the site theme tokens in template.css so light/dark both work. */

.wm-page {
    padding-bottom: 24px;
}

/* The page lives in a `.container p-0`, so there is no parent padding to absorb a
   Bootstrap row's negative gutter and the grid ends up wider than the viewport.
   Zero the row gutter and let the columns' own `px-2` do the spacing instead. */
.wm-page .row-category {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ---------- header ---------- */

.wm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px 22px;
    margin-bottom: 16px;
    border: 1px solid var(--border-card);
    border-radius: 18px;
    background-color: var(--bg-card);
    color: var(--color-text);
}

.wm-header__text {
    min-width: 0;
}

.wm-header__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.6;
    color: var(--color-text);
}

.wm-header__subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.9;
    color: var(--color-icon);
}

.wm-header__count {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    background-color: var(--bg-body);
}

.wm-header__count-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--red-100);
}

.wm-header__count-label {
    font-size: 12px;
    color: var(--color-icon);
}

/* ---------- toolbar ---------- */

.wm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.wm-chips {
    display: flex;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.wm-chips::-webkit-scrollbar {
    display: none;
}

.wm-chip {
    flex: 0 0 auto;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--color-text);
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.wm-chip:hover {
    border-color: var(--red-100);
}

.wm-chip.is-active {
    color: #fff;
    background-color: var(--red-100);
    border-color: var(--red-100);
}

.wm-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- availability switch ---------- */

.wm-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.wm-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wm-switch__track {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background-color: var(--tab-color);
    transition: background-color .18s ease;
}

.wm-switch__thumb {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #fff;
    transition: transform .18s ease;
}

.wm-switch input:checked + .wm-switch__track {
    background-color: var(--red-100);
}

.wm-switch input:checked + .wm-switch__track .wm-switch__thumb {
    transform: translateX(-18px);
}

.wm-switch input:focus-visible + .wm-switch__track {
    outline: 2px solid var(--red-100);
    outline-offset: 2px;
}

.wm-switch__label {
    font-size: 13px;
    color: var(--color-text);
}

/* ---------- sort ---------- */

.wm-sort {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.wm-sort__label {
    font-size: 13px;
    color: var(--color-icon);
}

.wm-sort__select {
    max-width: 100%;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    color: var(--color-text);
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    cursor: pointer;
}

.wm-sort__select:focus {
    outline: none;
    border-color: var(--red-100);
}

/* ---------- product item ---------- */

.wm-item {
    position: relative;
    height: 100%;
}

/* Sits above the card, not on it: the card's own corners are already taken by the
   discount/blue/green labels (top-left) and the hover add-to-cart button (top-right). */
.wm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text);
    background-color: var(--bg-body);
    border: 1px solid var(--border-card);
    border-radius: 999px;
}

.wm-badge i {
    font-size: 11px;
    color: var(--red-100);
}

/* ---------- product card overrides (scoped to this page) ----------
   The shared card forces `.img-pro img { width:100%; height:100%; object-fit: fill }`
   into a fixed-height `.img-pro` box, so images stretch — and the wider the column,
   the worse it gets. Give the frame a fixed square ratio instead and let the image sit
   inside it with `contain`, so nothing is ever distorted. Product images here range from
   1:1 originals to 400x280 thumbnails, so the leftover letterbox bars take the card's own
   background and stay invisible. Padding-top ratio rather than `aspect-ratio` so older
   Safari/Chrome degrade gracefully. */

.wm-page .img-pro {
    height: auto !important;
    padding-top: 100%;
    position: relative;
    display: block;
    background-color: var(--bg-card);
}

.wm-page .img-pro img {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    padding: 8px;
    object-fit: contain !important;
    -o-object-fit: contain !important;
}

/* Six per row leaves ~190px of card, so tighten the type and keep every card the
   same height regardless of how long the product name is. */
.wm-page .row-category .item {
    margin-bottom: 14px;
}

.wm-page .pro-name a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
    font-size: 13px;
    line-height: 1.55;
}

@media (min-width: 1200px) {
    .wm-page .add-to-cart-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .wm-page .cost-total {
        font-size: 14px;
    }

    .wm-page .old-cost,
    .wm-page .offer .off {
        font-size: 12px;
    }
}

/* ---------- skeleton ---------- */

.wm-skeleton__card {
    padding: 12px;
    border: 1px solid var(--border-card);
    border-radius: 14px;
    background-color: var(--bg-card);
}

.wm-skeleton__img,
.wm-skeleton__line,
.wm-skeleton__btn {
    border-radius: 8px;
    background: linear-gradient(90deg, var(--bg-body) 25%, var(--tab-color) 50%, var(--bg-body) 75%);
    background-size: 400% 100%;
    animation: wm-shimmer 1.4s ease infinite;
}

.wm-skeleton__img {
    height: 0;
    padding-top: 100%;
    margin-bottom: 12px;
}

.wm-skeleton__line {
    height: 12px;
    margin-bottom: 8px;
}

.wm-skeleton__line--short {
    width: 55%;
}

.wm-skeleton__btn {
    height: 34px;
    margin-top: 14px;
    border-radius: 10px;
}

@keyframes wm-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ---------- empty state ---------- */

.wm-empty {
    padding: 56px 20px;
    text-align: center;
    border: 1px dashed var(--border-card);
    border-radius: 18px;
    background-color: var(--bg-card);
}

.wm-empty__icon {
    font-size: 44px;
    color: var(--color-icon);
}

.wm-empty__title {
    margin: 16px 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}

.wm-empty__hint {
    margin: 0;
    font-size: 13px;
    color: var(--color-icon);
}

.wm-empty__btn {
    margin-top: 18px;
    padding: 10px 22px;
    font-family: inherit;
    font-size: 13px;
    color: #fff;
    background-color: var(--red-100);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

/* ---------- responsive ---------- */

@media (max-width: 767px) {
    .wm-header {
        padding: 16px;
        border-radius: 14px;
    }

    .wm-header__title {
        font-size: 17px;
    }

    .wm-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .wm-controls {
        justify-content: space-between;
        gap: 10px;
    }

    .wm-sort__label {
        display: none;
    }

    .wm-skeleton__card {
        padding: 8px;
    }
}
