/* ============================================
   NEXX BURGER RESPONSIVE DESIGN SYSTEM
   rem-based, mobile-first responsive design
   ============================================ */

/* ============================================
   DESIGN TOKENS - Core Variables (rem-based)
   ============================================ */

:root {
  /* === BREAKPOINTS (for reference in JS if needed) === */
  --nb-bp-xs: 320px;
  --nb-bp-sm: 360px;
  --nb-bp-md: 768px;
  --nb-bp-lg: 1024px;
  --nb-bp-xl: 1280px;

  /* === COLOR PALETTE === */
  /* Brand Colors - Nexx Burger Red */
  --nb-brand-primary: #d32f2f;
  --nb-brand-secondary: #b71c1c;
  --nb-brand-dark: #8b0000;
  --nb-brand-light: #f44336;
  --nb-brand-lighter: #ffebee;
  --nb-brand-shadow: rgba(211, 47, 47, 0.3);
  --nb-brand-shadow-hover: rgba(211, 47, 47, 0.4);

  /* Neutral Colors */
  --nb-white: #ffffff;
  --nb-gray-50: #fafafa;
  --nb-gray-100: #f5f6fa;
  --nb-gray-200: #e8e8e8;
  --nb-gray-300: #d0d0d0;
  --nb-gray-400: #a0a0a0;
  --nb-gray-500: #707070;
  --nb-gray-600: #505050;
  --nb-gray-700: #333333;
  --nb-gray-800: #1a1a1a;
  --nb-gray-900: #0a0a0a;

  /* Semantic Colors */
  --nb-success: #4caf50;
  --nb-success-light: #e8f5e9;
  --nb-success-dark: #2e7d32;
  --nb-warning: #ff9800;
  --nb-warning-light: #fff3e0;
  --nb-warning-dark: #e65100;
  --nb-error: #f44336;
  --nb-error-light: #ffebee;
  --nb-error-dark: #c62828;
  --nb-info: #2196f3;
  --nb-info-light: #e3f2fd;
  --nb-info-dark: #1565c0;

  /* === REM-BASED SPACING SCALE (1rem = 16px base) === */
  --nb-space-0: 0;
  --nb-space-1: 0.25rem;   /* 4px */
  --nb-space-2: 0.5rem;    /* 8px */
  --nb-space-3: 0.75rem;   /* 12px */
  --nb-space-4: 1rem;      /* 16px */
  --nb-space-5: 1.25rem;   /* 20px */
  --nb-space-6: 1.5rem;    /* 24px */
  --nb-space-8: 2rem;      /* 32px */
  --nb-space-10: 2.5rem;   /* 40px */
  --nb-space-12: 3rem;     /* 48px */
  --nb-space-16: 4rem;     /* 64px */
  --nb-space-20: 5rem;     /* 80px */
  --nb-space-24: 6rem;     /* 96px */

  /* === REM-BASED TYPOGRAPHY SCALE === */
  --nb-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --nb-font-size-xs: 0.75rem;    /* 12px */
  --nb-font-size-sm: 0.8125rem;  /* 13px */
  --nb-font-size-base: 0.9375rem; /* 15px */
  --nb-font-size-md: 1rem;       /* 16px */
  --nb-font-size-lg: 1.125rem;   /* 18px */
  --nb-font-size-xl: 1.25rem;    /* 20px */
  --nb-font-size-2xl: 1.5rem;    /* 24px */
  --nb-font-size-3xl: 1.75rem;   /* 28px */
  --nb-font-size-4xl: 2rem;      /* 32px */
  --nb-font-size-5xl: 2.5rem;    /* 40px */

  /* Font Weights */
  --nb-font-weight-normal: 400;
  --nb-font-weight-medium: 500;
  --nb-font-weight-semibold: 600;
  --nb-font-weight-bold: 700;

  /* Line Heights */
  --nb-line-height-tight: 1.25;
  --nb-line-height-normal: 1.5;
  --nb-line-height-relaxed: 1.75;

  /* === BORDER RADIUS (rem-based) === */
  --nb-radius-sm: 0.5rem;    /* 8px */
  --nb-radius-md: 0.75rem;   /* 12px */
  --nb-radius-lg: 1rem;      /* 16px */
  --nb-radius-xl: 1.25rem;   /* 20px */
  --nb-radius-2xl: 1.5rem;   /* 24px */
  --nb-radius-full: 9999px;

  /* === SHADOWS === */
  --nb-shadow-sm: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.08), 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.06);
  --nb-shadow-md: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1), 0 0.125rem 0.25rem rgba(0, 0, 0, 0.06);
  --nb-shadow-lg: 0 0.75rem 1.75rem rgba(0, 0, 0, 0.12), 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
  --nb-shadow-xl: 0 1.25rem 2.5rem rgba(0, 0, 0, 0.15), 0 0.75rem 1.5rem rgba(0, 0, 0, 0.1);
  --nb-shadow-brand: 0 0.25rem 0.75rem rgba(211, 47, 47, 0.25);
  --nb-shadow-brand-hover: 0 0.375rem 1.25rem rgba(211, 47, 47, 0.35);

  /* === TRANSITIONS === */
  --nb-transition-fast: 150ms ease;
  --nb-transition-normal: 250ms ease;
  --nb-transition-slow: 350ms ease;
  --nb-transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === Z-INDEX SCALE === */
  --nb-z-dropdown: 100;
  --nb-z-sticky: 200;
  --nb-z-modal-backdrop: 900;
  --nb-z-modal: 1000;
  --nb-z-toast: 1100;
  --nb-z-tooltip: 1200;

  /* === TOUCH TARGET (WCAG 2.1 AA) === */
  --nb-touch-target: 2.75rem; /* 44px minimum */
  --nb-touch-target-lg: 3rem; /* 48px for primary actions */

  /* === RESPONSIVE CONTAINER WIDTHS === */
  --nb-container-xs: 100%;
  --nb-container-sm: 100%;
  --nb-container-md: 45rem;    /* 720px */
  --nb-container-lg: 60rem;    /* 960px */
  --nb-container-xl: 75rem;    /* 1200px */
  --nb-container-2xl: 87.5rem; /* 1400px */
}

/* ============================================
   RESPONSIVE CONTAINER SYSTEM
   ============================================ */

.nb-container {
  width: 100%;
  max-width: var(--nb-container-xl);
  margin-inline: auto;
  padding-inline: clamp(var(--nb-space-3), 4vw, var(--nb-space-6));
}

.nb-container-fluid {
  width: 100%;
  padding-inline: clamp(var(--nb-space-3), 4vw, var(--nb-space-6));
}

.nb-container-narrow {
  width: 100%;
  max-width: var(--nb-container-md);
  margin-inline: auto;
  padding-inline: clamp(var(--nb-space-3), 4vw, var(--nb-space-6));
}

/* ============================================
   RESPONSIVE GRID SYSTEM
   ============================================ */

.nb-grid {
  display: grid;
  gap: var(--nb-space-4);
}

.nb-grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.nb-grid-1 { grid-template-columns: 1fr; }
.nb-grid-2 { grid-template-columns: repeat(2, 1fr); }
.nb-grid-3 { grid-template-columns: repeat(3, 1fr); }
.nb-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Responsive grid adjustments */
@media (max-width: 767px) {
  .nb-grid-2,
  .nb-grid-3,
  .nb-grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .nb-grid-3,
  .nb-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   RESPONSIVE FLEX UTILITIES
   ============================================ */

.nb-flex { display: flex; }
.nb-flex-col { flex-direction: column; }
.nb-flex-wrap { flex-wrap: wrap; }
.nb-items-center { align-items: center; }
.nb-items-start { align-items: flex-start; }
.nb-items-end { align-items: flex-end; }
.nb-justify-center { justify-content: center; }
.nb-justify-between { justify-content: space-between; }
.nb-justify-end { justify-content: flex-end; }

.nb-gap-1 { gap: var(--nb-space-1); }
.nb-gap-2 { gap: var(--nb-space-2); }
.nb-gap-3 { gap: var(--nb-space-3); }
.nb-gap-4 { gap: var(--nb-space-4); }
.nb-gap-5 { gap: var(--nb-space-5); }
.nb-gap-6 { gap: var(--nb-space-6); }
.nb-gap-8 { gap: var(--nb-space-8); }

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

.nb-text-xs { font-size: var(--nb-font-size-xs); }
.nb-text-sm { font-size: var(--nb-font-size-sm); }
.nb-text-base { font-size: var(--nb-font-size-base); }
.nb-text-md { font-size: var(--nb-font-size-md); }
.nb-text-lg { font-size: var(--nb-font-size-lg); }
.nb-text-xl { font-size: var(--nb-font-size-xl); }
.nb-text-2xl { font-size: var(--nb-font-size-2xl); }
.nb-text-3xl { font-size: var(--nb-font-size-3xl); }
.nb-text-4xl { font-size: var(--nb-font-size-4xl); }

/* Fluid typography using clamp */
.nb-heading-1 {
  font-size: clamp(1.75rem, 4vw + 1rem, 2.5rem);
  font-weight: var(--nb-font-weight-bold);
  line-height: var(--nb-line-height-tight);
}

.nb-heading-2 {
  font-size: clamp(1.5rem, 3vw + 0.75rem, 2rem);
  font-weight: var(--nb-font-weight-bold);
  line-height: var(--nb-line-height-tight);
}

.nb-heading-3 {
  font-size: clamp(1.25rem, 2vw + 0.5rem, 1.5rem);
  font-weight: var(--nb-font-weight-semibold);
  line-height: var(--nb-line-height-tight);
}

.nb-body-text {
  font-size: clamp(0.9375rem, 1vw + 0.5rem, 1rem);
  line-height: var(--nb-line-height-normal);
}

/* ============================================
   RESPONSIVE SPACING UTILITIES
   ============================================ */

/* Margins */
.nb-m-0 { margin: 0; }
.nb-m-auto { margin: auto; }
.nb-mx-auto { margin-inline: auto; }
.nb-my-auto { margin-block: auto; }

.nb-mt-2 { margin-block-start: var(--nb-space-2); }
.nb-mt-4 { margin-block-start: var(--nb-space-4); }
.nb-mt-6 { margin-block-start: var(--nb-space-6); }
.nb-mt-8 { margin-block-start: var(--nb-space-8); }

.nb-mb-2 { margin-block-end: var(--nb-space-2); }
.nb-mb-4 { margin-block-end: var(--nb-space-4); }
.nb-mb-6 { margin-block-end: var(--nb-space-6); }
.nb-mb-8 { margin-block-end: var(--nb-space-8); }

/* Padding */
.nb-p-0 { padding: 0; }
.nb-p-2 { padding: var(--nb-space-2); }
.nb-p-3 { padding: var(--nb-space-3); }
.nb-p-4 { padding: var(--nb-space-4); }
.nb-p-5 { padding: var(--nb-space-5); }
.nb-p-6 { padding: var(--nb-space-6); }
.nb-p-8 { padding: var(--nb-space-8); }

.nb-px-4 { padding-inline: var(--nb-space-4); }
.nb-px-6 { padding-inline: var(--nb-space-6); }
.nb-py-4 { padding-block: var(--nb-space-4); }
.nb-py-6 { padding-block: var(--nb-space-6); }

/* Responsive padding using clamp */
.nb-p-responsive {
  padding: clamp(var(--nb-space-3), 3vw, var(--nb-space-6));
}

.nb-px-responsive {
  padding-inline: clamp(var(--nb-space-3), 4vw, var(--nb-space-8));
}

.nb-py-responsive {
  padding-block: clamp(var(--nb-space-4), 3vw, var(--nb-space-8));
}

/* ============================================
   RESPONSIVE CARD COMPONENT
   ============================================ */

.nb-card-responsive {
  background: var(--nb-white);
  border-radius: var(--nb-radius-lg);
  box-shadow: var(--nb-shadow-sm);
  padding: clamp(var(--nb-space-4), 4vw, var(--nb-space-8));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.nb-card-responsive:hover {
  box-shadow: var(--nb-shadow-md);
}

/* ============================================
   RESPONSIVE BUTTON SYSTEM (WCAG 2.1 AA Touch Targets)
   ============================================ */

.nb-btn-responsive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--nb-space-2);
  min-height: var(--nb-touch-target);
  min-width: var(--nb-touch-target);
  padding: var(--nb-space-3) var(--nb-space-5);
  font-family: var(--nb-font-family);
  font-size: var(--nb-font-size-sm);
  font-weight: var(--nb-font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--nb-radius-md);
  cursor: pointer;
  transition: all var(--nb-transition-normal);
  white-space: nowrap;
}

.nb-btn-responsive:focus-visible {
  outline: 3px solid var(--nb-brand-primary);
  outline-offset: 2px;
}

.nb-btn-responsive:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nb-btn-primary-responsive {
  background: var(--nb-brand-primary);
  color: var(--nb-white);
  box-shadow: var(--nb-shadow-brand);
}

.nb-btn-primary-responsive:hover:not(:disabled) {
  background: var(--nb-brand-secondary);
  box-shadow: var(--nb-shadow-brand-hover);
  transform: translateY(-1px);
}

.nb-btn-secondary-responsive {
  background: transparent;
  color: var(--nb-brand-primary);
  border: 2px solid var(--nb-brand-primary);
}

.nb-btn-secondary-responsive:hover:not(:disabled) {
  background: var(--nb-brand-lighter);
}

/* Full width button on mobile */
.nb-btn-full-mobile {
  width: 100%;
}

@media (min-width: 768px) {
  .nb-btn-full-mobile {
    width: auto;
  }
}

/* ============================================
   RESPONSIVE INPUT SYSTEM
   ============================================ */

.nb-input-responsive,
.nb-select-responsive,
.nb-textarea-responsive {
  width: 100%;
  min-height: var(--nb-touch-target);
  padding: var(--nb-space-3) var(--nb-space-4);
  font-family: var(--nb-font-family);
  font-size: 1rem;
  color: var(--nb-gray-700);
  background: var(--nb-white);
  border: 2px solid var(--nb-gray-200);
  border-radius: var(--nb-radius-md);
  transition: all var(--nb-transition-normal);
  box-sizing: border-box;
}

.nb-input-responsive:hover:not(:disabled),
.nb-select-responsive:hover:not(:disabled),
.nb-textarea-responsive:hover:not(:disabled) {
  border-color: var(--nb-gray-300);
}

.nb-input-responsive:focus,
.nb-select-responsive:focus,
.nb-textarea-responsive:focus {
  outline: none;
  border-color: var(--nb-brand-primary);
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}

.nb-input-responsive:disabled,
.nb-select-responsive:disabled,
.nb-textarea-responsive:disabled {
  background: var(--nb-gray-100);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Prevent zoom on iOS */
@media (max-width: 480px) {
  .nb-input-responsive,
  .nb-select-responsive,
  .nb-textarea-responsive {
    font-size: 16px;
  }
}

/* ============================================
   RESPONSIVE MODAL SYSTEM
   ============================================ */

.nb-modal-backdrop-responsive {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--nb-z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nb-space-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--nb-transition-normal);
}

.nb-modal-backdrop-responsive.open {
  opacity: 1;
  visibility: visible;
}

.nb-modal-responsive {
  background: var(--nb-white);
  border-radius: var(--nb-radius-xl);
  box-shadow: var(--nb-shadow-xl);
  width: clamp(18rem, 90vw, 31.25rem);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--nb-transition-spring);
}

.nb-modal-backdrop-responsive.open .nb-modal-responsive {
  transform: scale(1) translateY(0);
}

.nb-modal-header-responsive {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--nb-space-4) var(--nb-space-5);
  border-bottom: 1px solid var(--nb-gray-200);
}

.nb-modal-body-responsive {
  padding: clamp(var(--nb-space-4), 4vw, var(--nb-space-6));
  overflow-y: auto;
  max-height: calc(90vh - 8.75rem);
  max-height: calc(90dvh - 8.75rem);
}

.nb-modal-footer-responsive {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--nb-space-3);
  padding: var(--nb-space-4) var(--nb-space-5);
  border-top: 1px solid var(--nb-gray-200);
  background: var(--nb-gray-50);
}

/* Stack modal footer buttons on small screens */
@media (max-width: 480px) {
  .nb-modal-footer-responsive {
    flex-direction: column;
  }
  
  .nb-modal-footer-responsive > * {
    width: 100%;
  }
}

/* ============================================
   RESPONSIVE TABLE SYSTEM
   ============================================ */

.nb-table-container-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--nb-radius-lg);
  box-shadow: var(--nb-shadow-sm);
}

.nb-table-responsive {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: var(--nb-font-size-sm);
}

.nb-table-responsive th {
  padding: var(--nb-space-3) var(--nb-space-4);
  text-align: left;
  font-weight: var(--nb-font-weight-semibold);
  color: var(--nb-gray-600);
  background: var(--nb-gray-50);
  border-bottom: 2px solid var(--nb-gray-200);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nb-table-responsive td {
  padding: var(--nb-space-3) var(--nb-space-4);
  border-bottom: 1px solid var(--nb-gray-200);
  vertical-align: middle;
}

.nb-table-responsive tbody tr {
  background: var(--nb-white);
  transition: background var(--nb-transition-fast);
}

.nb-table-responsive tbody tr:hover {
  background: var(--nb-gray-50);
}

/* ============================================
   RESPONSIVE HEADER/NAV
   ============================================ */

.nb-header-responsive {
  background: var(--nb-brand-primary);
  color: var(--nb-white);
  box-shadow: var(--nb-shadow-md);
  position: sticky;
  top: 0;
  z-index: var(--nb-z-sticky);
}

.nb-header-content-responsive {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--nb-space-3);
  padding: clamp(var(--nb-space-3), 2vw, var(--nb-space-4)) clamp(var(--nb-space-4), 4vw, var(--nb-space-6));
}

.nb-header-logo-responsive {
  height: clamp(2rem, 5vw, 3.125rem);
  width: auto;
  border-radius: var(--nb-radius-md);
}

.nb-header-title-responsive {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: var(--nb-font-weight-semibold);
  margin: 0;
}

.nb-header-nav-responsive {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nb-space-2);
  padding: 0 clamp(var(--nb-space-4), 4vw, var(--nb-space-6)) var(--nb-space-3);
  justify-content: center;
}

/* Stack header on very small screens */
@media (max-width: 480px) {
  .nb-header-content-responsive {
    flex-direction: column;
    text-align: center;
  }
  
  .nb-header-nav-responsive {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   RESPONSIVE FORM LAYOUT
   ============================================ */

.nb-form-group-responsive {
  margin-bottom: var(--nb-space-5);
}

.nb-form-label-responsive {
  display: block;
  margin-bottom: var(--nb-space-2);
  font-size: var(--nb-font-size-sm);
  font-weight: var(--nb-font-weight-semibold);
  color: var(--nb-gray-700);
}

.nb-form-row-responsive {
  display: grid;
  gap: var(--nb-space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .nb-form-row-responsive {
    grid-template-columns: repeat(2, 1fr);
  }
}

.nb-form-actions-responsive {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nb-space-3);
  margin-top: var(--nb-space-6);
}

@media (max-width: 480px) {
  .nb-form-actions-responsive {
    flex-direction: column;
  }
  
  .nb-form-actions-responsive > * {
    width: 100%;
  }
}

/* ============================================
   RESPONSIVE ITEM GRID (Order Board)
   ============================================ */

.nb-items-grid-responsive {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr));
  gap: clamp(var(--nb-space-3), 2vw, var(--nb-space-4));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Single column on very small screens */
@media (max-width: 359px) {
  .nb-items-grid-responsive {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   CONTAINER QUERIES (Modern Browsers)
   ============================================ */

@supports (container-type: inline-size) {
  .nb-container-query {
    container-type: inline-size;
    container-name: card-container;
  }

  @container card-container (max-width: 300px) {
    .nb-cq-stack {
      flex-direction: column;
      text-align: center;
    }
  }

  @container card-container (min-width: 400px) {
    .nb-cq-row {
      flex-direction: row;
      justify-content: space-between;
    }
  }
}

/* ============================================
   ACCESSIBILITY UTILITIES
   ============================================ */

.nb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.nb-focus-visible:focus-visible {
  outline: 3px solid var(--nb-brand-primary);
  outline-offset: 2px;
}

.nb-skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  background: var(--nb-brand-primary);
  color: var(--nb-white);
  padding: var(--nb-space-2) var(--nb-space-4);
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 var(--nb-radius-sm) 0;
  font-weight: var(--nb-font-weight-semibold);
}

.nb-skip-link:focus {
  position: fixed;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  overflow: visible;
  min-height: var(--nb-touch-target);
  display: flex;
  align-items: center;
}

/* ============================================
   PREVENT HORIZONTAL OVERFLOW AT 320px
   ============================================ */

html {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  overflow-x: hidden;
  max-width: 100%;
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* ============================================
   BREAKPOINT-SPECIFIC VISIBILITY
   ============================================ */

.nb-hide-xs { display: block; }
.nb-show-xs { display: none; }

@media (max-width: 359px) {
  .nb-hide-xs { display: none; }
  .nb-show-xs { display: block; }
}

.nb-hide-sm { display: block; }
.nb-show-sm { display: none; }

@media (max-width: 767px) {
  .nb-hide-sm { display: none; }
  .nb-show-sm { display: block; }
}

.nb-hide-md { display: block; }
.nb-show-md { display: none; }

@media (min-width: 768px) and (max-width: 1023px) {
  .nb-hide-md { display: none; }
  .nb-show-md { display: block; }
}

.nb-hide-lg { display: block; }
.nb-show-lg { display: none; }

@media (min-width: 1024px) {
  .nb-hide-lg { display: none; }
  .nb-show-lg { display: block; }
}

/* ============================================
   DESKTOP CONTENT DENSITY (1280px+)
   ============================================ */

@media (min-width: 1280px) {
  .nb-container {
    max-width: var(--nb-container-2xl);
  }
  
  .nb-grid-dense {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
    gap: var(--nb-space-5);
  }
  
  .nb-content-dense {
    padding: var(--nb-space-8);
  }
}

/* ============================================
   REDUCED MOTION PREFERENCE
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   SAFE AREA INSETS FOR NOTCHED PHONES
   (iPhone X, 11, 12, 13, 14, 15+, etc.)
   ============================================ */

@supports (padding: max(0px)) {
  :root {
    --nb-safe-area-top: env(safe-area-inset-top, 0px);
    --nb-safe-area-right: env(safe-area-inset-right, 0px);
    --nb-safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --nb-safe-area-left: env(safe-area-inset-left, 0px);
  }

  .nb-safe-padding {
    padding-top: max(var(--nb-space-4), var(--nb-safe-area-top));
    padding-right: max(var(--nb-space-4), var(--nb-safe-area-right));
    padding-bottom: max(var(--nb-space-4), var(--nb-safe-area-bottom));
    padding-left: max(var(--nb-space-4), var(--nb-safe-area-left));
  }

  .nb-header-responsive,
  .header,
  .nb-header {
    padding-top: max(var(--nb-space-3), var(--nb-safe-area-top));
    padding-left: max(var(--nb-space-4), var(--nb-safe-area-left));
    padding-right: max(var(--nb-space-4), var(--nb-safe-area-right));
  }

  .nb-footer-responsive,
  .footer,
  .nb-footer {
    padding-bottom: max(var(--nb-space-4), var(--nb-safe-area-bottom));
    padding-left: max(var(--nb-space-4), var(--nb-safe-area-left));
    padding-right: max(var(--nb-space-4), var(--nb-safe-area-right));
  }

  .nb-modal-responsive,
  .modal-content {
    padding-bottom: max(var(--nb-space-4), var(--nb-safe-area-bottom));
  }

  .nb-sticky-bottom,
  .sticky-order-summary {
    padding-bottom: max(var(--nb-space-4), var(--nb-safe-area-bottom));
  }
}

/* ============================================
   TOUCH DEVICE ADJUSTMENTS (@media pointer: coarse)
   Larger tap targets and more padding for touch screens
   ============================================ */

@media (pointer: coarse) {
  :root {
    --nb-touch-target: 3rem;
    --nb-touch-target-lg: 3.25rem;
  }

  button,
  .btn,
  .nb-btn,
  .nb-btn-responsive,
  input[type="submit"],
  input[type="button"],
  input[type="reset"] {
    min-height: 3rem;
    min-width: 3rem;
    padding: var(--nb-space-4) var(--nb-space-5);
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="week"],
  select,
  textarea,
  .nb-input,
  .nb-input-responsive,
  .nb-select-responsive,
  .nb-textarea-responsive {
    min-height: 3rem;
    padding: var(--nb-space-4);
  }

  .chip,
  .filter-chip,
  .tag,
  .badge,
  .status-chip {
    min-height: 3rem;
    padding: var(--nb-space-3) var(--nb-space-5);
  }

  .par-type-card,
  .item-card {
    padding: var(--nb-space-5);
  }

  .quantity-controls input {
    min-height: 3rem;
    padding: var(--nb-space-4);
  }

  .nb-modal-footer-responsive,
  .modal-footer {
    gap: var(--nb-space-4);
  }

  nav a,
  .nav-link,
  .tab,
  .tab-button,
  [role="tab"] {
    min-height: 3rem;
    padding: var(--nb-space-4) var(--nb-space-5);
  }

  .close,
  .close-btn,
  .modal-close {
    min-height: 3rem;
    min-width: 3rem;
  }

  .nb-grid {
    gap: var(--nb-space-5);
  }

  .items-grid,
  .par-type-grid {
    gap: var(--nb-space-4);
  }
}

/* ============================================
   IMPROVED FLUID TYPOGRAPHY USING clamp()
   Better scaling across all device sizes
   ============================================ */

.nb-fluid-h1 {
  font-size: clamp(1.5rem, 5vw + 0.5rem, 3rem);
  font-weight: var(--nb-font-weight-bold);
  line-height: var(--nb-line-height-tight);
  letter-spacing: -0.02em;
}

.nb-fluid-h2 {
  font-size: clamp(1.25rem, 4vw + 0.4rem, 2.25rem);
  font-weight: var(--nb-font-weight-bold);
  line-height: var(--nb-line-height-tight);
  letter-spacing: -0.01em;
}

.nb-fluid-h3 {
  font-size: clamp(1.125rem, 3vw + 0.3rem, 1.75rem);
  font-weight: var(--nb-font-weight-semibold);
  line-height: var(--nb-line-height-tight);
}

.nb-fluid-h4 {
  font-size: clamp(1rem, 2vw + 0.25rem, 1.375rem);
  font-weight: var(--nb-font-weight-semibold);
  line-height: var(--nb-line-height-normal);
}

.nb-fluid-body {
  font-size: clamp(0.875rem, 1.5vw + 0.5rem, 1.0625rem);
  line-height: var(--nb-line-height-relaxed);
}

.nb-fluid-small {
  font-size: clamp(0.75rem, 1vw + 0.4rem, 0.875rem);
  line-height: var(--nb-line-height-normal);
}

/* ============================================
   CRAMPED LAYOUT FIXES FOR 320px-360px
   iPhone SE, small Android phones
   ============================================ */

@media (max-width: 360px) {
  :root {
    --nb-space-responsive: 0.625rem;
  }

  html {
    font-size: 14px;
  }

  .nb-container,
  .nb-container-fluid,
  .container {
    padding-inline: 0.625rem;
  }

  .nb-card-responsive,
  .nb-section-card,
  .store-selection,
  .manager-acknowledgement,
  .store-info,
  .order-form {
    padding: 0.875rem;
    border-radius: 0.75rem;
  }

  .nb-grid,
  .items-grid,
  .par-type-grid {
    gap: 0.625rem;
  }

  .nb-items-grid-responsive {
    grid-template-columns: 1fr;
    gap: 0.625rem;
  }

  .nb-btn-responsive,
  .btn,
  .nb-btn {
    padding: var(--nb-space-3) var(--nb-space-4);
    font-size: 0.8125rem;
  }

  .nb-heading-1,
  .nb-fluid-h1 {
    font-size: 1.375rem;
  }

  .nb-heading-2,
  .nb-fluid-h2 {
    font-size: 1.125rem;
  }

  .nb-heading-3,
  .nb-fluid-h3 {
    font-size: 1rem;
  }

  .nb-modal-responsive,
  .modal-content {
    width: calc(100vw - 0.75rem);
    margin: 0.375rem;
    border-radius: 0.75rem;
  }

  .nb-modal-header-responsive,
  .modal-header {
    padding: 0.75rem;
  }

  .nb-modal-body-responsive,
  .modal-body {
    padding: 0.75rem;
  }

  .nb-modal-footer-responsive,
  .modal-footer {
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .header,
  .nb-header,
  .nb-header-responsive {
    padding: 0.5rem 0.625rem;
  }

  .header h1,
  .nb-header-title,
  .nb-header-title-responsive {
    font-size: 0.8125rem;
  }

  .header-logo,
  .nb-header-logo,
  .nb-header-logo-responsive {
    height: 1.75rem;
  }

  .filter-controls {
    padding: 0.75rem;
    gap: 0.625rem;
    grid-template-columns: 1fr;
  }

  .vendor-header {
    padding: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .vendor-header h5 {
    font-size: 1rem;
  }

  .delivery-days {
    font-size: 0.75rem;
    width: 100%;
  }

  .category-header,
  .invoice-header {
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
  }

  .item-card {
    padding: 0.75rem;
  }

  .item-card h5 {
    font-size: 0.9375rem;
  }

  .item-details {
    font-size: 0.75rem;
  }
}

/* Between 320px-360px - slightly more aggressive fixes */
@media (max-width: 320px) {
  html {
    font-size: 13px;
  }

  .nb-container,
  .nb-container-fluid,
  .container {
    padding-inline: 0.5rem;
  }

  .nb-card-responsive,
  .nb-section-card,
  .store-selection,
  .manager-acknowledgement,
  .store-info,
  .order-form {
    padding: 0.75rem;
  }

  .nb-btn-responsive,
  .btn,
  .nb-btn {
    font-size: 0.75rem;
    padding: 0.625rem 0.875rem;
  }

  .vendor-categories {
    padding: 0.75rem;
  }

  .par-type-card {
    padding: 0.875rem;
    min-height: 120px;
  }

  .par-type-icon {
    font-size: 2rem;
  }

  .par-type-card h3 {
    font-size: 0.9375rem;
  }

  .subcategories-container {
    padding-left: 0.5rem;
  }
}

/* ============================================
   ENHANCED INTERACTIVE ELEMENT TOUCH TARGETS
   Ensures all elements meet 44px minimum
   ============================================ */

.nb-touch-target-enhanced {
  position: relative;
}

.nb-touch-target-enhanced::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max(100%, 44px);
  height: max(100%, 44px);
  min-width: 44px;
  min-height: 44px;
}

.nb-clickable {
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(211, 47, 47, 0.2);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.nb-focusable:focus-visible {
  outline: 3px solid var(--nb-brand-primary);
  outline-offset: 2px;
}

/* ============================================
   ORIENTATION CHANGE HANDLING
   ============================================ */

@media (orientation: landscape) and (max-height: 500px) {
  .nb-modal-responsive,
  .modal-content {
    max-height: calc(100dvh - 1rem);
  }

  .nb-modal-body-responsive,
  .modal-body {
    max-height: calc(100dvh - 8rem);
  }

  .header,
  .nb-header,
  .nb-header-responsive {
    padding-block: 0.375rem;
  }

  .header-logo,
  .nb-header-logo {
    height: 1.75rem;
  }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   CSS Containment, will-change, content-visibility
   ============================================ */

.nb-contain-layout {
  contain: layout;
}

.nb-contain-paint {
  contain: paint;
}

.nb-contain-strict {
  contain: strict;
}

.nb-contain-content {
  contain: content;
}

.nb-section-card,
.store-selection,
.manager-acknowledgement,
.store-info,
.order-form,
.nb-card-responsive {
  contain: layout style;
}

.nb-modal-backdrop-responsive,
.modal-overlay {
  contain: strict;
}

.items-grid,
.par-type-grid,
.nb-items-grid-responsive,
.vendor-sheets-container {
  contain: layout;
}

.item-card,
.par-type-card {
  contain: layout style paint;
}

.nb-animated,
.nb-btn-responsive:hover,
.nb-btn:hover,
.btn:hover,
.nb-card-responsive:hover,
.nb-section-card:hover {
  will-change: transform;
}

.nb-modal-responsive,
.modal-content {
  will-change: transform, opacity;
}

.nb-animated-opacity {
  will-change: opacity;
}

.skeleton {
  will-change: background-position;
}

@supports (content-visibility: auto) {
  .nb-below-fold,
  .order-form,
  .vendor-sheets-container,
  #finalAcknowledgement,
  #vendorCreditSelection {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
  }
  
  .vendor-categories {
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
  }
  
  .items-grid,
  .par-type-grid {
    content-visibility: auto;
    contain-intrinsic-size: auto 400px;
  }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   Pointer: coarse for touch-specific adjustments
   ============================================ */

@media (pointer: coarse) {
  .nb-btn-responsive,
  .btn,
  .nb-btn,
  .nb-input,
  .nb-select-responsive,
  .nb-textarea-responsive,
  select,
  input,
  button {
    min-height: var(--nb-touch-target);
    min-width: var(--nb-touch-target);
  }
  
  .nb-btn-responsive,
  .btn,
  .nb-btn {
    padding: var(--nb-space-4) var(--nb-space-5);
  }
  
  .item-card,
  .par-type-card {
    padding: var(--nb-space-4);
  }
  
  .nb-clickable,
  .clickable,
  [role="button"] {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(211, 47, 47, 0.15);
    touch-action: manipulation;
  }
  
  a, button, [role="button"], .nb-btn, .btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(211, 47, 47, 0.15);
  }
  
  input[type="number"] {
    font-size: 16px;
    min-height: 48px;
    padding: var(--nb-space-3) var(--nb-space-4);
  }
  
  .quantity-controls {
    gap: var(--nb-space-3);
  }
  
  .quantity-controls button {
    min-width: 48px;
    min-height: 48px;
    font-size: 1.25rem;
  }
  
  .category-header,
  .invoice-header,
  .vendor-header {
    min-height: 48px;
  }
  
  .header-right .nb-btn,
  .header-right .btn {
    min-height: 40px;
    padding: var(--nb-space-2) var(--nb-space-4);
  }
  
  .nb-table-responsive td,
  .nb-table-responsive th {
    padding: var(--nb-space-4);
  }
}

@media (pointer: coarse) and (max-width: 480px) {
  .nb-modal-footer-responsive,
  .modal-footer {
    flex-direction: column;
    gap: var(--nb-space-3);
  }
  
  .nb-modal-footer-responsive > *,
  .modal-footer > * {
    width: 100%;
  }
  
  .nb-form-actions-responsive {
    flex-direction: column;
  }
  
  .nb-form-actions-responsive > * {
    width: 100%;
  }
}

/* ============================================
   ENHANCED 360px SMALL DEVICE FIXES
   Header stacking and cramped layout prevention
   ============================================ */

@media (max-width: 360px) {
  .header-top,
  .nb-header-top {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .header-left,
  .nb-header-left {
    flex: 1 1 100%;
    justify-content: center;
    order: 1;
  }
  
  .header-right,
  .nb-header-right {
    flex: 1 1 100%;
    justify-content: center;
    order: 2;
    gap: 0.5rem;
  }
  
  .nb-header-user {
    font-size: 0.75rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .header-right .nb-btn,
  .header-right .btn,
  #logoutStoreUserBtn {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    min-height: 36px;
  }
  
  .nb-vendor-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .nb-vendor-buttons .nb-btn {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  
  .date-container {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .order-date,
  .delivery-date {
    width: 100%;
  }
  
  .filter-controls {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .acknowledgement-content {
    padding: 0;
  }
  
  .nb-instruction-item {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
  }
  
  .nb-name-input-section {
    margin: 0.75rem 0;
  }
  
  .order-summary {
    padding: 0.75rem;
  }
  
  .summary-content {
    font-size: 0.8125rem;
  }
  
  .total {
    font-size: 1rem;
  }
}

/* ============================================
   VIRTUAL SCROLLER STYLES
   High-performance list rendering
   ============================================ */

.virtual-viewport {
  contain: strict;
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.virtual-content {
  contain: layout style;
}

.virtual-items {
  contain: layout style;
}

.virtual-item {
  contain: layout style paint;
  will-change: transform;
  box-sizing: border-box;
  padding: var(--nb-space-2);
}

.virtual-group-header {
  contain: layout style;
  position: sticky;
  z-index: 10;
  background: var(--color-bg-secondary, #fff);
  border-bottom: 1px solid var(--color-border, #e0e0e0);
  font-weight: var(--nb-font-weight-semibold, 600);
  padding: var(--nb-space-3) var(--nb-space-4);
  display: flex;
  align-items: center;
}

.virtual-item .item-card {
  height: 100%;
  margin: 0;
}

.virtual-spacer-top,
.virtual-spacer-bottom {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .virtual-viewport {
    scroll-behavior: auto;
  }
  
  .virtual-item {
    will-change: auto;
  }
}
