/* ==========================================================================
   RESTAURANT GOCA - Responsive Design System
   Mobile (320-640) | Tablet (641-1024) | Desktop (1025+)
   ========================================================================== */

/* ==========================================================================
   1. BASE - Root & Global
   ========================================================================== */
:root {
  --goca-teal: #0d9488;
  --goca-teal-light: #ccfbf1;
  --goca-navy: #1e293b;
  --goca-stone: #fafaf9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (max-width: 640px) {
  html,
  body,
  #root {
    max-width: 100%;
    overflow-x: hidden;
  }
}

#root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   2. LAYOUT - Sidebar + Content
   ========================================================================== */
/* Utilities used by the POS mobile drawer were added after Tailwind was built. */
.inset-y-0 { top: 0; bottom: 0; }
.translate-x-full {
  --tw-translate-x: 100%;
  translate: var(--tw-translate-x) var(--tw-translate-y);
}

/* ==========================================================================
   3. HEADER - Top Navigation Bar
   ========================================================================== */
@media (max-width: 640px) {
  header.h-16 {
    height: 3.5rem !important;
    padding-left: .75rem !important;
    padding-right: .75rem !important;
  }
  
  header img.w-9 { width: 2rem !important; height: 2rem !important; }
  header h1 { font-size: .75rem !important; }
}

/* ==========================================================================
   4. POS (Point of Sale) - Layout
   ========================================================================== */
.pos-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .pos-layout {
    flex-direction: row;
  }
}

/* Product grid - responsive columns */
.products-grid {
  display: grid;
  gap: .5rem;
  padding: .5rem;
}

@media (max-width: 400px) {
  .products-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 401px) and (max-width: 640px) {
  .products-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
@media (min-width: 1025px) and (max-width: 1366px) {
  .products-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
@media (min-width: 1367px) {
  .products-grid { grid-template-columns: repeat(5, 1fr) !important; }
}

/* Product card */
.product-card {
  border-radius: var(--radius-lg);
  padding: .75rem;
  cursor: pointer;
  transition: all .15s ease;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: white;
  border: 1px solid #e7e5e4;
}

.product-card:active { transform: scale(.96); }

@media (min-width: 641px) {
  .product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--goca-teal);
  }
}

.product-card .price {
  font-weight: 700;
  color: var(--goca-teal);
  font-size: .875rem;
  margin-top: .25rem;
}

.product-card .name {
  font-size: .75rem;
  color: var(--goca-navy);
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}

/* Cart/Order panel */
.cart-panel {
  background: white;
  border-top: 2px solid #e7e5e4;
}

@media (min-width: 1024px) {
  .cart-panel {
    border-top: none;
    border-left: 2px solid #e7e5e4;
    width: 380px;
    min-width: 320px;
  }
}

/* ==========================================================================
   5. ADMIN DASHBOARD - Cards Grid
   ========================================================================== */
.admin-card-grid {
  display: grid;
  gap: .75rem;
  padding: .75rem;
}

@media (max-width: 480px) {
  .admin-card-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .admin-card-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 769px) and (max-width: 1200px) {
  .admin-card-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (min-width: 1201px) {
  .admin-card-grid { grid-template-columns: repeat(4, 1fr) !important; }
}

.admin-card {
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  background: white;
  border: 1px solid #e7e5e4;
  transition: all .2s ease;
  cursor: pointer;
  min-height: 100px;
}

@media (min-width: 769px) {
  .admin-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--goca-teal);
  }
}

.admin-card:active { transform: scale(.97); }

/* ==========================================================================
   6. GARZON PORTAL
   ========================================================================== */
.garzon-grid {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

@media (max-width: 480px) {
  .garzon-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 481px) {
  .garzon-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

.garzon-card {
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  background: white;
  border: 2px solid #e7e5e4;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
}

.garzon-card:active { transform: scale(.97); }

/* ==========================================================================
   7. TABLES - Responsive Table View
   ========================================================================== */
@media (max-width: 640px) {
  /* Card-style table rows on mobile */
  table.data-table,
  table.data-table thead,
  table.data-table tbody,
  table.data-table th,
  table.data-table td,
  table.data-table tr {
    display: block !important;
  }
  
  table.data-table thead { display: none !important; }
  
  table.data-table tr {
    margin-bottom: .75rem;
    border: 1px solid #e7e5e4;
    border-radius: var(--radius-lg);
    padding: .75rem;
    background: white;
  }
  
  table.data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    border-bottom: 1px solid #f5f5f4;
  }
  
  table.data-table td:last-child { border-bottom: none; }
  
  table.data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--goca-navy);
    font-size: .75rem;
  }
}

@media (min-width: 641px) {
  /* Scrollable on tablet */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table.data-table {
    min-width: 600px;
    width: 100%;
  }
}

/* ==========================================================================
   8. FORMS - Inputs & Selects
   ========================================================================== */
@media (max-width: 767px) {
  /* Prevent iOS focus zoom without overriding component padding or width. */
  input, select, textarea { font-size: max(16px, 1em); }
}

/* ==========================================================================
   9. BUTTONS
   ========================================================================== */
@media (max-width: 640px) {
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: .5rem;
  }
  
  .btn-group button,
  .btn-group .btn {
    width: 100%;
  }
  
  button.full-width-mobile {
    width: 100% !important;
  }
}

/* ==========================================================================
   10. MODALS & DIALOGS
   ========================================================================== */
@media (max-width: 640px) {
  .fixed.inset-0 > .relative,
  [role="dialog"],
  .modal-content {
    margin: .5rem !important;
    max-height: calc(100dvh - 1rem) !important;
    border-radius: var(--radius-xl) !important;
    width: calc(100vw - 1rem) !important;
  }
  
  .modal-body {
    max-height: calc(100dvh - 8rem) !important;
    overflow-y: auto !important;
  }
}

.modal-backdrop {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ==========================================================================
   11. NAVIGATION (Bottom Tab Bar for Mobile)
   ========================================================================== */
@media (max-width: 1023px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e7e5e4;
    display: flex;
    justify-content: space-around;
    padding: .5rem 0 env(safe-area-inset-bottom, .5rem);
    z-index: 40;
  }
  
  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .125rem;
    font-size: .625rem;
    color: #78716c;
    padding: .25rem;
    min-width: 56px;
  }
  
  .mobile-bottom-nav .active { color: var(--goca-teal); }
  
  /* Add bottom padding to main content to clear nav */
  .main-content {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, .5rem)) !important;
  }
}

/* ==========================================================================
   12. KITCHEN DISPLAY
   ========================================================================== */
.kitchen-grid {
  display: grid;
  gap: .75rem;
}

@media (max-width: 640px) {
  .kitchen-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .kitchen-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 1025px) {
  .kitchen-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

.kitchen-order {
  border: 1px solid #e7e5e4;
  border-radius: var(--radius-lg);
  padding: .75rem;
  background: white;
}

/* ==========================================================================
   13. TABLES VIEW
   ========================================================================== */
.tables-grid {
  display: grid;
  gap: .75rem;
  padding: .75rem;
}

@media (max-width: 480px) {
  .tables-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .tables-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (min-width: 769px) and (max-width: 1200px) {
  .tables-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
@media (min-width: 1201px) {
  .tables-grid { grid-template-columns: repeat(5, 1fr) !important; }
}

.table-card {
  aspect-ratio: 1;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
  font-weight: 600;
  font-size: 1rem;
}

.table-card:active { transform: scale(.95); }

/* ==========================================================================
   14. SETTINGS PAGES
   ========================================================================== */
.settings-grid {
  display: grid;
  gap: 1rem;
}

/* Existing compiled screens patched after the original Tailwind build. */
.inventory-table-shell,
.products-table-shell,
.tables-map-shell {
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.inventory-table-shell table { min-width: 900px; }
.products-table-shell table { min-width: 820px; }

@media (max-width: 640px) {
  .reports-page,
  .inventory-page { padding: 1rem !important; }

  .reports-header {
    align-items: stretch !important;
    flex-direction: column;
    gap: .75rem;
  }

  .reports-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .reports-toolbar select { min-width: 0; }

  .tables-main {
    min-width: 0;
    padding: 1rem !important;
  }

  .tables-header {
    align-items: flex-start !important;
    flex-wrap: wrap;
    gap: .75rem;
  }

  .tables-header > :last-child {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: .25rem;
  }

  .tables-map-shell { min-height: 520px; }
  .tables-map-shell > div {
    min-width: 960px;
    min-height: 680px;
  }

  .inventory-table-shell th:first-child,
  .inventory-table-shell td:first-child,
  .products-table-shell th:first-child,
  .products-table-shell td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: white;
  }
}

@media (max-width: 768px) {
  .settings-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 769px) {
  .settings-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ==========================================================================
   15. LOGIN PAGE
   ========================================================================== */
@media (max-width: 480px) {
  .login-container {
    padding: 1rem !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .login-title { font-size: 1.25rem !important; }
  
  .role-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
  }
}

/* ==========================================================================
   16. DELIVERY VIEW
   ========================================================================== */
.delivery-grid {
  display: grid;
  gap: 1rem;
}

@media (max-width: 768px) {
  .delivery-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 769px) and (max-width: 1200px) {
  .delivery-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 1201px) {
  .delivery-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ==========================================================================
   17. REPORTS & CHARTS
   ========================================================================== */
@media (max-width: 768px) {
  .reports-grid {
    grid-template-columns: 1fr !important;
  }
  
  .chart-container {
    height: 200px !important;
  }
}

@media (min-width: 769px) {
  .reports-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ==========================================================================
   18. INVENTORY
   ========================================================================== */
.inventory-grid {
  display: grid;
  gap: 1rem;
}

@media (max-width: 480px) {
  .inventory-grid { grid-template-columns: 1fr !important; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .inventory-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 769px) {
  .inventory-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ==========================================================================
   19. UTILITY CLASSES
   ========================================================================== */
.hide-on-mobile {
  @media (max-width: 640px) { display: none !important; }
}

.show-on-mobile {
  @media (min-width: 641px) { display: none !important; }
}

@media (max-width: 480px) {
  .hide-xs { display: none !important; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .hide-sm { display: none !important; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .hide-md { display: none !important; }
}

@media (min-width: 1025px) {
  .hide-lg { display: none !important; }
}

/* Safe area padding for notched devices */
.safe-top { padding-top: env(safe-area-inset-top, 0); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.safe-left { padding-left: env(safe-area-inset-left, 0); }
.safe-right { padding-right: env(safe-area-inset-right, 0); }

/* ==========================================================================
   20. SCROLLBARS
   ========================================================================== */
@media (min-width: 769px) {
  .custom-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  
  .custom-scroll::-webkit-scrollbar-track { background: transparent; }
  
  .custom-scroll::-webkit-scrollbar-thumb {
    background: #d6d3d1;
    border-radius: 3px;
  }
  
  .custom-scroll::-webkit-scrollbar-thumb:hover { background: #a8a29e; }
}

@media (max-width: 768px) {
  .custom-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}

/* ==========================================================================
   21. PRINT STYLES
   ========================================================================== */
@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { font-size: 11pt; color: #000; background: white; }
  .shadow, .shadow-md, .shadow-lg, .shadow-xl { box-shadow: none !important; }
}

/* ==========================================================================
   22. LOADING & EMPTY STATES
   ========================================================================== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #78716c;
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }

/* ==========================================================================
   23. ERROR STATE FOR POS
   ========================================================================== */
.pos-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
  color: var(--goca-navy);
}

.pos-error h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: .5rem; }
.pos-error p { color: #78716c; margin-bottom: 1.5rem; max-width: 320px; }

/* ==========================================================================
   24. HIGH-DPI SCREENS
   ========================================================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img { image-rendering: auto; }
}

/* ==========================================================================
   25. REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* GOCA dialogs and operational tables - 2026-07-18 */
.goca-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(15 23 42 / 48%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.goca-dialog-panel {
  width: min(100%, 440px);
  max-height: min(88dvh, 680px);
  overflow-y: auto;
  border: 1px solid #e7e5e4;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 70px rgb(15 23 42 / 24%);
  color: #0f1f38;
  animation: goca-dialog-in 140ms ease-out;
}

.goca-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem .5rem;
}

.goca-dialog-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 750;
  line-height: 1.35;
}

.goca-dialog-close {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: #f5f5f4;
  color: #78716c;
  font-size: 1.5rem;
  line-height: 1;
}

.goca-dialog-close:hover { background: #e7e5e4; color: #0f1f38; }
.goca-dialog-message { padding: .25rem 1.25rem .75rem; color: #57534e; font-size: .9rem; line-height: 1.5; }
.goca-dialog-field { display: grid; gap: .45rem; padding: .5rem 1.25rem; color: #57534e; font-size: .82rem; font-weight: 650; }

.goca-dialog-input {
  width: 100%;
  min-height: 3rem;
  resize: vertical;
  border: 1px solid #d6d3d1;
  border-radius: 12px;
  background: #fafaf9;
  padding: .75rem .9rem;
  color: #0f1f38;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  outline: none;
}

.goca-dialog-input:focus { border-color: #008775; box-shadow: 0 0 0 3px rgb(0 135 117 / 13%); background: #fff; }
.goca-dialog-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: .75rem; padding: 1rem 1.25rem 1.25rem; }
.goca-dialog-button { min-height: 3rem; border: 0; border-radius: 12px; padding: .75rem 1rem; font-size: .92rem; font-weight: 750; }
.goca-dialog-button-secondary { border: 1px solid #d6d3d1; background: #fff; color: #44403c; }
.goca-dialog-button-primary { background: #007d6d; color: #fff; }
.goca-dialog-button-danger { background: #eb4b0a; color: #fff; }
.goca-dialog-button:focus-visible { outline: 3px solid rgb(0 135 117 / 25%); outline-offset: 2px; }

@keyframes goca-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1023px) {
  .tables-page {
    height: auto !important;
    min-height: 100%;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .tables-main {
    width: 100%;
    min-height: 680px;
    flex: 0 0 auto !important;
  }

  .tables-detail {
    width: 100% !important;
    min-height: 440px;
    flex: 0 0 auto;
    border-left: 0 !important;
    border-top: 1px solid #e7e5e4;
  }
}

@media (max-width: 640px) {
  .goca-dialog-backdrop { align-items: flex-end; padding: .5rem; }
  .goca-dialog-panel { width: 100%; max-height: calc(100dvh - 1rem); border-radius: 18px; }
  .goca-dialog-header { padding: 1rem 1rem .4rem; }
  .goca-dialog-message { padding: .2rem 1rem .65rem; }
  .goca-dialog-field { padding: .45rem 1rem; }
  .goca-dialog-actions { padding: .9rem 1rem 1rem; }

  .tables-main { min-height: 620px; padding: .75rem !important; }
  .tables-header { gap: .75rem; }
  .tables-toolbar { width: 100%; max-width: 100%; overflow-x: auto; padding-bottom: .2rem; }
  .tables-toolbar > * { flex: 0 0 auto; }
  .tables-legend { flex-wrap: wrap; gap: .5rem 1rem !important; margin-bottom: .75rem !important; }
  .tables-map-shell { min-height: 460px !important; padding: .75rem !important; border-radius: 18px !important; }
  .tables-map-shell .tables-map-canvas { min-width: 780px; min-height: 620px; }
  .tables-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: .6rem !important; }
  .tables-list-grid button { min-height: 92px; padding: .75rem !important; }
  .tables-detail { min-height: min(520px, 72dvh); }
}

@media (max-width: 380px) {
  .goca-dialog-actions { grid-template-columns: 1fr; }
  .tables-map-shell .tables-map-canvas { min-width: 700px; }
}