/**
 * Sales + Orders restructure CSS v2
 * - Orders top action buttons
 * - Sale fullscreen modal (tab-based tree)
 * - Repair fullscreen modal
 * - Products table + cart
 * - Table description badges
 * - Gear column toggle
 */

/* ══════════════════════════════════════════════
   ORDERS TOP ACTIONS
   ══════════════════════════════════════════════ */
.orders-top-actions {
  display: flex; gap: 12px; margin-bottom: 16px;
}
.orders-btn-sale,
.orders-btn-order {
  flex: 1;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 800;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  letter-spacing: .3px;
}
.orders-btn-sale:hover, .orders-btn-order:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.orders-btn-sale {
  background: #22C55E;
  color: #fff;
}
.orders-btn-sale:active { background: #16A34A; }
.orders-btn-order {
  background: #FF3366;
  color: #fff;
}
.orders-btn-order:active { background: #E6295A; }

/* ══════════════════════════════════════════════
   TABLE — DESCRIPTION BADGES
   ══════════════════════════════════════════════ */
.ot-desc-badges {
  display: flex; flex-wrap: wrap; gap: 4px;
  max-height: 48px; overflow: hidden;
}
.ot-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ot-badge-blue { background: #3B82F620; color: #2563EB; }
.ot-badge-pink { background: #FF336620; color: #E6295A; }
.ot-badge-green { background: #22C55E20; color: #16A34A; }

.ot-th-desc { min-width: 200px; }
.ot-th-num { width: 60px; }
.ot-th-gear { width: 40px; padding: 0 !important; }
.ot-gear-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 6px; opacity: .5;
  transition: opacity .2s;
}
.ot-gear-btn:hover { opacity: 1; }
.ot-client { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* ══════════════════════════════════════════════
   FULLSCREEN MODALS (sale + repair)
   ══════════════════════════════════════════════ */
.sale-overlay,
.repair-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--bg, #f5f5f5);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sale-modal,
.repair-modal {
  display: flex; flex-direction: column;
  height: 100%; width: 100%;
  max-width: 1200px; margin: 0 auto;
}

/* Header */
.sale-modal-header,
.repair-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sale-modal-title { font-size: 20px; font-weight: 800; color: #22C55E; }
.repair-modal-title { font-size: 20px; font-weight: 800; color: #FF3366; }
.sale-modal-close,
.repair-modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; color: var(--text-muted);
  padding: 4px 8px; border-radius: 8px;
  transition: background .15s;
}
.sale-modal-close:hover,
.repair-modal-close:hover { background: var(--border); }

/* Body */
.sale-modal-body,
.repair-modal-body {
  flex: 1; overflow-y: auto; padding: 16px 24px;
}

/* Footer (repair only) */
.repair-modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  flex-shrink: 0;
  max-height: 50vh; overflow-y: auto;
}

/* ══════════════════════════════════════════════
   SALE — PRODUCT TABLE
   ══════════════════════════════════════════════ */
.sale-products-table {
  width: 100%; border-collapse: collapse; margin-top: 8px;
}
.sale-products-table thead th {
  text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .3px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.sale-products-table tbody tr {
  transition: background .12s;
}
.sale-products-table tbody tr:hover {
  background: rgba(34,197,94,.04);
}
.sale-products-table tbody tr.sale-row-in-cart {
  background: rgba(34,197,94,.08);
}
.sale-products-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sale-th-name { min-width: 180px; }
.sale-th-group { width: 120px; }
.sale-th-price { width: 100px; }
.sale-th-add { width: 80px; text-align: right; }
.sale-td-name { font-weight: 600; }
.sale-td-group { font-size: 11px; color: var(--text-muted); }
.sale-td-price {
  font-weight: 700; color: #22C55E;
  font-family: var(--font-mono, monospace);
}
.sale-td-add {
  text-align: right;
  white-space: nowrap;
}
.sale-add-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: #22C55E;
  color: #fff;
  font-size: 20px; font-weight: 700;
  cursor: pointer;
  transition: background .12s, transform .12s;
  display: inline-flex; align-items: center; justify-content: center;
}
.sale-add-btn:hover {
  background: #16A34A;
  transform: scale(1.1);
}
.sale-qty-in-cart {
  display: inline-flex; align-items: center; justify-content: center;
  background: #22C55E; color: #fff;
  min-width: 22px; height: 22px; border-radius: 6px;
  font-size: 12px; font-weight: 800; padding: 0 4px;
  margin-right: 6px;
}

/* Show more */
.sale-show-more {
  display: block; width: 100%; padding: 10px;
  margin-top: 8px; border: 1px dashed var(--border);
  border-radius: 10px; background: none;
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text-muted); transition: all .15s;
}
.sale-show-more:hover {
  border-color: #22C55E; color: #22C55E;
}

/* ══════════════════════════════════════════════
   SALE CART OVERLAY MODAL (separate, like repair)
   ══════════════════════════════════════════════ */
.sale-cart-overlay {
  position: fixed; inset: 0; z-index: 10500;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.sale-cart-overlay.open { display: flex; }

/* Controls row (qty ± , %) under each cart item */
.sale-cart-modal-controls {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

/* ══════════════════════════════════════════════
   SALE — CART SECTION (legacy / inline fallback)
   ══════════════════════════════════════════════ */
.sale-cart-block {
  margin-top: 16px;
  border-top: 2px solid #22C55E;
  padding-top: 10px;
}

/* Cart rows */
.sale-cart-rows { margin-bottom: 10px; }
.sale-cart-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  gap: 8px;
}
.sale-cart-line-name {
  flex: 1; min-width: 80px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sale-cart-line-controls {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.sale-cart-line-price {
  font-family: var(--font-mono, monospace);
  font-size: 14px; font-weight: 700;
  min-width: 70px; text-align: right;
}

/* Qty buttons (shared) */
.sale-qty-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card-bg, #fff);
  cursor: pointer; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sale-qty-btn:hover { background: var(--border); }
.sale-qty-val {
  font-size: 14px; font-weight: 700; min-width: 20px; text-align: center;
  font-family: var(--font-mono);
}

/* Percent input */
.sale-pct-wrap {
  display: flex; align-items: center; gap: 1px;
}
.sale-pct-input {
  width: 40px; text-align: center; padding: 4px 2px;
  font-size: 13px; font-weight: 700; border-radius: 6px;
  border: 1px solid var(--border); font-family: var(--font-mono);
}
.sale-pct-input:focus { border-color: #22C55E; outline: none; }
.sale-pct-sign { font-size: 12px; color: var(--text-muted); }

.sale-remove-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-muted); padding: 2px 4px;
}
.sale-remove-btn:hover { color: #E6295A; }

/* Cart footer: buttons + total */
.sale-cart-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 10px; padding-top: 10px;
  border-top: 2px solid var(--text);
  flex-wrap: wrap;
}
.sale-cart-footer-left {
  display: flex; gap: 8px;
}
.sale-cart-footer-right {
  display: flex; align-items: center; gap: 12px;
}
.sale-total-pct .sale-pct-input { width: 46px; }

.sale-client-fields {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.sale-client-input {
  flex: 1; padding: 8px 12px; font-size: 13px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--card-bg, #fff); color: var(--text);
  transition: border-color .15s;
}
.sale-client-input:focus {
  outline: none; border-color: #22C55E;
}
.sale-client-input.phone-valid { border-color: #22C55E; }
.sale-client-input.phone-invalid { border-color: var(--red, #EF4444); }

.sale-btn-sell {
  padding: 10px 20px; font-size: 14px; font-weight: 700;
  background: #22C55E; color: #fff;
  border: none; border-radius: 10px;
  cursor: pointer; transition: all .15s;
}
.sale-btn-sell:hover { background: #16A34A; }

.sale-cart-grand-total {
  font-family: var(--font-mono, monospace);
  font-size: 20px; font-weight: 900;
  color: var(--text);
}

/* ══════════════════════════════════════════════
   UNIFIED PRODUCT PICKER MODAL
   ══════════════════════════════════════════════ */
.pp-overlay {
  position: fixed; inset: 0; z-index: 10100;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.pp-overlay.open { display: flex; }
.pp-modal {
  background: var(--bg, #f5f5f5); border-radius: 20px;
  width: 96%; max-width: 1200px; max-height: 96dvh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  animation: ppFadeIn .2s ease-out;
}
/* Таблица внутри пикера — без горизонтального скролла */
.pp-modal-body .wh-table-wrap { overflow-x: hidden; }
.pp-modal-body .wh-table { table-layout: fixed; width: 100%; }
.pp-modal-body .wh-table td.name { white-space: normal; word-break: break-word; }
.pp-modal-body .wh-table th { white-space: normal; }
@keyframes ppFadeIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

.pp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg, #f5f5f5); z-index: 2;
}
.pp-title { font-size: 18px; font-weight: 800; }
.pp-header-right { display: flex; align-items: center; gap: 8px; }
.pp-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--text-muted); padding: 4px 8px;
  border-radius: 8px; transition: background .15s;
}
.pp-close:hover { background: var(--border); }

.pp-header-search {
  flex: 1; min-width: 0; margin: 0 12px;
}
.pp-modal-body {
  padding: 0 24px 16px;
}
.pp-tabs-wrap {
  padding: 8px 0 4px;
}
.price-parts-count {
  text-align: center; padding: 8px 0 2px; font-size: 11px;
  color: var(--text-muted); font-weight: 600;
}

/* Picker: selected rows (green bg, badge, remove btn) */
.pp-clickable { cursor: pointer; }
.pp-row-selected {
  background: rgba(34,197,94,.12) !important;
}
.pp-row-selected:hover {
  background: rgba(34,197,94,.18) !important;
}
.pp-row-no-stock {
  opacity: .45;
  cursor: not-allowed;
}
.pp-cart-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #22C55E; color: #fff;
  min-width: 20px; height: 20px; border-radius: 6px;
  font-size: 11px; font-weight: 800; padding: 0 4px;
  margin-right: 4px; vertical-align: middle;
}
.pp-remove-btn {
  background: none; border: none; cursor: pointer;
  color: #EF4444; font-size: 14px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  margin-left: 6px; vertical-align: middle;
  transition: background .12s, color .12s;
}
.pp-remove-btn:hover {
  background: #FEE2E2; color: #DC2626;
}

/* ══════════════════════════════════════════════
   WORK PICKER POPUP (colored chips)
   ══════════════════════════════════════════════ */
.pp-work-picker-overlay {
  position: fixed; inset: 0; z-index: 10200;
  background: rgba(0,0,0,.35); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  animation: ppFadeIn .15s ease-out;
}
.pp-work-picker {
  background: var(--bg, #fff); border-radius: 20px;
  padding: 20px 24px 24px; min-width: 280px; max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.pp-work-picker-title {
  font-size: 15px; font-weight: 800; margin-bottom: 16px;
  color: var(--text);
}
.pp-work-chips {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.pp-work-chip {
  padding: 10px 20px; border-radius: 20px; border: none;
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.pp-work-chip:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.pp-work-chip:active { transform: scale(.97); }

/* ══════════════════════════════════════════════
   ORDER CARD — mobile extras
   ══════════════════════════════════════════════ */
.order-card-client {
  font-size: 13px; font-weight: 600; padding: 2px 0;
}
.order-card-desc {
  padding: 4px 0;
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .orders-top-actions {
    flex-direction: column; gap: 8px;
  }
  .orders-btn-sale, .orders-btn-order {
    font-size: 15px; padding: 14px 20px;
  }
  .sale-cart-line {
    flex-direction: column; align-items: flex-start;
  }
  .sale-cart-line-controls { width: 100%; justify-content: space-between; }
  .sale-cart-footer { flex-direction: column; align-items: stretch; }
  .sale-cart-footer-left { order: 2; }
  .sale-cart-footer-right { order: 1; justify-content: space-between; }
  .sale-products-table { font-size: 12px; }
  .sale-th-group { display: none; }
  .sale-td-group { display: none; }
  .pp-modal { width: 100%; max-width: 100%; border-radius: 16px; margin: 8px; }
}
