/* =======================================================================
   ZOL — Member browse, cart, checkout, orders
   ======================================================================= */

/* Browse page ------------------------------------------------------- */
.browse-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
    padding-bottom: 80px; /* space for cart bar */
}
.browse-header {
    background: var(--shop-primary);
    color: var(--shop-on-primary);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}
.browse-header .shop-name {
    font-family: var(--font-display);
    font-size: 18px;
    color: currentColor;
    font-weight: 500;
}
.browse-header .header-btn-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.browse-header .btn-ghost {
    background: rgba(255,255,255,0.1);
    color: var(--shop-on-primary);
    border-color: rgba(255,255,255,0.2);
}

/* Closed banner */
.closed-banner {
    background: rgba(215, 130, 61, 0.15);
    color: var(--accent);
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid rgba(215, 130, 61, 0.3);
}

/* Category nav (horizontal scroll on mobile) */
.cat-nav {
    background: #ffffff;
    padding: 12px 16px;
    border-bottom: 1px solid var(--paper-3);
    overflow-x: auto;
    white-space: nowrap;
    position: sticky;
    top: 56px;
    z-index: 10;
    -webkit-overflow-scrolling: touch;
}
.cat-nav::-webkit-scrollbar { height: 0; }
.cat-nav-pill {
    display: inline-block;
    padding: 7px 14px;
    margin-right: 6px;
    border-radius: 999px;
    background: var(--paper);
    color: rgba(14, 31, 20, 0.7);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 120ms ease;
}
.cat-nav-pill.is-active {
    background: var(--shop-primary);
    color: var(--shop-on-primary);
}

/* Product grid */
.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 16px;
}
.browse-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--paper-3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 120ms ease, box-shadow 120ms ease;
}
.browse-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.browse-card.unavailable { opacity: 0.55; cursor: not-allowed; }
.browse-card-photo {
    aspect-ratio: 1 / 1;
    background: var(--paper-2);
    overflow: hidden;
    position: relative;
}
.browse-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.browse-card-photo .placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: rgba(14, 31, 20, 0.25);
}
.browse-card-out-badge {
    position: absolute;
    top: 8px; left: 8px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 500;
}
.browse-card-body {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.browse-card-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.browse-card-price {
    margin-top: auto;
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--forest);
    font-weight: 500;
}
.browse-card-price-from {
    font-size: 11px;
    color: rgba(14, 31, 20, 0.55);
    font-family: var(--font-body);
    font-weight: 400;
    margin-right: 4px;
}

.browse-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(14, 31, 20, 0.5);
}

/* Product detail view ----------------------------------------------- */
.pdp-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
    padding-bottom: 96px;
}
.pdp-header {
    background: var(--shop-primary);
    color: var(--shop-on-primary);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.pdp-header .btn-back {
    background: rgba(255,255,255,0.12);
    color: var(--shop-on-primary);
    position: relative;
    top: auto;
    left: auto;
    flex-shrink: 0;
}
.pdp-header h2 {
    font-family: var(--font-display);
    font-size: 16px;
    margin: 0;
    color: currentColor;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pdp-photo {
    aspect-ratio: 1 / 1;
    background: var(--paper-2);
    width: 100%;
    overflow: hidden;
}
.pdp-photo img {
    width: 100%; height: 100%; object-fit: cover;
}
.pdp-thumbs {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    background: #fff;
    border-bottom: 1px solid var(--paper-3);
}
.pdp-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
}
.pdp-thumb.is-active { border-color: var(--shop-primary); }
.pdp-thumb img { width: 100%; height: 100%; object-fit: cover; }

.pdp-body {
    padding: 20px 16px;
}
.pdp-name {
    font-family: var(--font-display);
    font-size: 26px;
    color: var(--forest);
    margin: 0 0 4px;
    line-height: 1.15;
}
.pdp-cat {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.55);
    margin-bottom: 12px;
}
.pdp-price {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--forest);
    font-weight: 500;
    margin-bottom: 14px;
}
.pdp-desc {
    color: rgba(14, 31, 20, 0.75);
    line-height: 1.55;
    margin-bottom: 24px;
    white-space: pre-wrap;
}
.pdp-section {
    margin-bottom: 18px;
}
.pdp-section h4 {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin: 0 0 8px;
}
.pdp-option-values {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.pdp-option-chip {
    padding: 8px 14px;
    border: 1px solid var(--paper-3);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.pdp-option-chip.is-selected {
    border-color: var(--shop-primary);
    background: rgba(20, 56, 35, 0.05);
    color: var(--forest);
    font-weight: 500;
}
.pdp-option-chip.unavailable {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.pdp-qty {
    display: flex;
    align-items: center;
    gap: 12px;
}
.pdp-qty button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--paper-3);
    background: #fff;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    color: var(--forest);
}
.pdp-qty button:hover { background: var(--paper); }
.pdp-qty span {
    min-width: 30px;
    text-align: center;
    font-weight: 500;
}

/* Sticky add-to-cart bar */
.pdp-add-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--paper-3);
    padding: 14px 16px;
    display: flex;
    gap: 10px;
    z-index: 20;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.pdp-add-bar .btn { flex: 1; }

/* Cart bar (bottom of browse) --------------------------------------- */
.cart-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--shop-primary);
    color: var(--shop-on-primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 30;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    transition: transform 200ms ease;
}
.cart-bar[hidden] { display: none !important; }
.cart-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cart-bar-count {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}
.cart-bar-label {
    font-weight: 500;
}
.cart-bar-total {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 500;
}

/* Cart drawer ------------------------------------------------------- */
.cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}
.cart-drawer[hidden] { display: none !important; }
.cart-drawer-head {
    background: var(--shop-primary);
    color: var(--shop-on-primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.cart-drawer-head .btn-back {
    background: rgba(255,255,255,0.12);
    color: var(--shop-on-primary);
    position: relative; top: auto; left: auto;
}
.cart-drawer-head h2 {
    font-family: var(--font-display);
    font-size: 18px;
    margin: 0;
    color: currentColor;
    flex: 1;
}

.cart-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.cart-item {
    background: #fff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    align-items: center;
}
.cart-item-photo {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--paper-2);
}
.cart-item-photo img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { min-width: 0; }
.cart-item-name {
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 2px;
    font-size: 14px;
    line-height: 1.3;
}
.cart-item-variant {
    font-size: 12px;
    color: rgba(14, 31, 20, 0.55);
    margin-bottom: 4px;
}
.cart-item-price {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.7);
}
.cart-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.cart-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--paper-3);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.cart-qty button {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    font-size: 14px;
    cursor: pointer;
    color: var(--forest);
}
.cart-qty button:hover { background: var(--paper); }
.cart-qty span {
    min-width: 26px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}
.cart-item-remove {
    background: none;
    border: none;
    color: var(--error);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.cart-empty {
    text-align: center;
    padding: 60px 20px;
    color: rgba(14, 31, 20, 0.5);
}
.cart-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    color: rgba(14, 31, 20, 0.25);
}

.cart-summary {
    background: #fff;
    border-top: 1px solid var(--paper-3);
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.cart-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}
.cart-summary-row.total {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--forest);
    font-weight: 500;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--paper-3);
}
.cart-summary .btn { width: 100%; margin-top: 12px; }

/* Checkout -------------------------------------------------------- */
.checkout-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
}
.checkout-section {
    background: #fff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-md);
    padding: 18px;
    margin: 0 16px 14px;
}
.checkout-section:first-of-type { margin-top: 16px; }
.checkout-section h4 {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--forest);
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.fulfill-options {
    display: flex;
    gap: 10px;
}
.fulfill-option {
    flex: 1;
    border: 2px solid var(--paper-3);
    background: #fff;
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 120ms ease;
}
.fulfill-option.is-selected {
    border-color: var(--shop-primary);
    background: rgba(20, 56, 35, 0.04);
}
.fulfill-option svg {
    color: var(--shop-primary);
    margin-bottom: 4px;
}
.fulfill-option .label {
    font-weight: 500;
    color: var(--forest);
}
.fulfill-option .sub {
    font-size: 12px;
    color: rgba(14, 31, 20, 0.55);
    margin-top: 2px;
}

.payment-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.payment-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 2px solid var(--paper-3);
    background: #fff;
    border-radius: var(--radius-md);
    cursor: pointer;
}
.payment-option.is-selected {
    border-color: var(--shop-primary);
    background: rgba(20, 56, 35, 0.04);
}
.payment-option svg {
    color: var(--shop-primary);
    flex-shrink: 0;
}
.payment-option .label { font-weight: 500; }
.payment-option .sub {
    font-size: 12px;
    color: rgba(14, 31, 20, 0.55);
}

.checkout-totals {
    margin-top: 8px;
}

.checkout-action-bar {
    position: sticky;
    bottom: 0;
    background: var(--paper);
    padding: 16px;
    border-top: 1px solid var(--paper-3);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.checkout-action-bar .btn { width: 100%; }

/* My orders --------------------------------------------------------- */
.orders-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
    padding-bottom: 32px;
}
.order-card {
    background: #fff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin: 0 16px 10px;
    cursor: pointer;
    transition: border-color 120ms ease;
}
.order-card:hover { border-color: var(--shop-primary); }
.order-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.order-card-num {
    font-family: 'Menlo', monospace;
    font-weight: 500;
    color: var(--forest);
}
.order-status-pill {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 500;
}
.order-status-pill.new            { background: rgba(74, 124, 89, 0.15); color: var(--success); }
.order-status-pill.accepted,
.order-status-pill.preparing      { background: rgba(74, 124, 89, 0.15); color: var(--success); }
.order-status-pill.ready_for_pickup,
.order-status-pill.ready_for_delivery,
.order-status-pill.out_for_delivery { background: rgba(215, 130, 61, 0.15); color: var(--accent); }
.order-status-pill.delivered,
.order-status-pill.collected      { background: var(--paper-2); color: rgba(14, 31, 20, 0.6); }
.order-status-pill.cancelled,
.order-status-pill.no_stock,
.order-status-pill.payment_failed { background: rgba(181, 74, 61, 0.12); color: var(--error); }

.order-card-meta {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.6);
}
.order-card-total {
    font-family: var(--font-display);
    color: var(--forest);
    font-weight: 500;
    margin-top: 4px;
}

/* Order detail */
.order-detail-page {
    padding-bottom: 32px;
}
.order-detail-section {
    background: #fff;
    border: 1px solid var(--paper-3);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 14px 16px;
}
.order-detail-section h4 {
    font-size: 13px;
    color: rgba(14, 31, 20, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin: 0 0 10px;
}
.order-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--paper-3);
}
.order-line:last-child { border-bottom: none; }
.order-line-name {
    flex: 1;
    padding-right: 8px;
}
.order-line-name .variant {
    font-size: 12px;
    color: rgba(14, 31, 20, 0.55);
}
.order-line-qty {
    color: rgba(14, 31, 20, 0.6);
    margin-right: 12px;
}
.order-line-total {
    font-weight: 500;
    color: var(--ink);
    min-width: 70px;
    text-align: right;
}

.order-history-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: rgba(14, 31, 20, 0.7);
}
.order-history-row .when {
    color: rgba(14, 31, 20, 0.5);
}

.member-actions-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--paper-3);
    padding: 12px 16px;
    z-index: 30;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
}
.member-actions-bar[hidden] { display: none !important; }
.member-actions-bar .btn { flex: 1; }

/* Toolbar buttons on member screens for My Orders / Catalog ---------- */
.member-tabs {
    background: var(--shop-primary);
    color: var(--shop-on-primary);
    padding: 8px 12px;
    display: flex;
    gap: 6px;
}
.member-tab {
    flex: 1;
    background: rgba(255,255,255,0.1);
    color: var(--shop-on-primary);
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}
.member-tab.is-active {
    background: var(--shop-on-primary);
    color: var(--shop-primary);
    border-color: var(--shop-on-primary);
}

@media (max-width: 400px) {
    .browse-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }
}
