/* =============================================
   SPRINGS MODULE — Inventory / CRM / Orders
   ============================================= */

/* ---- Nav item ---- */
.nav-item.springs-nav { border-top: 1px solid #e2e8f0; margin-top: 10px; padding-top: 10px; }

/* ---- Springs wrapper ---- */
#view-springs { padding: 0; }

.springs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 0;
  flex-wrap: wrap;
  gap: 10px;
}
.springs-header h1 { margin: 0; font-size: 20px; font-weight: 700; color: #1e293b; }
.springs-header-actions { display: flex; gap: 8px; align-items: center; }

/* ---- Tab bar ---- */
.springs-tabs {
  display: flex;
  gap: 0;
  padding: 14px 24px 0;
  border-bottom: 2px solid #e2e8f0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.springs-tabs::-webkit-scrollbar { display: none; }
.springs-tab {
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.springs-tab.active { color: #3b5bdb; border-bottom-color: #3b5bdb; }
.springs-tab:hover:not(.active) { color: #374151; }

/* ---- Content area ---- */
#springs-content { padding: 20px 24px; }

/* ---- Section header ---- */
.sp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.sp-section-header h2 { margin: 0; font-size: 17px; font-weight: 700; color: #1e293b; }

/* ---- Empty state ---- */
.sp-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  padding: 40px 20px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px dashed #e2e8f0;
}

/* ==============================
   CATALOG
   ============================== */
.sp-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.sp-product-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}
.sp-product-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-1px); }
.sp-product-photo { height: 100px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sp-product-photo img { width: 100%; height: 100%; object-fit: cover; }
.sp-no-photo { font-size: 40px; opacity: .4; }
.sp-product-info { padding: 12px; }
.sp-product-name { font-weight: 700; font-size: 13px; color: #1e293b; margin-bottom: 2px; }
.sp-product-sku { font-size: 11px; color: #94a3b8; font-family: monospace; margin-bottom: 8px; }
.sp-product-prices { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.sp-price-customer { font-size: 14px; font-weight: 700; color: #3b5bdb; }
.sp-price-cost { font-size: 11px; color: #64748b; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }
.sp-margin { font-size: 11px; color: #10b981; background: #ecfdf5; padding: 2px 6px; border-radius: 4px; }
.sp-stock-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; }
.sp-stock-badge { padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.sp-weight { color: #94a3b8; }
.stock-ok { background: #ecfdf5; color: #059669; }
.stock-low { background: #fffbeb; color: #d97706; }
.stock-out { background: #fef2f2; color: #dc2626; }

/* ==============================
   CUSTOMERS
   ============================== */
.sp-customer-list { display: flex; flex-direction: column; gap: 10px; }
.sp-customer-row {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid #e2e8f0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow .15s;
  gap: 12px;
}
.sp-customer-row:hover { box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.sp-cust-main { flex: 1; }
.sp-cust-name { font-weight: 700; font-size: 14px; color: #1e293b; }
.sp-cust-contact { font-size: 12px; color: #64748b; margin-top: 2px; }
.sp-cust-addr { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.sp-cust-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.sp-cust-orders { font-size: 11px; color: #94a3b8; }
.sp-bal-badge { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.bal-owed { background: #fef2f2; color: #dc2626; }
.bal-credit { background: #ecfdf5; color: #059669; }
.bal-zero { background: #f1f5f9; color: #64748b; }

/* Customer detail grid */
.sp-cust-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}
.sp-detail-card {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
}
.sp-detail-label { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }

/* ==============================
   ORDERS
   ============================== */
.sp-order-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sp-filter-btn {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid #e2e8f0;
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  transition: all .15s;
}
.sp-filter-btn.active { background: #3b5bdb; color: white; border-color: #3b5bdb; }
.sp-order-list { display: flex; flex-direction: column; gap: 10px; }
.sp-order-row {
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: box-shadow .15s;
}
.sp-order-row:hover { box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.sp-order-row-left { flex: 1; }
.sp-order-row-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sp-order-num { font-family: monospace; font-weight: 700; font-size: 14px; color: #1e293b; }
.sp-order-cust { font-size: 13px; color: #374151; margin-top: 2px; }
.sp-order-items-preview { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.sp-order-total { font-weight: 700; font-size: 15px; color: #1e293b; }
.sp-order-status-badge {
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  text-transform: capitalize;
}
.sp-order-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid #e2e8f0;
}
.sp-order-mini:hover { background: #e2e8f0; }
.sp-order-mini .sp-order-total { margin-left: auto; font-size: 13px; }

/* ---- Add item row ---- */
.sp-add-item-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.sp-add-item-row select { font-size: 13px; padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 8px; background: white; }

/* ---- Items table ---- */
.sp-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sp-items-table thead tr { background: #f1f5f9; }
.sp-items-table th { padding: 8px 10px; text-align: left; font-size: 11px; text-transform: uppercase; color: #64748b; font-weight: 700; letter-spacing: .4px; }
.sp-items-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; color: #374151; vertical-align: middle; }
.sp-items-table input[type="number"] { border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 6px; font-size: 13px; }
.sp-sku { color: #94a3b8; font-size: 11px; font-family: monospace; }

/* ---- Order totals ---- */
.sp-order-totals {
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 16px;
  max-width: 300px;
  margin-left: auto;
}
.sp-totals-row { display: flex; justify-content: space-between; font-size: 13px; color: #374151; padding: 3px 0; }
.sp-totals-grand { font-weight: 800; font-size: 16px; color: #1e293b; border-top: 2px solid #e2e8f0; padding-top: 8px; margin-top: 4px; }

/* ---- Status stepper ---- */
.sp-status-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 4px;
}
.sp-step {
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  background: #f1f5f9;
  color: #94a3b8;
}
.sp-step.active { background: #3b5bdb; color: white; }
.sp-step.done { background: #ecfdf5; color: #059669; }
.sp-step-arrow { color: #cbd5e1; font-size: 16px; padding: 0 2px; }

/* ---- Order detail header ---- */
.sp-order-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: #374151;
  line-height: 1.6;
  gap: 12px;
}

/* ---- Freight section ---- */
.sp-freight-section {
  background: #f0f4ff;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
}
.sp-freight-info-box {
  background: #f0f4ff;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  margin-bottom: 0;
}
.sp-freight-info-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.sp-freight-info-row:last-child { border-bottom: none; }
.sp-freight-info-row span:first-child { font-weight: 700; min-width: 90px; color: #374151; }
.sp-freight-info-row span:last-child { color: #4b5563; }
.sp-detail-pair { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.sp-detail-pair span:first-child { color: #94a3b8; font-size: 11px; }
.sp-detail-pair span:last-child { font-weight: 600; color: #1e293b; }

/* ==============================
   REPORTS
   ============================== */
.sp-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}
.sp-stat-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  text-align: center;
}
.sp-stat-card.sp-stat-warn { border-color: #fbbf24; }
.sp-stat-card.sp-stat-ok { border-color: #34d399; }
.sp-stat-card.sp-stat-danger { border-color: #f87171; }
.sp-stat-num { font-size: 22px; font-weight: 800; color: #1e293b; }
.sp-stat-label { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.sp-alert-list { display: flex; flex-direction: column; gap: 8px; }
.sp-alert-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: 13px;
}

/* ==============================
   MODALS (Springs-specific)
   ============================== */
.sp-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.sp-modal-box {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sp-modal-large { max-width: 760px; }
.sp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.sp-modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: #1e293b; }
.sp-modal-close {
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  color: #64748b;
  transition: background .15s;
}
.sp-modal-close:hover { background: #e2e8f0; }
.sp-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.sp-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Form fields ---- */
.sp-field-group { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.sp-field-group label { font-size: 12px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: .4px; }
.sp-field-group input, .sp-field-group select, .sp-field-group textarea {
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-size: max(14px, 16px); /* iOS zoom prevention */
  color: #1e293b;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.sp-field-group input:focus, .sp-field-group select:focus, .sp-field-group textarea:focus {
  border-color: #3b5bdb;
  box-shadow: 0 0 0 3px rgba(59,91,219,.1);
}
.sp-field-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sp-field-row > .sp-field-group { min-width: 120px; }
.sp-field-group { margin-bottom: 12px; }

/* ==============================
   INVOICE
   ============================== */
.sp-invoice {
  font-family: Arial, sans-serif;
  color: #1e293b;
  max-width: 700px;
  margin: 0 auto;
}
.sp-invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 20px;
}
.sp-invoice-from { flex: 1; }
.sp-invoice-meta { text-align: right; }
.sp-invoice-title { font-size: 32px; font-weight: 800; color: #1e293b; letter-spacing: -1px; }
.sp-invoice-num { font-size: 14px; color: #64748b; font-family: monospace; margin-top: 2px; }
.sp-invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 28px;
  font-size: 13px;
  line-height: 1.7;
}
.sp-invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.sp-invoice-table thead tr { background: #1e293b; color: white; }
.sp-invoice-table th { padding: 10px 12px; font-size: 12px; text-align: left; }
.sp-invoice-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.sp-invoice-totals { max-width: 260px; margin-left: auto; margin-bottom: 20px; }
.sp-inv-total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: #374151; }
.sp-inv-grand { font-weight: 800; font-size: 18px; color: #1e293b; border-top: 2px solid #1e293b; padding-top: 10px; margin-top: 4px; }

/* ==============================
   SETTINGS
   ============================== */
.sp-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

/* ==============================
   INVENTORY
   ============================== */
.sp-inv-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  margin-bottom: 2px;
}
.sp-reserved-badge {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: #fef2f2;
  color: #dc2626;
}
/* Quick stock +/- buttons on product card */
.sp-quick-stock {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
.sp-sq-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: opacity .15s;
}
.sp-sq-btn:hover { opacity: .8; }
.sp-sq-in  { background: #ecfdf5; color: #059669; }
.sp-sq-out { background: #fef2f2; color: #dc2626; }

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 768px) {
  #springs-content { padding: 14px 12px; }
  .springs-header { padding: 14px 12px 0; }
  .springs-tabs { padding: 10px 12px 0; }
  .sp-catalog-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .sp-modal-box { max-height: 95vh; border-radius: 12px; }
  .sp-modal-large { max-width: 100%; }
  .sp-field-row { flex-direction: column; gap: 0; }
  .sp-invoice-parties { grid-template-columns: 1fr; gap: 14px; }
  .sp-cust-detail-grid { grid-template-columns: 1fr; }
  .sp-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sp-status-stepper { justify-content: flex-start; }
}
