/* ================================
   XpartWeb Order Writer (Clean Final)
   Replace entire orderwriter.css with this file
================================== */

:root {
  /* Accent color sync with theme (Elementor / WP preset), fallback if not set */
  --xow-accent: var(
    --e-global-color-primary,
    var(--wp--preset--color--primary, #000)
  );
  --xow-accent-2: #2c79c7; /* view cart button fallback */
  --xow-border: #e6e9ee;
  --xow-soft: #f6f7f9;
  --xow-soft-2: #eef2f5;
  --xow-text: #111827;
  --xow-muted: #6b7280;
  --xow-radius: 10px;
}

/* Wrapper */
#xow-wrap {
  max-width: 1250px;
  margin: 0 auto;
  padding: 18px 14px 32px;
  box-sizing: border-box;
  font-family: inherit;
  color: var(--xow-text);
}

/* Header */
.xow-header {
  display: flex;
  align-items: center;
  justify-content: right;
  gap: 12px;
  margin-bottom: 12px;
}

.xow-title {
  margin: 0;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 800;
}

.xow-return-shop,
.xow-make-payment {
  text-decoration: none;
  font-weight: 700;
  color: #000;
}

/* Layout (sidebar + main like reference) */
.xow-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: start;
}

/* Sidebar */
.xow-sidebar {
  border: 1px solid var(--xow-border);
  background: #fff;
  border-radius: var(--xow-radius);
  overflow: hidden;
}

.xow-cat-icon {
  display: none !important;
}

.xow-cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--xow-border);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
  color: var(--xow-text);
}

.xow-cat-btn:hover {
  background: var(--xow-soft);
}

.xow-cat-btn.active {
  background: #e9f0ee;
  border-left: 4px solid var(--xow-accent);
  padding-left: 10px;
}

.xow-cat-name {
  flex: 1;
}

.xow-cat-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--xow-muted);
  font-weight: 900;
}

/* Main container */
.xow-main {
  border: 1px solid var(--xow-border);
  background: #fff;
  border-radius: var(--xow-radius);
  padding: 14px;
}

/* ================================
   Topbar (stable, professional)
================================== */
.xow-topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.xow-toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.xow-toprow-1 .xow-search {
  flex: 1;
  min-width: 260px;
}
.xow-toprow-1 .xow-cartbox {
  flex-shrink: 0;
}

.xow-toprow-2 {
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

/* Search input */
.xow-search {
  position: relative !important;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--xow-border);
  background: #fff;
  border-radius: var(--xow-radius);
  padding: 10px 12px;
  min-height: 44px;
}

.xow-search-icon {
  position: absolute !important;
  left: 6px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  opacity: 0.55 !important;
  font-size: 16px !important;
  pointer-events: none !important;
}

#xow-search {
  width: 100%;
  border: 0 !important;
  outline: none !important;
  background: transparent !important;
  font-size: 14px;
}

/* Cart summary */
.xow-cartbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--xow-border);
  background: var(--xow-soft);
  border-radius: var(--xow-radius);
  padding: 8px 10px;
  min-width: 210px;
  min-height: 44px;
}

.xow-carttext {
  font-size: 13px;
  font-weight: 800;
  color: var(--xow-text);
}

.xow-view-cart {
  border: 0;
  background: var(--xow-accent-2);
  color: #fff;
  font-weight: 900;
  border-radius: 8px !important;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12px;
}

.xow-view-cart:hover {
  filter: brightness(0.95);
}

/* Customer select + acting row */
.xow-customer-select {
  width: 340px;
  min-width: 260px;
  position: relative !important;
}

#xow-customer-search {
  width: 100%;
  min-height: 44px;
  padding-left: 30px !important;
  border: 1px solid var(--xow-border);
  border-radius: var(--xow-radius);
  background: #fff;
  outline: none;
}

.xow-customer-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--xow-border);
  border-radius: var(--xow-radius);
  z-index: 999;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.xow-customer-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f4;
}
.xow-customer-item:hover {
  background: var(--xow-soft);
}
.xow-customer-item:last-child {
  border-bottom: 0;
}

.xow-selected-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.xow-selected-customer {
  font-size: 13px;
  font-weight: 700;
  color: var(--xow-text);
}

.xow-clear-customer {
  border: 1px solid var(--xow-border);
  background: #fff;
  border-radius: 8px !important;
  padding: 7px 10px;
  font-weight: 900;
  cursor: pointer;
  font-size: 12px;
}
.xow-clear-customer:hover {
  background: var(--xow-soft);
}

.xow-acting-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--xow-border);
  background: #fff;
  border-radius: var(--xow-radius);
  padding: 8px 10px;
  min-height: 44px;
}

.xow-acting-as {
  font-size: 13px;
  font-weight: 900;
  color: var(--xow-text);
}

.xow-role {
  margin-left: 6px;
  color: var(--xow-muted);
  font-weight: 900;
}

/* ================================
   Table
================================== */
.xow-table-wrap {
  border: 1px solid var(--xow-border);
  border-radius: var(--xow-radius);
  overflow: hidden;
  background: #fff;
}

.xow-table {
  width: 100%;
  border-collapse: collapse;
  /* table-layout: fixed; */
}

.xow-table thead th {
  background: var(--xow-soft);
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--xow-text);
  border-bottom: 1px solid var(--xow-border);
}

.xow-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--xow-border);
  vertical-align: middle;
}

/* .xow-table th,
.xow-table td {
  overflow: hidden;
} */

/* Column widths (matches your order: Product / SKU / Price / Qty / Stock / Button) */
.xow-table th:nth-child(1),
.xow-table td:nth-child(1) {
  width: 38%;
}
.xow-table th:nth-child(2),
.xow-table td:nth-child(2) {
  width: 16%;
}
.xow-table th:nth-child(3),
.xow-table td:nth-child(3) {
  width: 10%;
}
.xow-table th:nth-child(4),
.xow-table td:nth-child(4) {
  width: 14%;
  text-align: center;
}
.xow-table th:nth-child(5),
.xow-table td:nth-child(5) {
  width: 10%;
}
.xow-table th:nth-child(6),
.xow-table td:nth-child(6) {
  width: 12%;
  text-align: center;
}

/* Product cell */
.xow-prod {
  display: flex;
  align-items: center;
  gap: 10px;
}

.xow-prod img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--xow-border);
}

.xow-prod-name {
  font-weight: 800;
  line-height: 1.2;
}

/* Price formatting */
.xow-price del {
  opacity: 0.6;
  font-size: 13px;
}

/* ================================
   Qty control (compact + number always visible)
   Default value in HTML can be 0 (your request)
================================== */
.xow-qty-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border: 1px solid var(--xow-border);
  border-radius: 999px;
  background: #fff;
  min-width: 118px; /* prevents collapse (fixes hidden number) */
}

.xow-minus,
.xow-plus {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--xow-border);
  background: var(--xow-soft);
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}

.xow-minus:hover,
.xow-plus:hover {
  background: #fff;
}

.xow-qty {
  width: 40px;
  min-width: 40px;
  height: 28px;
  border: 0 !important;
  outline: none !important;
  background: transparent !important;
  text-align: center;
  font-weight: 900;
  font-size: 14px;
  padding: 0 !important;
  -moz-appearance: textfield;
}

.xow-qty::-webkit-outer-spin-button,
.xow-qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Stock */
.xow-stock {
  font-weight: 900;
  color: #2f6b57;
}
.xow-stock.out {
  color: #a23b3b;
}

/* Add button */
.xow-add {
  background: var(--xow-accent) !important;
  border: 0 !important;
  color: #fff !important;
  font-weight: 900 !important;
  padding: 9px 14px !important;
  border-radius: 7px !important;
  cursor: pointer !important;
}

.xow-add:hover {
  filter: brightness(0.95);
}

.xow-add[disabled] {
  opacity: 0.8;
  cursor: not-allowed !important;
}

.xow-add.added {
  opacity: 0.9;
}

.xow-add.added::after {
  content: " ✓";
  font-weight: 900;
}

/* ================================
   Footer Pagination (modern)
================================== */
.xow-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 10px;
  margin-top: 10px;
  border: 1px solid var(--xow-border);
  border-radius: var(--xow-radius);
  background: #fff;
}

.xow-range {
  color: var(--xow-muted);
  font-weight: 900;
  font-size: 13px;
}

.xow-perpage {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--xow-muted);
  font-weight: 900;
}
.xow-perpage span {
  white-space: nowrap;
  font-size: 15px;
}

#xow-per-page {
  border: 1px solid var(--xow-border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font-weight: 900;
}

.xow-pagination {
  display: flex;
  gap: 10px;
}

.xow-page-btn {
  border: 1px solid #000;
  background: var(--xow-soft);
  border-radius: 10px !important;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
}

.xow-page-btn:hover {
  background: #fff;
}

.xow-page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================================
   Responsive
================================== */
@media (max-width: 980px) {
  .xow-layout {
    grid-template-columns: 1fr;
  }
  .xow-toprow {
    flex-wrap: wrap;
  }
  .xow-cartbox {
    width: 100%;
  }
  .xow-customer-select {
    width: 100%;
  }
  .xow-acting-wrap {
    width: 100%;
    justify-content: space-between;
  }
  .xow-title {
    font-size: 30px;
  }
}

/* ===== FIX: Sidebar categories look like the reference (single column list) ===== */

.xow-sidebar {
  padding: 0 !important;
}

/* Make sure category list stacks vertically (no 2-column wrap) */
#xow-category-list,
.xow-cat-list {
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Make each category a full-width row */
.xow-cat-btn {
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-radius: 0 !important; /* row style */
  border: 0 !important;
  border-bottom: 1px solid var(--xow-border) !important;
  background: #fff !important;
  padding: 12px 14px !important;
  margin: 0 !important;
  color: #000 !important;
}

/* Active row look (left border + light bg) */
.xow-cat-btn.active {
  background: #eef4f1 !important;
  border-left: 4px solid var(--xow-accent) !important;
  padding-left: 10px !important;
}

/* Count pill */
.xow-cat-count {
  margin-left: auto !important;
  padding: 3px 8px !important;
  border-radius: 999px !important;
  background: var(--xow-soft-2) !important;
  color: var(--xow-muted) !important;
  font-weight: 900 !important;
  font-size: 12px !important;
}

/* Remove any icon if still printed */
.xow-cat-icon {
  display: none !important;
}
/* ===== FIX: QTY column cut off (force enough space + no clipping) ===== */

/* Allow the table to size columns naturally */
.xow-table {
  table-layout: auto !important;
}

/* Do NOT clip content inside cells (important for qty controls) */
.xow-table th,
.xow-table td {
  overflow: visible !important;
}

/* Make QTY column wide enough */
.xow-table th:nth-child(4),
.xow-table td:nth-child(4) {
  width: 160px !important;
  white-space: nowrap !important;
  text-align: center !important;
}

/* Keep qty control compact and always visible */
.xow-table td:nth-child(4) .xow-qty-wrap {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  min-width: 140px !important; /* prevents clipping */
  padding: 6px 10px !important;
}

/* Button sizes */
.xow-table td:nth-child(4) .xow-minus,
.xow-table td:nth-child(4) .xow-plus {
  width: 30px !important;
  line-height: 5px !important;
  flex: 0 0 26px !important;
  padding: 10px 3px;
  border-radius: 37%;
}

/* Input width (the number "1") */
.xow-table td:nth-child(4) .xow-qty {
  width: 44px !important;
  min-width: 44px !important;
  height: 30px !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  text-align: center !important;
}
.xow-login-required {
  max-width: 500px;
  margin: 80px auto;
  text-align: center;
  padding: 40px;
  border: 1px solid var(--xow-border);
  border-radius: var(--xow-radius);
  background: #fff;
}

.xow-login-required h2 {
  margin-bottom: 10px;
}

.xow-login-btn {
  display: inline-block;
  margin-top: 15px;
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--xow-accent);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}
/* =========================================================
   MOBILE: turn table rows into cards (no data loss)
   ========================================================= */
@media (max-width: 768px) {
  /* Layout: stack sidebar + content */
  .xow-layout {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .xow-sidebar {
    order: 1;
  }
  .xow-main {
    order: 2;
    padding: 12px !important;
  }

  /* Categories: horizontal scroll pills (clean + space efficient) */
  .xow-sidebar {
    padding: 10px !important;
  }

  .xow-cat-list {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch;
  }

  .xow-cat-btn {
    flex: 0 0 auto !important;
    border: 1px solid var(--xow-border) !important;
    border-radius: 999px !important;
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--xow-border) !important;
    white-space: nowrap !important;
  }

  .xow-cat-btn.active {
    border-left: 1px solid var(--xow-border) !important;
    background: #e9f0ee !important;
  }

  /* Topbar: stack neatly */
  .xow-toprow {
    flex-wrap: wrap !important;
  }

  .xow-toprow-1 .xow-search {
    width: 100% !important;
  }

  .xow-cartbox {
    width: 100% !important;
    min-width: 0 !important;
  }

  .xow-toprow-2 {
    gap: 10px !important;
  }

  .xow-customer-select,
  .xow-acting-wrap {
    width: 100% !important;
  }

  /* Search icon alignment (fix) */
  .xow-search,
  .xow-customer-select {
    position: relative;
    padding-left: 38px !important;
  }

  .xow-search-icon {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    line-height: 1 !important;
    pointer-events: none;
  }

  /* --- TABLE -> CARDS --- */
  .xow-table {
    table-layout: auto !important;
  }

  .xow-table thead {
    display: none !important; /* we will show labels per cell */
  }

  .xow-table,
  .xow-table tbody,
  .xow-table tr,
  .xow-table td {
    display: block !important;
    width: 100% !important;
  }

  .xow-table-wrap {
    overflow: visible !important;
  }

  /* Each product row becomes a card */
  .xow-table tr {
    border: 1px solid var(--xow-border) !important;
    border-radius: 12px !important;
    padding: 12px !important;
    margin: 10px 0 !important;
    background: #fff !important;
  }

  .xow-table td {
    border: 0 !important;
    padding: 10px 0 !important;
  }

  /* Product area at top */
  .xow-table td:nth-child(1) {
    padding-top: 0 !important;
  }

  .xow-prod img {
    width: 52px !important;
    height: 52px !important;
  }

  /* Add labels for each field using nth-child */
  .xow-table td:nth-child(2)::before {
    content: "SKU";
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--xow-muted);
    margin-bottom: 4px;
  }

  .xow-table td:nth-child(3)::before {
    content: "Price";
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--xow-muted);
    margin-bottom: 4px;
  }

  .xow-table td:nth-child(4)::before {
    content: "Qty";
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--xow-muted);
    margin-bottom: 6px;
  }

  .xow-table td:nth-child(5)::before {
    content: "Stock";
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--xow-muted);
    margin-bottom: 4px;
  }

  /* Qty: full width and readable */
  .xow-table td:nth-child(4) {
    text-align: left !important;
  }

  .xow-qty-wrap {
    width: 100% !important;
    max-width: 220px !important;
    min-width: 0 !important;
    justify-content: space-between !important;
  }

  .xow-qty {
    width: 60px !important;
    min-width: 60px !important;
  }

  /* Add button full width */
  .xow-table td:nth-child(6) {
    padding-bottom: 0 !important;
  }

  .xow-add {
    width: 100% !important;
    justify-content: center !important;
    padding: 12px 14px !important;
  }

  /* Footer pagination: stack, keep "per page" one line */
  .xow-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .xow-perpage {
    justify-content: flex-start !important;
    white-space: nowrap !important; /* keeps “per page” one line */
  }

  .xow-pagination {
    justify-content: space-between !important;
  }

  .xow-page-btn {
    width: 48% !important;
  }
}
/* FIX: remove desktop fixed column widths that create empty blocks on mobile */
@media (max-width: 768px) {
  .xow-table {
    table-layout: auto !important;
  }

  /* cancel any desktop column width rules */
  .xow-table th,
  .xow-table td,
  .xow-table th:nth-child(1),
  .xow-table td:nth-child(1),
  .xow-table th:nth-child(2),
  .xow-table td:nth-child(2),
  .xow-table th:nth-child(3),
  .xow-table td:nth-child(3),
  .xow-table th:nth-child(4),
  .xow-table td:nth-child(4),
  .xow-table th:nth-child(5),
  .xow-table td:nth-child(5),
  .xow-table th:nth-child(6),
  .xow-table td:nth-child(6) {
    width: auto !important;
    max-width: none !important;
  }

  /* make every "cell" truly full width */
  .xow-table td {
    float: none !important;
    clear: both !important;
  }
}
@media (max-width: 768px) {
  .xow-table tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .xow-table td {
    padding: 0 !important;
  }

  .xow-table td:nth-child(6) {
    margin-top: 6px !important;
  }
  .xow-table th:nth-child(4),
  .xow-table td:nth-child(4) {
    display: flex !important;
    align-items: center;
  }
  .xow-table td:nth-child(4) .xow-qty-wrap {
    width: 20px !important;
    margin: 8px;
  }
}
.xow-cart-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.xow-pay-later-btn {
  background: #111;
  color: #fff;
  border: 1px solid #111;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.xow-pay-later-btn:hover {
  opacity: 0.92;
}

.xow-pay-later-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
