/* ============================================================
   RESPONSIVE.CSS — Mobile-First Breakpoints
   Hydrogel Film Business POS
   ============================================================ */

/* ─── BASE (Mobile 360px–430px) ─────────────────────────── */

/* Hide sidebar on mobile */
.sidebar {
  transform: translateX(-100%);
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-xl);
}

/* Main content fills full width on mobile */
.main-content {
  margin-left: 0;
}

/* Admin layout on mobile = stacked */
.admin-layout .main-content {
  margin-left: 0;
}

/* Bottom nav visible on mobile */
.bottom-nav { display: flex; }

/* Header adjustments */
.app-header {
  height: var(--header-height);
}

/* Content padding on mobile */
.content-area {
  padding: var(--space-4) var(--space-3);
}

/* Grid overrides for mobile */
.grid-2  { grid-template-columns: repeat(2, 1fr); }
.grid-3  { grid-template-columns: repeat(2, 1fr); }
.grid-4  { grid-template-columns: repeat(2, 1fr); }

/* Dashboard stat cards */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

/* Full-width tables */
.table-wrapper { border-radius: var(--radius-lg); }

/* POS Layout */
.pos-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - var(--nav-bottom-height));
  overflow: hidden;
}

.pos-products { flex: 1; overflow-y: auto; padding: var(--space-3); }
.pos-cart {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  max-height: 45vh;
  overflow-y: auto;
}

/* Cart badge */
.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal full-screen on mobile */
.modal-full .modal {
  max-height: 100vh;
  border-radius: 0;
}

/* Large touch targets */
.touch-target {
  min-height: 48px;
  min-width: 48px;
}

/* Compact header for mobile */
.page-header-mobile {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

/* ─── SM (480px+) ───────────────────────────────────────── */
@media (min-width: 480px) {
  .content-area { padding: var(--space-4); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ─── MD (768px — Tablet) ───────────────────────────────── */
@media (min-width: 768px) {
  /* Show sidebar on tablet+ for admin */
  .admin-layout .sidebar {
    transform: translateX(0);
    position: fixed;
  }

  .admin-layout .main-content,
  .admin-layout .app-header {
    margin-left: var(--sidebar-width);
  }

  /* Hide mobile bottom nav on desktop admin */
  .admin-layout .bottom-nav {
    display: none;
  }

  /* Page no longer needs bottom nav padding on admin */
  .admin-layout .page {
    padding-bottom: 0;
  }

  /* Grid */
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats { grid-template-columns: repeat(4, 1fr); }

  /* Product grid */
  .product-grid { grid-template-columns: repeat(4, 1fr); }

  /* POS 2-column layout */
  .pos-layout {
    flex-direction: row;
    height: calc(100vh - var(--header-height));
  }
  .pos-products {
    flex: 1;
    border-right: 1px solid var(--border);
  }
  .pos-cart {
    width: 360px;
    max-height: none;
    border-top: none;
    display: flex;
    flex-direction: column;
  }

  /* Content area */
  .content-area { padding: var(--space-6); }
}

/* ─── LG (1024px — Desktop) ─────────────────────────────── */
@media (min-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .dashboard-stats { grid-template-columns: repeat(4, 1fr); }

  .product-grid { grid-template-columns: repeat(5, 1fr); }

  .content-area {
    padding: var(--space-6) var(--space-8);
    max-width: var(--content-max);
  }

  .pos-cart { width: 400px; }
}

/* ─── XL (1280px) ────────────────────────────────────────── */
@media (min-width: 1280px) {
  .sidebar { width: 280px; }
  .admin-layout .main-content,
  .admin-layout .app-header { margin-left: 280px; }
}

/* ─── Landscape Mobile ───────────────────────────────────── */
@media (max-width: 767px) and (orientation: landscape) {
  .bottom-nav { height: 56px; }
  :root { --nav-bottom-height: 56px; }

  .pos-layout {
    flex-direction: row;
    height: calc(100vh - var(--header-height) - var(--nav-bottom-height));
  }
  .pos-products { flex: 1; border-right: 1px solid var(--border); }
  .pos-cart { width: 300px; max-height: none; border-top: none; }

  .numpad-key { height: 48px; }
}

/* ─── Small Phones (360px and below) ─────────────────────── */
@media (max-width: 360px) {
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .payment-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card-value { font-size: var(--text-xl); }
  .btn-xl { padding: 14px var(--space-5); font-size: var(--text-base); }
}

/* ─── Print Styles ───────────────────────────────────────── */
@media print {
  .bottom-nav,
  .sidebar,
  .app-header,
  .fab,
  .btn,
  .modal-overlay,
  .toast-container { display: none !important; }

  .main-content { margin: 0 !important; }
  .content-area { padding: 0 !important; max-width: none !important; }
  body { background: white; }

  .print-visible { display: block !important; }
  .print-hidden { display: none !important; }
}

/* ─── Sidebar Overlay ────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: calc(var(--z-nav) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: all;
}

@media (min-width: 768px) {
  .admin-layout .sidebar-overlay { display: none; }
}

/* ─── Responsive Tables ──────────────────────────────────── */
@media (max-width: 639px) {
  /* Hide less important columns on mobile */
  .table-hide-mobile { display: none !important; }

  /* Make action column sticky */
  .table-actions {
    position: sticky;
    right: 0;
    background: var(--bg-surface);
  }
}

/* ─── Responsive Typography ──────────────────────────────── */
@media (max-width: 375px) {
  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }
  .stat-card-value { font-size: var(--text-xl); }
}

/* ─── No-touch / Hover Devices ───────────────────────────── */
@media (hover: hover) {
  .btn:hover { opacity: 0.9; }
  .list-item.clickable:hover { background: var(--gray-50); }
  .product-card:hover { transform: translateY(-1px); }
}

/* ─── Safe Area Support (Notched Phones) ─────────────────── */
@supports (padding: max(0px)) {
  .bottom-nav {
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
    height: calc(var(--nav-bottom-height) + env(safe-area-inset-bottom, 0px));
  }

  :root {
    --nav-bottom-height: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .page {
    padding-bottom: var(--nav-bottom-height);
  }
}

/* ─── PWA Standalone Mode ────────────────────────────────── */
@media (display-mode: standalone) {
  .app-header {
    padding-top: env(safe-area-inset-top, 0);
    height: calc(var(--header-height) + env(safe-area-inset-top, 0));
  }
}
