/* ═══════════════════════════════════════════════════════════════════
   [odoo_products] — product-display.css
   Mobile-first. Desktop sidebar. Mobile bottom drawer.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────────── */
.opd-wrap {
    --opd-accent:   #16A34A;
    --opd-accent-l: #f0fdf4;
    --opd-border:   #e2e8f0;
    --opd-text:     #1e293b;
    --opd-muted:    #64748b;
    --opd-subtle:   #94a3b8;
    --opd-surface:  #ffffff;
    --opd-bg:       #f8fafc;
    --opd-radius:   12px;
    font-family: inherit;
    color: var(--opd-text);
    position: relative;
}

.opd-title {
    font-size: clamp(1.25rem, 4vw, 1.6rem);
    font-weight: 700;
    margin: 0 0 16px;
    color: #0f172a;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE STICKY BAR (hidden on desktop)
   ══════════════════════════════════════════════════════════════════ */
.opd-mobile-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

/* Desktop: hide mobile bar, sidebar handles search */
@media (min-width: 781px) {
    .opd-mobile-bar { display: none; }
}

.opd-mobile-search-wrap {
    flex: 1;
    position: relative;
}

.opd-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 44px;
    border-radius: 10px;
    background: var(--opd-surface);
    border: 1.5px solid var(--opd-border);
    font-size: .9rem;
    font-weight: 600;
    color: var(--opd-text);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color .18s, background .18s;
    position: relative;
}
.opd-filter-toggle:active,
.opd-filter-toggle.active {
    border-color: var(--opd-accent);
    background: var(--opd-accent-l);
    color: var(--opd-accent);
}
.opd-filter-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--opd-accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ══════════════════════════════════════════════════════════════════
   DRAWER OVERLAY (mobile)
   ══════════════════════════════════════════════════════════════════ */
.opd-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1998;
    backdrop-filter: blur(2px);
    animation: opd-fade-in .22s ease;
}
.opd-drawer-overlay.active { display: block; }
@keyframes opd-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Drawer handle (swipe indicator) */
.opd-sidebar__handle {
    display: none;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--opd-border);
    margin: 10px auto 0;
}

/* Drawer header row */
.opd-drawer-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--opd-border);
}
.opd-drawer-title { font-weight: 700; font-size: 1rem; }
.opd-drawer-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--opd-bg);
    color: var(--opd-muted);
    font-size: .9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.opd-drawer-close:hover { background: var(--opd-border); }

/* ══════════════════════════════════════════════════════════════════
   LAYOUT (desktop: sidebar left | mobile: full-width stack)
   ══════════════════════════════════════════════════════════════════ */
.opd-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    align-items: start;
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.opd-sidebar {
    background: var(--opd-surface);
    border: 1px solid var(--opd-border);
    border-radius: var(--opd-radius);
    overflow: hidden;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--opd-border) transparent;
}

/* Search */
.opd-sidebar__search {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid var(--opd-bg);
}

.opd-search-input {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--opd-border);
    border-radius: 8px;
    font-size: 1rem; /* 1rem = no iOS auto-zoom */
    background: var(--opd-bg);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    color: var(--opd-text);
}
.opd-search-input:focus {
    border-color: var(--opd-accent);
    box-shadow: 0 0 0 3px rgba(22,163,74,.15);
    background: var(--opd-surface);
}
.opd-search-icon {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--opd-subtle);
    pointer-events: none;
}

/* Category tree */
.opd-sidebar__cats { padding: 8px 0 12px; }
.opd-sidebar__heading {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--opd-subtle);
    padding: 4px 16px 6px;
    margin: 0;
}
.opd-cat-list, .opd-cat-children {
    list-style: none;
    margin: 0;
    padding: 0;
}
.opd-cat-item { position: relative; }
.opd-cat-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    font-size: .875rem;
    color: #374151;
    text-align: left;
    gap: 6px;
    line-height: 1.3;
    min-height: 40px; /* touch target */
    transition: background .14s, color .14s;
    -webkit-tap-highlight-color: transparent;
}
.opd-cat-btn:hover,
.opd-cat-btn:focus-visible {
    background: var(--opd-accent-l);
    color: var(--opd-accent);
    outline: none;
}
.opd-cat-item.active > .opd-cat-btn {
    color: var(--opd-accent);
    font-weight: 600;
    border-left-color: var(--opd-accent);
    background: var(--opd-accent-l);
}
.opd-cat-btn--child { padding-left: 28px; font-size: .84rem; }
.opd-cat-name { flex: 1; }
.opd-cat-count {
    font-size: .72rem;
    background: #f1f5f9;
    color: var(--opd-muted);
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.opd-cat-item.active > .opd-cat-btn .opd-cat-count {
    background: rgba(22,163,74,.15);
    color: var(--opd-accent);
}
.opd-cat-arrow {
    font-size: .95rem;
    color: var(--opd-subtle);
    transition: transform .18s;
    flex-shrink: 0;
}
.opd-cat-arrow.open { transform: rotate(90deg); }
.opd-cat-children { display: none; background: var(--opd-bg); }
.opd-cat-children.open { display: block; }

/* ══════════════════════════════════════════════════════════════════
   MAIN AREA
   ══════════════════════════════════════════════════════════════════ */
.opd-main { min-width: 0; }

.opd-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--opd-border);
}
.opd-result-count { margin: 0; font-size: .85rem; color: var(--opd-muted); }
.opd-sort-wrap { display: flex; align-items: center; gap: 8px; }
.opd-sort-wrap label { font-size: .82rem; color: var(--opd-muted); white-space: nowrap; }
.opd-sort-select {
    padding: 8px 12px;
    border: 1px solid var(--opd-border);
    border-radius: 8px;
    font-size: .875rem;
    background: var(--opd-surface);
    color: var(--opd-text);
    cursor: pointer;
    min-height: 40px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.opd-sort-select:focus { outline: none; border-color: var(--opd-accent); }

/* ══════════════════════════════════════════════════════════════════
   PRODUCT GRID
   ══════════════════════════════════════════════════════════════════ */
.opd-grid {
    display: grid;
    gap: 14px;
}
/* Mobile: always 2 columns (pharmacy products are small, 1-col wastes space) */
.opd-grid--2 { grid-template-columns: repeat(2, 1fr); }
.opd-grid--3 { grid-template-columns: repeat(2, 1fr); }
.opd-grid--4 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 600px) {
    .opd-grid--3 { grid-template-columns: repeat(2, 1fr); }
    .opd-grid--4 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 781px) {
    .opd-grid--2 { grid-template-columns: repeat(2, 1fr); }
    .opd-grid--3 { grid-template-columns: repeat(3, 1fr); }
    .opd-grid--4 { grid-template-columns: repeat(3, 1fr); }
    .opd-grid    { gap: 18px; }
}
@media (min-width: 1100px) {
    .opd-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════
   PRODUCT CARD
   ══════════════════════════════════════════════════════════════════ */
.opd-card {
    background: var(--opd-surface);
    border: 1px solid var(--opd-border);
    border-radius: var(--opd-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .22s, transform .22s;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    /* Only apply hover lift on devices that support hover (not touchscreens) */
    .opd-card:hover {
        box-shadow: 0 8px 28px rgba(0,0,0,.09);
        transform: translateY(-2px);
    }
    .opd-card:hover .opd-card__img { transform: scale(1.04); }
}
.opd-card--oos { opacity: .62; }

/* Image */
.opd-card__img-wrap {
    display: block;
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--opd-bg);
    text-decoration: none;
}
.opd-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
    display: block;
}

/* No-image placeholder */
.opd-card__no-img {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(145deg, #f1f5f9 0%, #e2eaf4 100%);
}
.opd-card__no-img svg { width: 52px; height: 52px; }
.opd-card__no-img span {
    font-size: .68rem;
    font-weight: 700;
    color: var(--opd-subtle);
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* Badges */
.opd-stock-badge {
    position: absolute;
    bottom: 7px;
    right: 7px;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 7px;
    border-radius: 20px;
    line-height: 1;
}
.opd-badge--in  { background: #dcfce7; color: #15803d; }
.opd-badge--low { background: #fef9c3; color: #854d0e; }
.opd-badge--out { background: #f1f5f9; color: var(--opd-subtle); }
.opd-sale-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    background: #dc2626;
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 20px;
    letter-spacing: .04em;
    line-height: 1;
}

/* Card body */
.opd-card__body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}
.opd-card__name {
    margin: 0;
    font-size: .84rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.opd-card__name a { text-decoration: none; color: #0f172a; }
.opd-card__name a:active { color: var(--opd-accent); }
.opd-card__sku  { margin: 0; font-size: .7rem; color: var(--opd-subtle); }
.opd-card__price {
    font-weight: 700;
    font-size: .95rem;
    color: #0f172a;
    margin-top: 1px;
}
.opd-card__price del  { color: var(--opd-subtle); font-weight: 400; font-size: .82rem; }
.opd-card__price ins  { text-decoration: none; color: #dc2626; }

@media (min-width: 781px) {
    .opd-card__body  { padding: 12px 14px 14px; gap: 6px; }
    .opd-card__name  { font-size: .9rem; }
    .opd-card__price { font-size: 1rem; }
}

/* Variations */
.opd-variations { display: flex; flex-direction: column; gap: 6px; }
.opd-var-row    { display: flex; flex-direction: column; gap: 3px; }
.opd-var-label  { font-size: .72rem; font-weight: 600; color: var(--opd-muted); }
.opd-var-select {
    padding: 7px 10px;
    border: 1px solid var(--opd-border);
    border-radius: 7px;
    font-size: .875rem; /* no iOS zoom */
    width: 100%;
    min-height: 38px;
}
.opd-swatches   { display: flex; flex-wrap: wrap; gap: 6px; }
.opd-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--opd-border);
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.opd-swatch.selected { border-color: var(--opd-accent); transform: scale(1.15); }

/* ── Card action row (View Product + Add to Cart) ────────────────── */
.opd-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}
/* Single button (out-of-stock simple products only need one full-width) */
.opd-card__actions--simple {
    grid-template-columns: auto 1fr;
}

/* "View Product" — outlined secondary button */
.opd-btn-secondary {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 44px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    border: 1.5px solid var(--opd-border) !important;
    background: var(--opd-surface) !important;
    color: var(--opd-text) !important;
    font-size: .82rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    transition: border-color .16s, color .16s, background .16s !important;
    box-sizing: border-box !important;
    -webkit-tap-highlight-color: transparent !important;
}
@media (hover: hover) {
    .opd-btn-secondary:hover {
        border-color: var(--opd-accent) !important;
        color: var(--opd-accent) !important;
        background: var(--opd-accent-l) !important;
    }
}
.opd-btn-secondary:active {
    background: var(--opd-accent-l) !important;
    border-color: var(--opd-accent) !important;
}

/* "Add to Cart" primary green button + WC native button override */
.opd-btn,
.opd-card .add_to_cart_button,
.opd-card .button,
.opd-card .single_add_to_cart_button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 44px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    border: none !important;
    background: var(--opd-accent) !important;
    color: #fff !important;
    font-size: .82rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    transition: filter .16s !important;
    box-sizing: border-box !important;
    text-align: center !important;
    -webkit-appearance: none !important;
    -webkit-tap-highlight-color: transparent !important;
}
@media (hover: hover) {
    .opd-btn:hover:not(.opd-btn--oos):not([disabled]),
    .opd-card .add_to_cart_button:hover,
    .opd-card .button:hover { filter: brightness(1.1) !important; }
}
.opd-btn:active,
.opd-card .add_to_cart_button:active { filter: brightness(.9) !important; }

/* Out of stock state */
.opd-btn--oos,
.opd-card .add_to_cart_button.disabled {
    background: #e2e8f0 !important;
    color: var(--opd-subtle) !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* WC "Added to cart" loading state */
.opd-card .add_to_cart_button.loading {
    opacity: .7 !important;
    pointer-events: none !important;
}
.opd-card .add_to_cart_button.added { background: #15803d !important; }

/* WC sometimes injects an "Added to cart" span — hide it in grid context */
.opd-card .added_to_cart { display: none !important; }

/* ── Empty state ─────────────────────────────────────────────── */
.opd-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.opd-empty svg { width: 72px; height: 72px; }
.opd-empty p { color: var(--opd-muted); font-size: .95rem; margin: 0; }
.opd-reset-btn {
    padding: 0 24px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    background: var(--opd-accent);
    color: #fff;
    font-size: .88rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

/* ── Loading overlay ─────────────────────────────────────────── */
.opd-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9;
    border-radius: var(--opd-radius);
}
.opd-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--opd-border);
    border-top-color: var(--opd-accent);
    border-radius: 50%;
    animation: opd-spin .65s linear infinite;
}
@keyframes opd-spin { to { transform: rotate(360deg); } }

/* ── Pagination ──────────────────────────────────────────────── */
.opd-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 28px;
}
.opd-page-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1.5px solid var(--opd-border);
    border-radius: 8px;
    background: var(--opd-surface);
    font-size: .875rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: background .14s, border-color .14s, color .14s;
    -webkit-tap-highlight-color: transparent;
}
.opd-page-btn:active { transform: scale(.96); }
@media (hover: hover) {
    .opd-page-btn:hover:not(.active) { border-color: var(--opd-accent); color: var(--opd-accent); }
}
.opd-page-btn.active {
    background: var(--opd-accent);
    border-color: var(--opd-accent);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(22,163,74,.28);
}
.opd-page-btn--nav { font-size: 1rem; font-weight: 700; }
.opd-page-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 40px;
    color: var(--opd-subtle);
    font-size: .9rem;
}

/* Mobile: show only prev/next + current — hide numbered pages */
@media (max-width: 480px) {
    .opd-page-btn:not(.opd-page-btn--nav):not(.active) { display: none; }
    .opd-page-dots { display: none; }
    .opd-page-btn--nav { min-width: 80px; }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE OVERRIDES (< 780px)
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 780px) {

    /* Layout: single column (sidebar is a drawer) */
    .opd-layout { grid-template-columns: 1fr; gap: 0; }

    /* Sidebar → full-width bottom drawer */
    .opd-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        border: none;
        border-top: 1px solid var(--opd-border);
        z-index: 1999;
        transform: translateY(100%);
        transition: transform .32s cubic-bezier(.22,1,.36,1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        box-shadow: 0 -8px 32px rgba(0,0,0,.12);
    }
    .opd-sidebar.open {
        transform: translateY(0);
    }
    .opd-sidebar__handle { display: block; }
    .opd-drawer-head { display: flex; }

    /* Hide desktop search inside sidebar on mobile (mobile bar has its own) */
    .opd-sidebar__search { display: none; }

    /* Topbar: stack on mobile */
    .opd-topbar { flex-direction: column; align-items: flex-start; gap: 6px; }
    .opd-sort-wrap { width: 100%; }
    .opd-sort-select { flex: 1; }

    /* Card: smaller padding on mobile */
    .opd-card__body { padding: 8px 10px 10px; gap: 4px; }

    /* Pagination: bigger tap targets */
    .opd-page-btn { min-width: 44px; height: 44px; }
}
