/* ════════════════════════════════════════════════════════
   MOBILE-SPECIFIC STYLES - Optimized for Touch Devices
   ════════════════════════════════════════════════════════ */

:root {
  --mobile-safe-top: max(env(safe-area-inset-top), 0.5rem);
  --mobile-safe-bottom: max(env(safe-area-inset-bottom), 0.5rem);
}

/* ── Base Mobile Styles ──────────────────────────────────── */

body {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ── Mobile Header (Auto-Hide on Scroll) ──────────────────── */

.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: white;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 90;
  transform: translateY(0);
  transition: transform 0.3s ease-out;
  padding-top: env(safe-area-inset-top);
}

.mobile-header.hide {
  transform: translateY(-100%);
}

#mobile-admin-content,
#mobile-customer-content {
  padding-top: 48px;
  padding-top: calc(48px + env(safe-area-inset-top));
}

/* ── Mobile Navigation ───────────────────────────────────── */

.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 100;
  padding-top: var(--mobile-safe-top);
}

.mobile-nav-title {
  font-weight: 700;
  font-size: 1.1rem;
  flex: 1;
}

.mobile-nav-actions {
  display: flex;
  gap: 0.5rem;
}

.mobile-back-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
}

.mobile-back-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

/* ── Mobile Content Area ─────────────────────────────────── */

.mobile-page {
  padding-bottom: var(--mobile-safe-bottom);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mobile-content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ── Mobile Forms ────────────────────────────────────────── */

.form-control {
  font-size: 16px;
  padding: 10px;
  min-height: 40px;
  border-radius: 8px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  display: block;
}

/* ── Mobile Buttons ──────────────────────────────────────── */

.btn {
  min-height: 48px;
  min-width: 48px;
  font-size: 1rem;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  touch-action: manipulation;
}

.btn-lg {
  min-height: 56px;
  padding: 16px 20px;
  font-size: 1.05rem;
}

.btn-sm {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.w-full {
  width: 100%;
}

/* ── Mobile Cards ────────────────────────────────────────── */

.card {
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-light);
}

.card-header {
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-weight: 700;
  font-size: 1rem;
}

/* ── Mobile Lists ────────────────────────────────────────── */

.mobile-list-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-list-item:last-child {
  border-bottom: none;
}

.mobile-list-item-main {
  flex: 1;
}

.mobile-list-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.mobile-list-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mobile-list-item-action {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Mobile Tables → Card Lists ──────────────────────────── */

table {
  width: 100%;
  margin-bottom: 1rem;
}

table thead {
  display: none;
}

table tr {
  display: block;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 1rem;
  padding: 1rem;
}

table td {
  display: block;
  padding: 0.5rem 0;
  text-align: left;
}

table td::before {
  content: attr(data-label);
  font-weight: 600;
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

/* ── Mobile Search/Filter ────────────────────────────────── */

.search-bar {
  margin-bottom: 1rem;
}

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-bar > * {
  width: 100%;
}

/* ── Mobile Modals ───────────────────────────────────────── */

.modal {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 16px;
  padding: 0;
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.modal-body {
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.5rem;
}

.modal-footer .btn {
  flex: 1;
}

/* ── Mobile Stats ────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.stat-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* ── Mobile Inputs ───────────────────────────────────────── */

input, select, textarea {
  width: 100%;
  font-size: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-light);
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
}

/* ── Mobile Cart ─────────────────────────────────────────── */

.cart-item {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  align-items: center;
}

.cart-item-thumb {
  font-size: 2rem;
  flex-shrink: 0;
}

.cart-item-info {
  flex: 1;
}

.cart-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.cart-item-price {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.qty-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.qty-val {
  width: 40px;
  text-align: center;
  font-weight: 600;
}

/* ── Mobile Product Cards ────────────────────────────────── */

.products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.product-card {
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-img {
  font-size: 3rem;
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
}

.product-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.product-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.product-sku {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.product-stock {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.product-price {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

/* ── Mobile Badges ───────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Mobile Utility ──────────────────────────────────────── */

.hide-mobile {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1rem 0;
}

/* ── Mobile Auth Pages ───────────────────────────────────── */

.mobile-auth-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(135deg, #000000, #333333);
}

.mobile-auth-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.mobile-auth-logo {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
}

.mobile-auth-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.mobile-auth-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ── Mobile Bottom Navigation ──────────────────────────── */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: white;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 99;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  color: var(--text-muted);
  cursor: pointer;
  gap: 2px;
  font-size: 0.65rem;
  font-weight: 500;
  border: none;
  background: none;
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-item span:first-child {
  font-size: 1.5rem;
}

.mobile-main-content {
  padding-bottom: 80px;
}

/* ── Mobile Toast ────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: var(--mobile-safe-bottom);
  left: 1rem;
  right: 1rem;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideUp 0.3s ease-out;
  z-index: 1000;
}

@keyframes slideUp {
  from {
    transform: translateY(120%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Mobile Responsive Spacing ───────────────────────────── */

.mt-2 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.p-1 { padding: 0.25rem; }

/* ── Mobile Orientation ──────────────────────────────────── */

@media (orientation: landscape) {
  .mobile-nav {
    height: 48px;
  }

  .mobile-page {
    padding-top: 60px;
  }

  .mobile-content {
    padding: 0.75rem;
  }
}

/* ── iPad/Large Mobile (600px+) ──────────────────────────── */

@media (min-width: 600px) {
  .products-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .filter-bar {
    flex-direction: row;
  }

  .filter-bar > * {
    width: auto;
    flex: 1;
  }

  .modal-footer {
    flex-direction: row;
  }

  .modal-footer .btn {
    flex: 1;
  }
}
