/* ═══════════════════════════════════════════════
   JustOrder Products — Stylesheet
   ═══════════════════════════════════════════════ */

/* ── ACF Fallback Brand Colours ─────────────── */
:root {
    --color-primary:   #911618;
    --color-secondary: #F27633;
    --color-accent:    #111118;
}

/* ── RMW Design Tokens ──────────────────────── */
:root {
    --rmw-primary-color:   #333333;
    --rmw-secondary-color: #666666;
    --rmw-accent-color:    #8B4513;
    --rmw-background:      #f9fafb;          /* gray-50 */
    --rmw-card-background: #ffffff;
    --rmw-border-color:    #e5e7eb;          /* gray-200 */
    --rmw-button-bg:       #ffffff;
    --rmw-button-hover-bg: #f5f5f5;
    --rmw-shadow:          0 2px 8px rgba(0,0,0,0.08);
    --rmw-shadow-hover:    0 4px 16px rgba(0,0,0,0.13);
    --rmw-transition:      0.3s ease;
    --rmw-border-radius:   12px;
}

/* ── Reset & Base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.jo-archive {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--rmw-background);
    color: #111827;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ═══════════════ HEADER ═══════════════ */
.jo-header {
    background: #ffffff;
    border-bottom: 1px solid var(--rmw-border-color);
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.jo-header__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 640px) {
    .jo-header__inner { padding: 16px 24px; }
}

@media (min-width: 1024px) {
    .jo-header__inner { padding: 16px 32px; }
}

.jo-header__title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .jo-header__title { font-size: 1.875rem; }
}

.jo-header__count {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 2px;
}

@media (min-width: 768px) {
    .jo-header__count { font-size: 1rem; }
}

.jo-header__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Sort dropdown */
.jo-sort-wrapper {
    display: none;
}

@media (min-width: 640px) {
    .jo-sort-wrapper { display: block; }
}

.jo-sort-select {
    appearance: none;
    -webkit-appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--rmw-border-color);
    border-radius: 8px;
    padding: 8px 36px 8px 14px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s;
}

.jo-sort-select:hover { border-color: #9ca3af; }
.jo-sort-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

/* Filter toggle (mobile only) */
.jo-filter-toggle {
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    color: #374151;
}

.jo-filter-toggle:hover { background: #f3f4f6; }

@media (min-width: 1024px) {
    .jo-filter-toggle { display: none; }
}

/* Cart button */
.jo-cart-btn {
    position: relative;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jo-cart-btn:hover { background: #f3f4f6; }

.jo-cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ═══════════════ MAIN LAYOUT ═══════════════ */
.jo-main {
    padding: 32px 0;
}

.jo-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 640px) {
    .jo-container { padding: 0 24px; }
}

@media (min-width: 1024px) {
    .jo-container { padding: 0 32px; }
}

.jo-layout {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

@media (min-width: 1024px) {
    .jo-layout {
        flex-direction: row;
    }
}

/* ═══════════════ SIDEBAR ═══════════════ */
.jo-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .jo-sidebar {
        display: block;
        width: 256px;
        flex-shrink: 0;
    }
}

.jo-sidebar__card {
    position: sticky;
    top: 88px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--rmw-border-color);
    padding: 24px;
    box-shadow: var(--rmw-shadow);
}

.jo-sidebar__title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
}

.jo-sidebar__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.jo-sidebar__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9375rem;
    color: #374151;
}

.jo-sidebar__item:hover {
    background: #f3f4f6;
}

.jo-sidebar__item--active {
    background: var(--color-accent);
    color: #ffffff;
    font-weight: 500;
}

.jo-sidebar__item--active:hover {
    background: var(--color-accent);
    filter: brightness(1.15);
    color: #ffffff;
}

.jo-sidebar__count {
    font-size: 0.875rem;
    opacity: 0.75;
}

/* ═══════════════ MOBILE SIDEBAR ═══════════════ */
.jo-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.jo-mobile-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1024px) {
    .jo-mobile-overlay { display: none !important; }
}

.jo-mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    background: #ffffff;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.jo-mobile-sidebar.is-active {
    transform: translateX(0);
}

@media (min-width: 1024px) {
    .jo-mobile-sidebar { display: none !important; }
}

.jo-mobile-sidebar__header {
    position: sticky;
    top: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--rmw-border-color);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
}

.jo-mobile-sidebar__title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.jo-mobile-sidebar__close {
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    color: #374151;
}

.jo-mobile-sidebar__close:hover { background: #f3f4f6; }

.jo-mobile-sidebar__list {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ═══════════════ PRODUCT GRID ═══════════════ */
.jo-products {
    flex: 1;
    min-width: 0;
}

.jo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 768px) {
    .jo-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

@media (min-width: 1280px) {
    .jo-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ═══════════════ PRODUCT CARD (RMW) ═══════════════ */
.rmw-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--rmw-card-background);
    border-radius: var(--rmw-border-radius);
    border: 1px solid var(--rmw-border-color);
    box-shadow: var(--rmw-shadow);
    transition: box-shadow var(--rmw-transition), transform var(--rmw-transition);
    overflow: hidden;
}

.rmw-product-card:hover {
    box-shadow: var(--rmw-shadow-hover);
}

/* Image */
.rmw-product-image {
    position: relative;
    overflow: hidden;
    border-radius: var(--rmw-border-radius) var(--rmw-border-radius) 0 0;
}

.rmw-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--rmw-transition);
}

.rmw-product-card:hover .rmw-product-image img {
    transform: scale(1.05);
}

/* Aspect Ratios */
.rmw-aspect-1-1 { aspect-ratio: 1 / 1; }
.rmw-aspect-4-3 { aspect-ratio: 4 / 3; }
.rmw-aspect-16-9 { aspect-ratio: 16 / 9; }
.rmw-aspect-3-4 { aspect-ratio: 3 / 4; }

/* Sale badge */
.jo-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    z-index: 2;
}

/* Product Info */
.rmw-product-info {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.rmw-category-badge {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--rmw-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rmw-product-title {
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--rmw-primary-color);
    margin: 0;
    line-height: 1.4;
}

.rmw-product-title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--rmw-transition);
}

.rmw-product-title a:hover {
    color: var(--rmw-accent-color);
}

.rmw-product-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rmw-primary-color);
    margin-top: auto;
    padding-right: 70px;
}

.rmw-product-price del {
    color: var(--rmw-secondary-color);
    font-weight: 400;
    margin-right: 6px;
    font-size: 0.9em;
}

.rmw-product-price ins {
    text-decoration: none;
    font-weight: 600;
}

/* Corner Cart Button */
button.rmw-corner-cart-btn,
a.rmw-corner-cart-btn,
.rmw-corner-cart-btn {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 80px;
    height: 36px;
    background-color: var(--color-secondary);
    border: none;
    border-radius: 20px 0 12px 0;
    color: white;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--rmw-transition);
    box-shadow: var(--rmw-shadow);
    text-decoration: none;
    padding: 0;
    margin: 0;
    line-height: 1;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-sizing: border-box;
    letter-spacing: normal;
    text-transform: none;
    text-indent: 0;
    text-shadow: none;
    background-image: none;
}

.rmw-corner-cart-btn:hover {
    background-color: var(--color-secondary);
    filter: brightness(0.88);
    transform: scale(1.05);
    color: white;
}

.rmw-corner-cart-btn:focus {
    outline: none;
    box-shadow: var(--rmw-shadow);
}

.rmw-corner-cart-btn:active {
    transform: scale(0.98);
}

.rmw-corner-cart-btn.rmw-loading span { display: none; }

.rmw-corner-cart-btn.rmw-loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rmw-spin 1s linear infinite;
}

.rmw-corner-cart-btn.rmw-success {
    background-color: #4CAF50;
}

.rmw-corner-cart-btn.rmw-success span { display: none; }

.rmw-corner-cart-btn.rmw-success::after {
    content: "✓";
    font-size: 16px;
}

/* WooCommerce native AJAX states */
.rmw-corner-cart-btn.loading span { display: none; }

.rmw-corner-cart-btn.loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rmw-spin 1s linear infinite;
}

.rmw-corner-cart-btn.added {
    background-color: #4CAF50;
}

.rmw-corner-cart-btn.added span { display: none; }

.rmw-corner-cart-btn.added::after {
    content: "✓";
    font-size: 16px;
}

/* Hide WooCommerce "View cart" link — mini-cart opens instead */
.added_to_cart,
a.added_to_cart,
.wc-forward.added_to_cart {
    display: none !important;
}

/* ═══════════════ PAGINATION ═══════════════ */
.jo-pagination {
    margin-top: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.jo-pagination a,
.jo-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #374151;
    background: #fff;
    border: 1px solid var(--rmw-border-color);
    transition: all 0.2s;
}

.jo-pagination a:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.jo-pagination span.current {
    background: var(--color-accent);
    color: #ffffff;
    border-color: var(--color-accent);
}

.jo-pagination .prev,
.jo-pagination .next {
    padding: 0 10px;
}

.jo-pagination .dots {
    border: none;
    background: transparent;
}

/* ═══════════════ NO PRODUCTS ═══════════════ */
.jo-no-products {
    text-align: center;
    padding: 64px 16px;
}

.jo-no-products p {
    color: #6b7280;
    font-size: 1.125rem;
}

/* ═══════════════ QUICK VIEW MODAL ═══════════════ */
.jo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.jo-modal-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.jo-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 51;
    background: #ffffff;
    border-radius: 12px;
    width: calc(100% - 32px);
    max-width: 896px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.jo-modal.is-active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.jo-modal__header {
    position: sticky;
    top: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--rmw-border-color);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
}

.jo-modal__title {
    font-size: 1.25rem;
    font-weight: 500;
    color: #111827;
}

.jo-modal__close {
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    color: #374151;
}

.jo-modal__close:hover { background: #f3f4f6; }

.jo-modal__body {
    padding: 24px;
}

@media (min-width: 768px) {
    .jo-modal__body { padding: 32px; }
}

/* Modal content layout */
.jo-modal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

@media (min-width: 768px) {
    .jo-modal-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.jo-modal-image {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 12px;
    background: #f3f4f6;
}

.jo-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.jo-modal-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.jo-modal-cat {
    display: inline-block;
    padding: 4px 12px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.jo-modal-name {
    font-size: 1.875rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px;
    line-height: 1.3;
}

.jo-modal-price-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.jo-modal-price {
    font-size: 1.875rem;
    font-weight: 700;
    color: #111827;
}

.jo-modal-price-original {
    font-size: 1.5rem;
    color: #9ca3af;
    text-decoration: line-through;
}

.jo-modal-divider {
    border: none;
    border-top: 1px solid var(--rmw-border-color);
    margin: 0;
}

.jo-modal-section-title {
    font-size: 1rem;
    font-weight: 500;
    color: #111827;
    margin-bottom: 8px;
}

.jo-modal-desc {
    color: #6b7280;
    line-height: 1.7;
    font-size: 0.9375rem;
}

.jo-modal-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jo-modal-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 0.9375rem;
}

.jo-modal-features li::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    flex-shrink: 0;
}

.jo-modal-add-btn {
    margin-top: auto;
    width: 100%;
    background: var(--color-accent);
    color: #ffffff;
    border: none;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, filter 0.2s;
}

.jo-modal-add-btn:hover {
    background: var(--color-accent);
    filter: brightness(1.2);
}

.jo-modal-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.jo-modal-add-btn .jo-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rmw-spin 1s linear infinite;
}

.jo-modal-view-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    color: #6b7280;
    font-size: 0.875rem;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.jo-modal-view-link:hover { color: #374151; }

/* ═══════════════ TOAST ═══════════════ */
.rmw-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #4CAF50;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--rmw-shadow-hover);
    z-index: 1000;
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

.rmw-toast.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.rmw-toast.rmw-error { background: #ef4444; }
.rmw-toast.rmw-info  { background: #3b82f6; }

/* ═══════════════ ANIMATIONS ═══════════════ */
@keyframes rmw-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ═══════════════ MOBILE RESPONSIVE ═══════════════ */
@media (max-width: 639px) {
    .rmw-product-info {
        padding: 0.75rem;
    }

    .rmw-category-badge {
        font-size: 0.625rem;
    }

    .rmw-product-title {
        font-size: 0.875rem;
    }

    .rmw-product-price {
        font-size: 0.875rem;
        padding-right: 55px;
    }

    .rmw-corner-cart-btn {
        width: 65px;
        height: 28px;
        font-size: 16px;
    }
}

/* ═══════════════ TABLET ═══════════════ */
@media (min-width: 640px) and (max-width: 1023px) {
    .rmw-product-info {
        padding: 1.25rem;
    }

    .rmw-product-title {
        font-size: 1.125rem;
    }
}

/* ═══════════════ REDUCED MOTION ═══════════════ */
@media (prefers-reduced-motion: reduce) {
    .rmw-product-card,
    .rmw-product-image img,
    .rmw-corner-cart-btn,
    .jo-modal,
    .jo-modal-overlay,
    .jo-mobile-sidebar,
    .jo-mobile-overlay,
    .rmw-toast {
        transition: none !important;
        animation: none !important;
    }
}

/* ═══════════════ WC PRICE OVERRIDES ═══════════════ */
.rmw-product-price .woocommerce-Price-amount {
    font-size: inherit;
    color: inherit;
    font-weight: inherit;
}

.rmw-product-price del .woocommerce-Price-amount {
    color: var(--rmw-secondary-color);
}

.rmw-product-price ins {
    text-decoration: none;
}

/* ═══════════════ HIDE WP ADMIN BAR OVERLAP ═══════════════ */
.admin-bar .jo-header {
    top: 32px;
}

@media (max-width: 782px) {
    .admin-bar .jo-header {
        top: 46px;
    }
}

.admin-bar .jo-sidebar__card {
    top: 120px;
}

@media (max-width: 782px) {
    .admin-bar .jo-sidebar__card {
        top: 134px;
    }
}
