/**
 * FayzliBazar — komponentlar: tugmalar, chiplar, mahsulot kartasi, forma elementlari,
 * miqdor stepper, pagination, alert, bo'sh holat, filtr paneli.
 */

/* ---------- Tugmalar ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-control);
    font-weight: 700;
    font-size: 14px;
    padding: 11px 18px;
    text-align: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

/* Navy: karta "Buyurtma berish" — hover gold */
.btn--primary {
    background: var(--navy);
    color: #ffffff;
}

.btn--primary:hover {
    background: var(--gold);
    color: var(--gold-ink);
}

/* Gold: "Kirish", buyurtma submit — hover navy */
.btn--gold {
    background: var(--gold);
    color: var(--gold-ink);
    font-weight: 800;
}

.btn--gold:hover {
    background: var(--navy);
    color: #ffffff;
}

/* Outline: o'xshash mahsulotlardagi "Ko'rish" */
.btn--outline {
    background: var(--surface);
    color: var(--navy);
    border: 1.5px solid var(--navy);
    padding: 10px 18px;
}

.btn--outline:hover {
    background: var(--navy);
    color: #ffffff;
}

.btn--block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ---------- Kategoriya chiplari ---------- */

.chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 18px 0 4px;
}

.chip {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border-chip);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
}

.chip:hover {
    border-color: var(--navy);
    color: var(--navy);
}

/* Mobil: chiplar bir qatorda, gorizontal suriladi (ekran chetigacha) */
@media (max-width: 700px) {
    .chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0 calc(-1 * var(--container-pad));
        padding-left: var(--container-pad);
        padding-right: var(--container-pad);
    }

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

    .chip {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ---------- Mahsulot kartasi ---------- */

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.grid-cards--narrow {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

/* Mobil: har doim bir qatorda 2 ta karta */
@media (max-width: 700px) {
    .grid-cards,
    .grid-cards--narrow {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .product-card__body {
        padding: 12px 12px 14px;
        gap: 6px;
    }

    .product-card__title {
        font-size: 13px;
    }

    .product-card__price {
        font-size: 15px;
    }

    .product-card__body .btn {
        padding: 9px 8px;
        font-size: 13px;
    }
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s, transform 0.15s;
}

.product-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.product-card__media {
    aspect-ratio: 1;
    background: var(--img-bg);
    overflow: hidden;
    display: block;
}

.product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-card__body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.product-card__tag {
    font-size: 11px;
    font-weight: 800;
    color: var(--gold-text);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Nom 2 qatorga qisqartiriladi — kartalar balandligi tekislanadi (CLS/grid "tishlamasin") */
.product-card__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    flex: 1;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(2 * 1.35em);
}

.product-card__title:hover {
    color: var(--navy);
}

.product-card__price {
    font-size: 17px;
    font-weight: 800;
    color: var(--navy);
}

.product-card--related .product-card__price {
    font-size: 16px;
}

/* ---------- Rasm yuklanishi (shimmer placeholder) ---------- */

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

.lazy-wrap {
    position: relative;
}

.lazy-wrap .lazy-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    background: linear-gradient(90deg, var(--img-bg) 25%, var(--surface-2) 50%, var(--img-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    border-radius: inherit;
    color: var(--text-faint);
}

.lazy-wrap img {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.lazy-wrap img.is-loaded {
    opacity: 1;
    position: relative;
    z-index: 2;
}

.lazy-wrap .lazy-loader.is-hidden {
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* ---------- Badge (mahsulot sahifasidagi kategoriya) ---------- */

.badge-cat {
    align-self: flex-start;
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    color: var(--gold-text);
    background: var(--gold-tint);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* ---------- Forma elementlari ---------- */

.form-field {
    display: flex;
    flex-direction: column;
}

.input {
    width: 100%;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-control);
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    background: var(--surface);
    color: var(--text);
}

.input::placeholder {
    color: var(--text-faint);
}

.input:focus {
    border-color: var(--navy);
}

.form-field .field-error {
    color: var(--danger);
    font-size: 12px;
    margin: 4px 2px 0;
    min-height: 0;
}

.form-field.has-error .input {
    border-color: var(--danger);
}

.checkbox-label {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-2);
}

.checkbox-label input[type='checkbox'] {
    accent-color: var(--navy);
    width: 15px;
    height: 15px;
    margin: 0;
}

/* ---------- Miqdor stepper ---------- */

.qty-row {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.qty {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-control);
    overflow: hidden;
}

.qty__btn {
    border: none;
    background: var(--surface-2);
    width: 44px;
    height: 44px;
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
    transition: background 0.15s;
}

.qty__btn:hover {
    background: var(--navy-tint);
}

.qty__value {
    width: 44px;
    text-align: center;
    font-weight: 800;
    font-size: 16px;
}

.qty-total {
    font-size: 14px;
    color: var(--text-muted);
}

.qty-total strong {
    color: var(--text);
}

/* ---------- Buyurtma formasi paneli ---------- */

.order-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-box__title {
    font-size: 14px;
    font-weight: 800;
}

.order-box .input {
    background: var(--surface);
}

.order-box__note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.order-box__submit {
    padding: 14px 0;
    font-size: 15px;
    font-weight: 800;
}

/* ---------- "Yana yuklash" (AJAX load-more) ---------- */

.load-more {
    text-align: center;
    padding-top: 28px;
}

.load-more__btn {
    min-width: 220px;
}

.load-more__btn.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

/* ---------- Alert (flash xabarlar) ---------- */

.alert {
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 14px;
}

.alert--success {
    border-color: rgba(28, 124, 75, 0.35);
    background: #eaf6f0;
    color: var(--success);
    font-weight: 600;
}

.alert--error {
    border-color: rgba(192, 57, 43, 0.35);
    background: #fdf0ee;
    color: var(--danger);
    font-weight: 600;
}

/* ---------- Bo'sh holat ---------- */

.empty-state {
    grid-column: 1 / -1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-panel);
    padding: 56px 24px;
    text-align: center;
}

.empty-state__icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--navy-tint);
    color: var(--navy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.empty-state__title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
}

.empty-state__desc {
    font-size: 14px;
    color: var(--text-muted);
}

/* ---------- Filtr paneli (katalog aside) ---------- */

.filter-panel {
    flex: 0 1 240px;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 20px;
}

.filter-panel__title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.filter-panel__divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 18px 0 14px;
}

.cat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cat-list__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    text-align: left;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    width: 100%;
}

.cat-list__item:hover {
    background: var(--surface-2);
    color: var(--navy);
}

.cat-list__count {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-faint);
}

.cat-list__item.is-active {
    background: var(--navy);
    color: #ffffff;
    font-weight: 700;
}

.cat-list__item.is-active .cat-list__count {
    color: var(--gold);
}

.price-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---------- Mobil filtr drawer (bottom-sheet) ---------- */

.filter-toggle {
    display: none;
}

.filter-panel__mobile-head {
    display: none;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13, 43, 88, 0.45);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

body.drawer-open {
    overflow: hidden;
}

@media (max-width: 760px) {
    .filter-toggle {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        background: var(--surface);
        border: 1.5px solid var(--border-input);
        border-radius: var(--radius-control);
        padding: 9px 16px;
        min-height: 44px;
        font-size: 14px;
        font-weight: 700;
        color: var(--navy);
    }

    .filter-toggle__badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: var(--radius-pill);
        background: var(--navy);
        color: #ffffff;
        font-size: 11px;
        font-weight: 800;
    }

    /* Panel bottom-sheet bo'lib chiqadi; oqimdan chiqqani uchun grid to'liq kenglik oladi */
    .filter-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 210;
        max-height: 78vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -12px 40px rgba(13, 43, 88, 0.25);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.3s ease, visibility 0.3s ease;
    }

    .filter-panel.is-open {
        transform: translateY(0);
        visibility: visible;
    }

    .filter-panel__mobile-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
        font-size: 16px;
        font-weight: 800;
    }

    .filter-panel__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: none;
        border-radius: 10px;
        background: var(--surface-2);
        color: var(--text-2);
    }
}

/* ---------- Mobil: touch-target va iOS zoom tuzatishlari ---------- */

@media (max-width: 760px) {
    /* iOS Safari 16px dan kichik inputga fokusda sahifani zumlaydi */
    .input {
        font-size: 16px;
    }

    /* WCAG 2.1 AA: bosiladigan elementlar kamida 44px */
    .btn {
        min-height: 44px;
    }

    .chip {
        min-height: 44px;
    }

    .cat-list__item {
        min-height: 44px;
    }

    .checkbox-label {
        min-height: 44px;
    }

    .qty__btn {
        width: 44px;
        height: 44px;
    }
}
