/* ==========================================================================
   sl-flow - Mobile-Dedicated Styling (mobile.css)
   Optimized for Smartphone & Tablet Touch Interfaces (iPhone 393px+, iPad)
   ========================================================================== */

@import url("base.css");

/* Mobile Layout Base */
body.is-mobile-device,
body {
  padding-bottom: 5.5rem; /* Room for mobile bottom bar */
  -webkit-tap-highlight-color: transparent;
}

.mobile-app-header {
  background: linear-gradient(180deg, #162038 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.mobile-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.4rem;
}

.mobile-brand-title {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  color: #f8fafc;
  flex-shrink: 0;
}

.mobile-product-select-wrap {
  flex: 1;
  min-width: 0;
  max-width: 140px;
}

.mobile-product-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #38bdf8;
  padding: 0.25rem 0.4rem;
  font-size: 0.775rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Mobile Controls & Lot Selector */
.mobile-control-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(19, 27, 46, 0.6);
  border-bottom: 1px solid var(--border-color);
}

.mobile-lot-selector-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  position: relative;
}

.mobile-cal-wrap {
  position: relative;
  flex-shrink: 0;
}

.btn-mobile-cal {
  padding: 0.4rem 0.6rem;
  font-size: 0.775rem;
  font-weight: 600;
  white-space: nowrap;
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.mobile-shipment-select {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* Mobile Calendar Popup */
.mobile-cal-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 290px;
  max-width: 90vw;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  padding: 0.75rem;
  z-index: 200;
}

.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.cal-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: #f8fafc;
}

.cal-nav-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.cal-nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.725rem;
  border-radius: 4px;
  cursor: default;
  position: relative;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
}

.cal-day-cell.cal-empty {
  background: transparent;
}

.cal-day-cell.cal-today {
  border: 1px solid #38bdf8;
  font-weight: 700;
  color: #f8fafc;
}

.cal-day-cell.cal-has-data {
  background: rgba(56, 189, 248, 0.12);
  cursor: pointer;
  font-weight: 700;
  color: #f8fafc;
}

.cal-day-cell.cal-has-data:hover,
.cal-day-cell.cal-has-data:active {
  background: rgba(56, 189, 248, 0.3);
}

.cal-day-cell.cal-selected {
  outline: 2px solid #38bdf8;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  position: absolute;
  bottom: 2px;
}

.cal-dot-confirmed {
  background: var(--color-ok);
}

.cal-dot-open {
  background: #38bdf8;
}

.cal-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-subtle);
}

/* Mobile Sticky Stock Balance Chips */
.mobile-sticky-balance {
  display: block;
  position: sticky;
  top: 50px;
  z-index: 90;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
}

.mobile-balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.mobile-balance-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mobile-chips-scroll {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.mobile-chips-scroll::-webkit-scrollbar {
  display: none;
}

.mobile-chip {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
  font-size: 0.725rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.m-chip-size {
  color: var(--text-primary);
  font-weight: 700;
}

.m-chip-rem {
  font-weight: 700;
}

.m-chip-status {
  font-size: 0.675rem;
  opacity: 0.9;
}

/* OK / Green */
.mobile-chip-ok,
.mobile-chip-green {
  border-color: var(--color-ok-border);
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

/* Surplus / Yellow */
.mobile-chip-surplus,
.mobile-chip-yellow {
  border-color: var(--color-surplus-border);
  background: var(--color-surplus-bg);
  color: var(--color-surplus);
}

/* Shortage / Red */
.mobile-chip-shortage,
.mobile-chip-red {
  border-color: var(--color-shortage-border);
  background: var(--color-shortage-bg);
  color: var(--color-shortage);
}

.m-cust-remarks-tag {
  display: inline-block;
  padding: 0.05rem 0.3rem;
  font-size: 0.675rem;
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 3px;
  color: #38bdf8;
  font-weight: 600;
}

/* Quick Filter Chips */
.mobile-filter-chips-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.m-filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 26px;
}

.m-filter-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.m-filter-chip.active {
  background: var(--color-brand);
  border-color: var(--color-brand-hover);
  color: #ffffff;
}

/* Mobile Customer Cards Grid */
.mobile-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem 6rem;
}

.mobile-customer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mobile-customer-card.has-order {
  border-left: 4px solid var(--color-ok);
  background: linear-gradient(180deg, rgba(19, 27, 46, 0.95) 0%, rgba(16, 24, 43, 0.95) 100%);
}

.mobile-customer-card:focus-within {
  border-color: var(--border-focus);
}

/* Accordion Header */
.m-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 0.5rem;
}

.mobile-customer-card.is-expanded .m-card-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.5rem;
  margin-bottom: 0.6rem;
}

.m-card-cust-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex-grow: 1;
}

.m-card-cust-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.m-card-cust-code {
  font-size: 0.725rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.m-card-meta-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.m-card-total-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.m-card-toggle-icon {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.mobile-customer-card.is-expanded .m-card-toggle-icon {
  transform: rotate(180deg);
}

/* Accordion Body */
.m-card-body {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
}

.mobile-customer-card.is-expanded .m-card-body {
  display: flex;
}

/* Variant Rows in Mobile Card */
.m-variant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.m-variant-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

/* Stepper Quantity Modifier */
.m-stepper-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.m-btn-step {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
  width: 38px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
}

.m-btn-step:active {
  background: rgba(255, 255, 255, 0.15);
}

.m-input-qty {
  width: 52px;
  height: 36px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  font-family: var(--font-mono);
}

.m-input-qty.zero-val {
  color: var(--text-muted);
}

/* Card Carrier & Remarks Row */
.m-card-carrier-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.m-card-select-carrier {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  outline: none;
}

.m-card-input-remarks {
  flex: 2;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  outline: none;
}

/* Floating Bottom Action Bar */
.mobile-bottom-bar {
  display: block;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 200;
}

.mobile-bottom-bar-inner {
  display: flex;
  gap: 0.35rem;
  max-width: 600px;
  margin: 0 auto;
}

.btn-mobile-act {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-mobile-act:active {
  transform: scale(0.96);
}

.btn-mobile-act.primary {
  background: var(--color-brand);
  border-color: var(--color-brand-hover);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.btn-mobile-act .icon {
  font-size: 1.15rem;
  line-height: 1;
}

/* Mobile New Shipment Modal Styles */
.m-var-carryover-input.is-locked {
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.85;
}
