/* iOS Bottom Sheets */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-spring);
}

.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 90vh;
  background: var(--bg-card);
  border-top-left-radius: var(--radius-2xl);
  border-top-right-radius: var(--radius-2xl);
  box-shadow: var(--shadow-floating);
  z-index: 1000;
  transform: translateY(105%);
  transition: transform var(--duration-normal) var(--ease-spring);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.sheet-handle-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: grab;
}

.sheet-handle {
  width: 38px;
  height: 5px;
  background: var(--text-quaternary);
  border-radius: var(--radius-full);
}

.sheet-header {
  padding: 12px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid var(--separator-subtle);
}

.sheet-title {
  font-size: var(--font-size-title-3);
  font-weight: 700;
}

.sheet-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--fill-tertiary);
  color: var(--text-secondary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sheet-footer {
  padding: 16px 20px calc(16px + var(--safe-bottom));
  border-top: 0.5px solid var(--separator-subtle);
  background: var(--bg-card);
  display: flex;
  gap: 12px;
}

/* iOS Segmented Controls */
.segmented-control {
  display: flex;
  background: var(--fill-tertiary);
  padding: 3px;
  border-radius: var(--radius-md);
  position: relative;
  user-select: none;
}

.segment-item {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-spring);
  z-index: 1;
}

.segment-item.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* iOS Toggle Switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--fill-secondary);
  transition: .3s cubic-bezier(0.32, 0.72, 0, 1);
  border-radius: 31px;
}

.ios-slider:before {
  position: absolute;
  content: "";
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s cubic-bezier(0.32, 0.72, 0, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.ios-switch input:checked + .ios-slider {
  background-color: var(--color-success);
}

.ios-switch input:checked + .ios-slider:before {
  transform: translateX(20px);
}

/* Quantity Stepper */
.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--fill-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
}

.stepper-btn {
  width: 34px;
  height: 34px;
  border-radius: calc(var(--radius-md) - 3px);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  transition: background var(--duration-fast);
}

.stepper-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stepper-value {
  min-width: 36px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

/* Badge Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform var(--duration-fast);
}

.badge:hover {
  transform: scale(1.04);
}

.badge-sale {
  background: var(--color-danger);
  color: #FFFFFF;
}

.badge-new {
  background: var(--color-primary);
  color: #FFFFFF;
}

.badge-bestseller {
  background: var(--color-warning);
  color: #FFFFFF;
}

.badge-success {
  background: var(--color-success-subtle);
  color: var(--color-success);
}

.badge-tinted {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

/* Smooth Page Transition Animation */
#app-content {
  animation: smoothPageFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes smoothPageFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chip filter pill */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--fill-quaternary);
  border: 1px solid var(--border-subtle);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-spring);
}

.chip:hover, .chip.active {
  background: var(--color-primary);
  color: #FFFFFF;
  border-color: var(--color-primary);
}

.chip-remove {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-left: 2px;
}

/* Floating Compare Tray */
.compare-tray {
  position: fixed;
  bottom: calc(var(--tabbar-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: 10px 16px;
  box-shadow: var(--shadow-floating);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 800;
  transition: transform var(--duration-normal) var(--ease-spring);
  max-width: 90vw;
}

@media (min-width: 992px) {
  .compare-tray {
    bottom: 24px;
  }
}

.compare-tray.active {
  transform: translateX(-50%) translateY(0);
}

.compare-tray-items {
  display: flex;
  gap: 8px;
}

.compare-tray-thumb {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #FFFFFF;
}

.compare-tray-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-tray-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* iOS Toast Notification (Spring-in Top Notification) */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}

.toast {
  background: var(--bg-glass-strong);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  animation: toastSlideIn var(--duration-normal) var(--ease-spring);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toast-message {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

/* iOS Grouped Inset List (Account / Settings) */
.grouped-list {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
}

.grouped-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  position: relative;
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--duration-fast);
}

.grouped-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 56px;
  right: 0;
  bottom: 0;
  height: 0.5px;
  background: var(--separator-subtle);
}

.grouped-item:hover {
  background: var(--fill-quaternary);
  opacity: 1;
}

.grouped-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 14px;
  color: #fff;
  flex-shrink: 0;
}

.grouped-content {
  flex: 1;
}

.grouped-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.grouped-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.grouped-chevron {
  color: var(--text-tertiary);
  margin-left: 8px;
}

/* Shimmer Skeleton Loaders */
.skeleton {
  background: linear-gradient(90deg, var(--fill-quaternary) 25%, var(--fill-tertiary) 50%, var(--fill-quaternary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =========================================================
   Apple iOS Animated Thermal Receipt & Invoice Dispenser
   ========================================================= */

@keyframes receiptFeedOut {
  0% {
    max-height: 0;
    opacity: 0;
    transform: translateY(-24px);
  }
  20% {
    opacity: 1;
  }
  100% {
    max-height: 1200px;
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes printPulseLed {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px #34C759; }
  50% { opacity: 0.4; box-shadow: none; }
}

.thermal-dispenser-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.thermal-printer-bezel {
  background: linear-gradient(180deg, #2C2C2E 0%, #1C1C1E 100%);
  border-radius: 26px 26px 0 0;
  padding: 16px 22px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  width: 100%;
}

.thermal-printer-slot {
  height: 8px;
  background: #000000;
  border-radius: 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.1);
  margin-top: 10px;
  position: relative;
}

.thermal-receipt-paper {
  background: #FFFFFF;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", Menlo, Consolas, monospace;
  padding: 24px 22px 28px;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 20px 48px -12px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  animation: receiptFeedOut 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: top center;
  width: 100%;
}

.receipt-jagged-edge {
  height: 12px;
  width: 100%;
  background: linear-gradient(135deg, #FFFFFF 5px, transparent 0), linear-gradient(-135deg, #FFFFFF 5px, transparent 0);
  background-size: 14px 14px;
  background-position: left bottom;
  position: absolute;
  bottom: -6px;
  left: 0;
}

/* =========================================================
   Universal Neumorphism for All Portals (Admin, Rider, Account)
   ========================================================= */

.stat-card, .delivery-run-card, .account-card, .table-card {
  background: #F4F7FB !important;
  border: 1px solid rgba(255, 255, 255, 0.85) !important;
  border-radius: 22px !important;
  box-shadow: 7px 7px 18px rgba(166, 180, 200, 0.36), -7px -7px 18px rgba(255, 255, 255, 0.95) !important;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.stat-card:hover, .delivery-run-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 9px 9px 24px rgba(166, 180, 200, 0.44), -9px -9px 24px #ffffff !important;
}

.form-control, .form-input {
  background: #EEF2F7 !important;
  border: 1px solid rgba(215, 225, 238, 0.6) !important;
  border-radius: 14px !important;
  box-shadow: inset 3px 3px 6px rgba(166, 180, 200, 0.38), inset -3px -3px 6px #ffffff !important;
  transition: all 0.2s ease !important;
}

.form-control:focus, .form-input:focus {
  box-shadow: inset 3px 3px 6px rgba(166, 180, 200, 0.45), inset -3px -3px 6px #ffffff, 0 0 0 3px rgba(0, 122, 255, 0.15) !important;
  border-color: #007AFF !important;
  outline: none !important;
}

@media print {
  body * {
    visibility: hidden;
  }
  .printable-receipt-target, .printable-receipt-target * {
    visibility: visible;
  }
  .printable-receipt-target {
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .thermal-printer-bezel, .thermal-action-bar, .thermal-dispenser-overlay {
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  .no-print {
    display: none !important;
  }
}
