/* KantorBox Order Tool — Public CSS */
:root {
  --kb-green:       #1D9E75;
  --kb-green-lt:    #E1F5EE;
  --kb-green-dk:    #0F6E56;
  --kb-green-deep:  #085041;
  --kb-wa:          #25D366;
  --kb-wa-hov:      #1EBF5A;
  --kb-bg:          #F4F6F9;
  --kb-surface:     #FFFFFF;
  --kb-border:      #E5E7EB;
  --kb-text:        #111827;
  --kb-muted:       #6B7280;
  --kb-subtle:      #9CA3AF;
  --kb-radius:      10px;
  --kb-radius-lg:   14px;
}

#kbot-app {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--kb-text);
  background: var(--kb-bg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 980px;
  margin: 0 auto;
  box-sizing: border-box;
}

#kbot-app *, #kbot-app *::before, #kbot-app *::after { box-sizing: border-box; }

/* ── Cards ── */
#kbot-app .kbot-catalog-card,
#kbot-app .kbot-summary-card,
#kbot-app .kbot-customer-card {
  background: var(--kb-surface);
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-lg);
  padding: 1rem 1.25rem;
}

#kbot-app .kbot-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--kb-muted);
  margin-bottom: .75rem;
}

/* ── Toolbar ── */
#kbot-app .kbot-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

#kbot-app .kbot-toolbar input[type="text"] {
  flex: 1;
  min-width: 160px;
}

#kbot-app .kbot-toolbar select {
  width: 160px;
  flex-shrink: 0;
}

/* ── Inputs (scoped) ── */
#kbot-app input[type="text"],
#kbot-app input[type="email"],
#kbot-app input[type="tel"],
#kbot-app select {
  font-family: inherit;
  font-size: 14px;
  color: var(--kb-text);
  background: var(--kb-surface);
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  margin: 0;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

#kbot-app select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' 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");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

#kbot-app input:focus,
#kbot-app select:focus {
  border-color: var(--kb-green);
  box-shadow: 0 0 0 3px rgba(29,158,117,0.1);
}

/* ── Tabs ── */
#kbot-app .kbot-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

#kbot-app .kbot-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 13px;
  border-radius: 20px;
  border: 1px solid var(--kb-border);
  background: var(--kb-surface);
  color: var(--kb-muted);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  line-height: 1.6;
}

#kbot-app .kbot-tab:hover  { border-color: var(--kb-green); color: var(--kb-green); }
#kbot-app .kbot-tab.active { background: var(--kb-green); color: #fff; border-color: var(--kb-green); }

/* ── Table ── */
#kbot-app .kbot-table-scroll {
  overflow-x: auto;
  border-radius: var(--kb-radius);
  border: 1px solid var(--kb-border);
  -webkit-overflow-scrolling: touch;
}

#kbot-app .kbot-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
  background: var(--kb-surface);
}

#kbot-app .kbot-table thead th {
  background: #F9FAFB;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--kb-muted);
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--kb-border);
  white-space: nowrap;
}

#kbot-app .kbot-table thead th.center { text-align: center; }
#kbot-app .kbot-table thead th.right  { text-align: right; }

#kbot-app .kbot-table tbody tr {
  border-bottom: 1px solid var(--kb-border);
  transition: background 0.1s;
}

#kbot-app .kbot-table tbody tr:last-child { border-bottom: none; }
#kbot-app .kbot-table tbody tr:hover    { background: #FAFAFA; }
#kbot-app .kbot-table tbody tr.in-order { background: var(--kb-green-lt); }

#kbot-app .kbot-table td {
  padding: 10px 14px;
  vertical-align: middle;
  border: none;
}

/* Col: Photo/SKU */
#kbot-app .kbot-col-photo { display: flex; align-items: center; gap: 10px; }

#kbot-app .kbot-prod-img {
  width: 60px; height: 60px;
  object-fit: contain;
  background: #F3F4F6;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

#kbot-app .kbot-prod-placeholder {
  width: 60px; height: 60px;
  background: #F3F4F6;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

#kbot-app .kbot-sku {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--kb-muted);
}

/* Col: Measurements */
#kbot-app .kbot-meas { font-size: 14px; font-weight: 600; white-space: nowrap; }
#kbot-app .kbot-pack-lbl { font-size: 11px; color: var(--kb-muted); margin-top: 2px; }

/* Col: Price */
#kbot-app .kbot-price-pack { font-size: 14px; font-weight: 600; color: var(--kb-green-dk); white-space: nowrap; }
#kbot-app .kbot-price-unit { font-size: 11px; color: var(--kb-muted); margin-top: 2px; }

/* Col: QTY */
#kbot-app .kbot-qty-wrap {
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

#kbot-app .kbot-qty-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--kb-border);
  background: var(--kb-surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px; font-weight: 600; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--kb-text);
  transition: all 0.1s;
  flex-shrink: 0;
  padding: 0;
}

#kbot-app .kbot-qty-btn:hover {
  background: var(--kb-green);
  color: #fff;
  border-color: var(--kb-green);
}

#kbot-app .kbot-qty-val {
  font-size: 16px; font-weight: 600;
  min-width: 28px; text-align: center;
}

#kbot-app .kbot-qty-unit {
  font-size: 11px; color: var(--kb-muted);
  text-align: center; margin-top: 2px;
}

/* Col: Subtotal */
#kbot-app .kbot-subtotal {
  font-size: 14px; font-weight: 600;
  color: var(--kb-subtle);
  text-align: right; white-space: nowrap;
}
#kbot-app .kbot-subtotal.active { color: var(--kb-green-dk); }

/* ── Summary ── */
#kbot-app .kbot-summary-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}

#kbot-app .kbot-chips { display: flex; gap: 8px; flex-wrap: wrap; }

#kbot-app .kbot-chip {
  background: var(--kb-green-lt);
  color: var(--kb-green-dk);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 13px; font-weight: 500;
}

#kbot-app .kbot-grand {
  font-size: 24px; font-weight: 700;
  color: var(--kb-green-deep);
}

/* ── Customer form ── */
#kbot-app .kbot-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#kbot-app .kbot-field label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--kb-muted);
  margin-bottom: 4px;
}

/* ── Action buttons ── */
#kbot-app .kbot-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
}

#kbot-app .kbot-btn-wa,
#kbot-app .kbot-btn-email {
  flex: 1; min-width: 200px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 20px;
  border-radius: var(--kb-radius);
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  border: none;
}

#kbot-app .kbot-btn-wa {
  background: var(--kb-wa); color: #fff;
}
#kbot-app .kbot-btn-wa:hover { background: var(--kb-wa-hov); }

#kbot-app .kbot-btn-email {
  background: var(--kb-surface); color: var(--kb-text);
  border: 1.5px solid var(--kb-border);
}
#kbot-app .kbot-btn-email:hover { border-color: var(--kb-text); background: #F9FAFB; }

/* ── Floating Cart Icon ── */
#kbot-cart-icon {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--kb-green);
  color: #fff;
  border-radius: 50px;
  padding: 13px 20px 13px 16px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(29,158,117,0.4);
  transform: translateY(90px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease, background 0.15s;
  user-select: none;
  pointer-events: none;
}

#kbot-cart-icon.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#kbot-cart-icon:hover { background: var(--kb-green-dk); }
#kbot-cart-icon:active { transform: scale(0.96); }

#kbot-cart-icon svg {
  flex-shrink: 0;
  stroke: #fff;
}

#kbot-cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #fff;
  color: var(--kb-green-dk);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

#kbot-cart-total {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
}

/* Pulse animation on summary card when cart icon clicked */
@keyframes kbot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(29,158,117,0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(29,158,117,0); }
  100% { box-shadow: 0 0 0 0 rgba(29,158,117,0); }
}
.kbot-summary-pulse { animation: kbot-pulse 0.6s ease-out; }

/* ── Toast ── */
#kbot-app .kbot-toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--kb-green-deep); color: #fff;
  padding: 11px 20px; border-radius: var(--kb-radius);
  font-size: 14px; font-weight: 500;
  transition: transform 0.28s ease; z-index: 9999;
  white-space: nowrap; pointer-events: none;
}
#kbot-app .kbot-toast.show { transform: translateX(-50%) translateY(0); }

/* ── Load More ── */
#kbot-app .kbot-loadmore-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: var(--kb-surface);
  color: var(--kb-green-dk);
  border: 1.5px solid var(--kb-green);
  border-radius: 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

#kbot-app .kbot-loadmore-btn:hover {
  background: var(--kb-green);
  color: #fff;
}

#kbot-app .kbot-loadmore-btn::before {
  content: '↓';
  font-size: 16px;
}

/* ── Empty state ── */
#kbot-app .kbot-empty {
  text-align: center; padding: 2rem;
  color: var(--kb-subtle); font-size: 13px;
}

/* ════════════════════════════════════════
   RESPONSIVE — Mobile card layout
   On screens ≤ 640px the table is hidden
   and replaced by stacked product cards.
════════════════════════════════════════ */

/* Mobile list hidden by default on desktop */
@media (min-width: 641px) {
  #kbot-app .kbot-mobile-list  { display: none !important; }
  #kbot-app .kbot-table-scroll { display: block; }
}

@media (max-width: 640px) {

  #kbot-app { padding: .6rem; gap: .6rem; }
  #kbot-app .kbot-catalog-card,
  #kbot-app .kbot-summary-card,
  #kbot-app .kbot-customer-card { padding: .75rem; }

  /* Hide desktop table, show mobile cards */
  #kbot-app .kbot-table-scroll { display: none !important; }
  #kbot-app .kbot-mobile-list  { display: flex; flex-direction: column; }

  /* ── Product card: two-row design ── */
  #kbot-app .kbot-mobile-card {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--kb-border);
    align-items: center;
    transition: background 0.1s;
  }
  #kbot-app .kbot-mobile-card:last-child { border-bottom: none; }
  #kbot-app .kbot-mobile-card.in-order {
    background: var(--kb-green-lt);
    border-radius: 8px;
    padding: 10px 8px;
    margin: 2px 0;
  }

  /* Photo — spans both rows on left */
  #kbot-app .kbot-mc-img,
  #kbot-app .kbot-mc-placeholder {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 60px; height: 60px;
    object-fit: contain;
    background: #F3F4F6;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    align-self: center;
  }

  /* Info — top-right cell */
  #kbot-app .kbot-mc-info {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding-bottom: 4px;
  }
  #kbot-app .kbot-mc-sku {
    font-family: 'DM Mono', 'Courier New', monospace;
    font-size: 11px; color: var(--kb-muted);
    display: block; margin-bottom: 1px;
  }
  #kbot-app .kbot-mc-meas {
    font-size: 12px; font-weight: 600; color: var(--kb-text);
    display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #kbot-app .kbot-mc-price {
    font-size: 14px; font-weight: 700; color: var(--kb-green-dk);
    display: block; margin-top: 2px;
  }
  #kbot-app .kbot-mc-pack {
    font-size: 11px; color: var(--kb-muted);
    display: block;
  }
  #kbot-app .kbot-mc-sub {
    font-size: 11px; font-weight: 600; color: var(--kb-green-dk);
    display: block; margin-top: 2px;
  }
  #kbot-app .kbot-mc-sub.hidden { display: none; }

  /* QTY controls — bottom-right cell */
  #kbot-app .kbot-mc-qty {
    grid-column: 2 / 4;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
  }
  #kbot-app .kbot-mc-qty .kbot-qty-wrap {
    display: flex; align-items: center; gap: 8px;
  }
  #kbot-app .kbot-mc-qty .kbot-qty-btn {
    width: 34px; height: 34px;
    font-size: 20px; border-radius: 8px;
    flex-shrink: 0;
  }
  #kbot-app .kbot-mc-qty .kbot-qty-val {
    font-size: 16px; font-weight: 600;
    min-width: 26px; text-align: center;
  }
  #kbot-app .kbot-mc-qty .kbot-qty-unit {
    font-size: 11px; color: var(--kb-muted);
  }

  /* Subtotal in qty row on mobile — shown inline */
  #kbot-app .kbot-mc-qty .kbot-mc-sub-inline {
    font-size: 13px; font-weight: 600;
    color: var(--kb-green-dk);
    margin-left: auto;
  }

  /* Form, summary, buttons */
  #kbot-app .kbot-form-grid { grid-template-columns: 1fr; }
  #kbot-app .kbot-grand     { font-size: 20px; }
  #kbot-app .kbot-btn-wa,
  #kbot-app .kbot-btn-email { min-width: 100%; padding: 13px; font-size: 14px; }

  /* Toolbar: stack search + dropdown */
  #kbot-app .kbot-toolbar { flex-direction: column; }
  #kbot-app .kbot-toolbar input,
  #kbot-app .kbot-toolbar select { width: 100%; }

  /* Cart icon */
  #kbot-cart-icon   { bottom: 14px; right: 14px; padding: 10px 14px 10px 12px; gap: 7px; }
  #kbot-cart-total  { font-size: 13px; }
}
