/* AP Wholesale — Dark Mode v1.0.5
   Applied via html[data-ws-theme="dark"]; selector wins over :root without !important.
   Hardcoded colour overrides use !important only where theme/WC CSS forces the same. */

/* ── CSS variable overrides ─────────────────────────────────────────────── */
html[data-ws-theme="dark"] {
    --ws-bg:        #1a202c;
    --ws-card-bg:   #2d3748;
    --ws-border:    #4a5568;
    --ws-text:      #e2e8f0;
    --ws-muted:     #a0aec0;
    /* sidebar already dark — intentionally unchanged */
}

/* ── Topbar (hardcoded #fff in layout.css) ──────────────────────────────── */
html[data-ws-theme="dark"] .ap-wholesale-topbar {
    background: #2d3748;
    border-bottom-color: #4a5568;
}
html[data-ws-theme="dark"] .ap-wholesale-topbar__search input {
    background: #374151;
    color: #e2e8f0;
    border-color: #4a5568;
}
/* Mobile hamburger (color:#2d3748 in layout.css → invisible on dark topbar) */
html[data-ws-theme="dark"] .ap-ws-hamburger {
    color: #e2e8f0;
}

/* ── Main content area ──────────────────────────────────────────────────── */
html[data-ws-theme="dark"] body.ap-wholesale-portal-page,
html[data-ws-theme="dark"] .ap-wholesale-wrap,
html[data-ws-theme="dark"] .ap-wholesale-main {
    background: #1a202c;
    color: #e2e8f0;
}
html[data-ws-theme="dark"] .ap-wholesale-main h1,
html[data-ws-theme="dark"] .ap-wholesale-main h2,
html[data-ws-theme="dark"] .ap-wholesale-main h3 {
    color: #e2e8f0;
}

/* ── Cards — grid & list ─────────────────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-product-card,
html[data-ws-theme="dark"] .ap-ws-product-list-row {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e2e8f0;
}
/* OOS tint */
html[data-ws-theme="dark"] .ap-ws-product-card--out-of-stock,
html[data-ws-theme="dark"] .ap-ws-product-list-row--out-of-stock {
    background: #3d2020 !important;
    border-color: #7b3535 !important;
}
/* Monthly special / on-sale tint */
html[data-ws-theme="dark"] .ap-ws-product-card--special,
html[data-ws-theme="dark"] .ap-ws-product-list-row--special {
    background: #36300e !important;
    border-color: #7a6a10 !important;
}
/* Card image area (hardcoded #fbfbfb) */
html[data-ws-theme="dark"] .ap-ws-product-card__img-wrap {
    background: #374151 !important;
}

/* ── Qty input (wholesale-catalogue.js forces colours via style; CSS fights back) */
html[data-ws-theme="dark"] .ap-ws-qty-input {
    color: #e2e8f0 !important;
    background-color: #374151 !important;
    -webkit-text-fill-color: #e2e8f0 !important;
    border-color: #4a5568 !important;
}
html[data-ws-theme="dark"] .ap-ws-qty-input:disabled,
html[data-ws-theme="dark"] .ap-ws-qty-input[readonly] {
    background-color: #2d3748 !important;
    color: #a0aec0 !important;
    -webkit-text-fill-color: #a0aec0 !important;
}

/* ── Box / Individual mode buttons ──────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-mode-btn {
    background: #374151 !important;
    color: #a0aec0 !important;
    border-color: #4a5568 !important;
}
html[data-ws-theme="dark"] .ap-ws-mode-btn:hover {
    background: #4a5568 !important;
    color: #e2e8f0 !important;
}
html[data-ws-theme="dark"] .ap-ws-mode-btn.is-active {
    background: var(--ws-accent) !important;
    color: #fff !important;
    border-color: var(--ws-accent) !important;
}

/* ── RRP badge (inline variant) ─────────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-rrp-badge--inline {
    background: #374151;
    color: #a0aec0;
}

/* ── Linked product badges (R / S buttons) ──────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-linked-badge {
    background: #374151;
    color: #a0aec0;
    border-color: #4a5568;
}

/* ── Single product page — price table ───────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-price-table-wrap {
    background: #374151 !important;
}
/* td/th carry inline color & border — need !important to win */
html[data-ws-theme="dark"] .ap-ws-price-table-wrap th,
html[data-ws-theme="dark"] .ap-ws-price-table-wrap td {
    color: #e2e8f0 !important;
    border-color: #4a5568 !important;
}
/* Regular price row — keep slightly muted so hierarchy reads */
html[data-ws-theme="dark"] .ap-ws-price-table-wrap tbody tr:first-child td {
    color: #a0aec0 !important;
}

/* ── Note / special-discount text boxes ─────────────────────────────────── */
html[data-ws-theme="dark"] .ap-wholesale-main [style*="background:#fffbeb"],
html[data-ws-theme="dark"] .ap-wholesale-main [style*="background: #fffbeb"] {
    background: #36300e !important;
    border-color: #7a6a10 !important;
    color: #e2e8f0 !important;
}

/* ── Dashboard notice ───────────────────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-dashboard-notice {
    color: #e2e8f0 !important;
}

/* ── Brand / page filter bar ─────────────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-brand-filter select,
html[data-ws-theme="dark"] .ap-ws-page-filter select,
html[data-ws-theme="dark"] .ap-ws-page-filter input {
    background: #374151;
    color: #e2e8f0;
    border-color: #4a5568;
}

/* ── Order review / history tables ──────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-order-table th,
html[data-ws-theme="dark"] .ap-ws-order-table td {
    border-color: #4a5568;
    color: #e2e8f0;
}
html[data-ws-theme="dark"] .ap-ws-order-table tr:nth-child(even) td {
    background: #323d4e;
}

/* ── Inline colour overrides: card & list elements ──────────────────────── */
/* Muted gray (#718096) used on: Regular price label+value, SKU, secondary text.
   Attribute selector matches the literal substring in inline style attributes. */
html[data-ws-theme="dark"] .ap-ws-product-card [style*="color:#718096"],
html[data-ws-theme="dark"] .ap-ws-product-list-row [style*="color:#718096"] {
    color: #a0aec0 !important;
}

/* Dark slate (#4a5568) used on bundle card description and price rows */
html[data-ws-theme="dark"] .ap-ws-product-card [style*="color:#4a5568"],
html[data-ws-theme="dark"] .ap-ws-product-list-row [style*="color:#4a5568"] {
    color: #cbd5e0 !important;
}

/* SKU / description class (explicit colour via CSS class) */
html[data-ws-theme="dark"] .ap-ws-product-card__sku,
html[data-ws-theme="dark"] .ap-ws-product-card__name a {
    color: #e2e8f0 !important;
}

/* Bundle price rows that use color:#4a5568 via class+style */
html[data-ws-theme="dark"] .ap-ws-product-card__price-row {
    color: #cbd5e0 !important;
}

/* Bundle card image placeholder (light blue #ebf8ff) */
html[data-ws-theme="dark"] .ap-ws-product-card [style*="background:#ebf8ff"] {
    background: #374151 !important;
}

/* Bundle deal link badges (light blue bg + dark blue text) */
html[data-ws-theme="dark"] .ap-ws-bundle-badge {
    background: #1a365d !important;
    color: #90cdf4 !important;
    border-color: #3182ce !important;
}
html[data-ws-theme="dark"] .ap-ws-bundle-badge strong {
    color: #90cdf4 !important;
}

/* Bundle deal deal-info text (color:#2b6cb0 inline) */
html[data-ws-theme="dark"] .ap-ws-product-card [style*="color:#2b6cb0"] {
    color: #90cdf4 !important;
}

/* Note trigger button (white bg, gray border, dark text) */
html[data-ws-theme="dark"] .ap-ws-note-trigger {
    background: #374151 !important;
    color: #a0aec0 !important;
    border-color: #4a5568 !important;
}

/* ── Dark mode toggle widget ─────────────────────────────────────────────── */
.ap-ws-dark-toggle {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    background: #d1d5db;
    border-radius: 5px;
    padding: 2px;
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1;
}
html[data-ws-theme="dark"] .ap-ws-dark-toggle {
    background: #374151;
}
.ap-ws-dark-toggle button {
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: #718096;
    cursor: pointer;
    line-height: 1;
    transition: background .15s, color .15s;
    white-space: nowrap;
    /* Lock icon glyph size so ☀/☾ don't blow up in large system fonts */
    font-family: system-ui, -apple-system, sans-serif;
}
html[data-ws-theme="dark"] .ap-ws-dark-toggle button {
    color: #9ca3af;
}
.ap-ws-dark-toggle button.is-active {
    background: #fff;
    color: #1a202c;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
html[data-ws-theme="dark"] .ap-ws-dark-toggle button.is-active {
    background: #4a5568;
    color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.ap-ws-dark-toggle button:hover:not(.is-active) {
    color: #374151;
}
html[data-ws-theme="dark"] .ap-ws-dark-toggle button:hover:not(.is-active) {
    color: #e2e8f0;
}

/* ── Dashboard / catalogue section panels (background:#fff inline) ────────── */
html[data-ws-theme="dark"] .ap-ws-panel {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e2e8f0;
}
/* BIS (back-in-stock) panel keeps a muted green accent border */
html[data-ws-theme="dark"] #ap-ws-bis-panel {
    border-color: #276749 !important;
}
/* Muted text inside panels (color:#718096 / color:#4a5568 inline styles) */
html[data-ws-theme="dark"] .ap-ws-panel [style*="color:#718096"] {
    color: #a0aec0 !important;
}
html[data-ws-theme="dark"] .ap-ws-panel [style*="color:#4a5568"] {
    color: #a0aec0 !important;
}
/* Catalogue brand/page filter inputs & selects */
html[data-ws-theme="dark"] .ap-ws-filters select,
html[data-ws-theme="dark"] .ap-ws-filters input[type="text"],
html[data-ws-theme="dark"] input.ap-ws-page-filter {
    background: #374151;
    color: #e2e8f0;
    border-color: #4a5568;
}

/* ── Free Freight Progress Bar ──────────────────────────────────────────────── */
html[data-ws-theme="dark"] #ap-ws-freight-bar {
    background: #2d3748;
    border-color: #4a5568;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
html[data-ws-theme="dark"] #ap-ws-freight-bar .ap-ws-freight-label {
    color: #a0aec0;
}
html[data-ws-theme="dark"] #ap-ws-freight-bar .ap-ws-freight-track {
    background: #4a5568;
}
html[data-ws-theme="dark"] #ap-ws-freight-bar .ap-ws-freight-remaining {
    color: #e2e8f0;
}

/* ── Order Review page ──────────────────────────────────────────────────────── */

/* Table: thead border, th text */
html[data-ws-theme="dark"] #ap-ws-order-form table thead tr {
    border-bottom-color: #4a5568 !important;
}
html[data-ws-theme="dark"] #ap-ws-order-form table th {
    color: #e2e8f0;
}
/* Table: tbody row dividers */
html[data-ws-theme="dark"] #ap-ws-order-form table tbody tr {
    border-bottom-color: #374151 !important;
}

/* Unit price strong (inline color:#2d3748 — dark navy, invisible on dark bg) */
html[data-ws-theme="dark"] .ap-or-unit-price {
    color: #e2e8f0 !important;
}
/* Product cell: price wrapper text, SKU, price note, box display, GST, surcharge note */
html[data-ws-theme="dark"] #ap-ws-order-form [style*="color:#718096"] {
    color: #a0aec0 !important;
}
html[data-ws-theme="dark"] #ap-ws-order-form [style*="color:#4a5568"] {
    color: #a0aec0 !important;
}
/* Cart adjustment notice amber text */
html[data-ws-theme="dark"] #ap-ws-order-form [style*="color:#744210"],
html[data-ws-theme="dark"] .ap-wholesale-main [style*="color:#744210"] {
    color: #fefcbf !important;
}

/* Qty input in order review table */
html[data-ws-theme="dark"] .ap-ws-review-qty {
    background: #374151 !important;
    color: #e2e8f0 !important;
    border-color: #4a5568 !important;
}

/* FREE units badge (light green #c6f6d5 bg) */
html[data-ws-theme="dark"] #ap-ws-order-form [style*="background:#c6f6d5"] {
    background: #1a4731 !important;
    color: #68d391 !important;
}

/* Free freight banner (light green bg) */
html[data-ws-theme="dark"] #ap-or-freight-banner {
    background: #1a2e1a !important;
    border-color: #276749 !important;
    color: #68d391 !important;
}

/* Totals: divider above "Total (inc GST)" */
html[data-ws-theme="dark"] #ap-ws-order-form [style*="border-top:2px solid #e2e8f0"] {
    border-top-color: #4a5568 !important;
}

/* Update Quantities / BIS Apply — gray pill buttons */
html[data-ws-theme="dark"] #ap-or-update-btn,
html[data-ws-theme="dark"] #ap-bis-apply-btn {
    background: #374151 !important;
    color: #e2e8f0 !important;
}

/* Product Notes section box */
html[data-ws-theme="dark"] #ap-ws-order-form [style*="background:#fafbfc"] {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
}
html[data-ws-theme="dark"] #ap-ws-product-notes-list [style*="border-top:1px solid #edf2f7"] {
    border-top-color: #4a5568 !important;
}

/* PO Reference textarea, BIS coupon input, Payment Terms select */
html[data-ws-theme="dark"] #ap_po_reference,
html[data-ws-theme="dark"] #ap-bis-coupon-input,
html[data-ws-theme="dark"] #ap_payment_terms {
    background: #374151;
    color: #e2e8f0;
    border-color: #4a5568;
}

/* ── Bundle detail page (page-bundle.php inline <style> block) ──────────────── */

/* Sticky unlock bar: light-blue #ebf8ff bg */
html[data-ws-theme="dark"] .ap-bundle-unlock-bar {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e2e8f0;
}
/* Group name pills (Stone / Wood / Soil) */
html[data-ws-theme="dark"] .ap-bundle-group-pill {
    background: #374151 !important;
    border-color: #4a5568 !important;
    color: #a0aec0 !important;
}
/* Covered/selected pill — light green */
html[data-ws-theme="dark"] .ap-bundle-group-pill--covered {
    background: #1a4731 !important;
    border-color: #276749 !important;
    color: #68d391 !important;
}
/* Product card wrapper inside bundle page */
html[data-ws-theme="dark"] .ap-bundle-product-select-card {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
}
/* Reward section border divider */
html[data-ws-theme="dark"] .ap-bundle-group[style*="border-top:2px solid #bee3f8"] {
    border-top-color: #4a5568 !important;
}
/* "Your Reward" FREE badge (light green) */
html[data-ws-theme="dark"] .ap-bundle-group__header [style*="background:#c6f6d5"] {
    background: #1a4731 !important;
    color: #68d391 !important;
}
/* Back link color:#4a5568 */
html[data-ws-theme="dark"] .ap-wholesale-main > p > a[style*="color:#4a5568"] {
    color: #a0aec0 !important;
}

/* ── Bundle badge popup tooltip ──────────────────────────────────────────────── */
html[data-ws-theme="dark"] .ap-ws-bundle-popup {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e2e8f0 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,.4) !important;
}
html[data-ws-theme="dark"] .ap-ws-bundle-popup [style*="color:#2b6cb0"] {
    color: #90cdf4 !important;
}
