/* MOBILE UX IMPROVEMENTS
   ============================================ */
/* Bigger Search Bar */
/* Bigger Search Bar */
.search-input {
  height: 60px;
  /* Significant Size Increase */
  font-size: 18px;
  /* Larger text */
  padding: 0 var(--space-md);
  width: 100%;
  border-radius: var(--radius-lg);
}

.search-container svg {
  width: 24px;
  height: 24px;
}

/* Green Call Waiter Button */
/* Green Call Waiter Button */
.call-waiter-btn {
  position: fixed;
  bottom: 120px;
  /* Moved up to clear cart */
  right: var(--space-md);
  width: 64px;
  /* Larger */
  height: 64px;
  border-radius: 50%;
  background-color: #10b981 !important;
  /* Force Green */
  color: white !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  border: none;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.call-waiter-btn:active {
  transform: scale(0.95);
}

.call-waiter-btn svg {
  width: 28px;
  height: 28px;
}

/* Ensure Floating Cart is safe on mobile */
/* Ensure Floating Cart is safe on mobile */
@media (max-width: 640px) {
  .floating-cart {
    bottom: var(--space-md);
    /* More breathing room */
    left: var(--space-md);
    right: var(--space-md);
    width: auto;
    border-radius: var(--radius-xl);
    /* Removed background and padding to fix "grey box" issue */
    background: transparent;
    padding: 0;
    box-shadow: none;
    border: none;
  }

  .call-waiter-btn {
    bottom: 100px;
    /* Clear the cart */
  }
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

/* ============================================

   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 640px) {
  :root {
    --font-size-3xl: 1.75rem;
    --font-size-2xl: 1.25rem;
    --font-size-xl: 1.125rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    padding: var(--space-md) 0 180px 0;
  }

  /* Admin & Waiter Layout Stacking */
  .admin-layout,
  .waiter-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  /* Admin Mobile Navigation - Horizontal Scroll */
  .admin-sidebar {
    width: 100%;
    min-height: auto;
    padding: var(--space-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(5, 7, 13, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: var(--space-sm);
    padding-bottom: var(--space-xs);
  }

  .admin-nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }

  /* Compact header logo on mobile */
  .admin-sidebar .header-logo {
    display: none;
    /* Hide logo title to save space, or make very small */
  }

  .admin-main {
    padding: var(--space-md);
  }

  /* Full Screen Modals on Mobile */
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    padding: var(--space-md);
    overflow-y: auto;
  }

  /* Hide less important table columns */
  /* Hide less important table columns on mobile */
  /* Hide Image column (1st) */
  .data-table th:nth-child(1),
  .data-table td:nth-child(1) {
    display: none;
  }

  /* Hiding 4th column hid the 'Links' in Waiter/Tables sections. 
     We should try to only hide price/category in Products if needed, 
     but since tables vary, let's just show column 4 for now to ensure Links are visible.
  */
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) {
    display: table-cell;
    /* Restore visibility */
  }

  /* Waiter Table Mobile: Show Name (1), Hide ID (2) */
  #waitersSection .data-table th:nth-child(1),
  #waitersSection .data-table td:nth-child(1) {
    display: table-cell !important;
  }

  #waitersSection .data-table th:nth-child(2),
  #waitersSection .data-table td:nth-child(2) {
    display: none !important;
  }

  /* Tables Table Mobile: Show Number (1), Hide Status (3) */
  #tablesSection .data-table th:nth-child(1),
  #tablesSection .data-table td:nth-child(1) {
    display: table-cell !important;
  }

  #tablesSection .data-table th:nth-child(3),
  #tablesSection .data-table td:nth-child(3) {
    display: none !important;
  }

  /* Categories Table Mobile: Show Name (2), Hide Prind (1) and Order (3) */
  /* Categories Table Mobile: Show All */
  #categoriesSection .data-table th:nth-child(1),
  #categoriesSection .data-table td:nth-child(1),
  #categoriesSection .data-table th:nth-child(3),
  #categoriesSection .data-table td:nth-child(3) {
    display: table-cell !important;
  }

  #categoriesSection .data-table th:nth-child(2),
  #categoriesSection .data-table td:nth-child(2) {
    display: table-cell !important;
  }

  /* Variations Table Mobile: Show Name (1), Hide Order (2) */
  #variationsSection .data-table th:nth-child(2),
  #variationsSection .data-table td:nth-child(2) {
    display: none !important;
  }

  #variationsSection .data-table th:nth-child(1),
  #variationsSection .data-table td:nth-child(1) {
    display: table-cell !important;
  }
}

/* ============================================

   GLOBAL TOUCH TARGET IMPROVEMENTS
   ============================================ */
@media (max-width: 1024px) {

  /* Ensure interactive elements meet 44px minimum */
  .btn:not(.btn-icon-small),
  .btn-add,
  .category-tab,
  .language-option,
  .toggle {
    min-height: 44px;
  }

  /* Increase Variation Text Size */
  .variation-item {
    font-size: 17px !important;
    /* Increased to 18px */
    padding: 10px 5px !important;
    width: auto !important;
    min-width: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 12px !important;
    max-width: 100%;
    box-sizing: border-box !important;
    white-space: nowrap !important;
  }

  /* Add to Cart Button - Handle Long Text */
  .add-to-cart-btn-large {
    white-space: normal !important;
    /* Allow wrapping */
    height: auto !important;
    /* Allow growing */
    min-height: 54px !important;
    /* Minimum touch target */
    padding: 10px 16px !important;
    line-height: 1.2 !important;
    /* Tighten line height for wrapped text */
    display: flex !important;
    text-align: center !important;
  }

  .variation-item span {
    font-weight: 500 !important;
  }

  /* Waiter panel minimum touch sizes */
  .waiter-detail-footer .btn {
    min-height: 44px;
  }

  /* Improve waiter product list for mobile */
  .waiter-product-list {
    grid-template-columns: 1fr;
  }

  .waiter-product-card {
    min-height: 72px;
  }
}


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

.btn-qty {
  width: 32px;
  border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.12);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-qty:hover {
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.5);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.btn-qty.btn-minus {
  border-color: var(--error) !important;
  color: var(--error) !important;
}

.btn-qty.btn-minus:hover {
  background: var(--error) !important;
  color: white !important;
}

.btn-qty.btn-plus {
  border-color: var(--success) !important;
  color: var(--success) !important;
}

.btn-qty.btn-plus:hover {
  background: var(--success) !important;
  color: white !important;
}

.btn-qty:active {
  transform: scale(0.9);
}


.ingredient-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.ingredient-toggle.excluded {
  opacity: 1;
  text-decoration: line-through;
  background: rgba(239, 68, 68, 0.2) !important;
  border: 1px solid var(--error) !important;
  color: var(--error) !important;
}

.ingredient-toggle .status-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--success);
  color: white;
  font-size: 0.7rem;
}

.ingredient-toggle.excluded .status-icon {
  background: var(--error);
}

/* Specific fix for Desktop Waiter Modal Positioning */
@media (min-width: 1024px) {

  #addItemModal .modal-content,
  #waiterProductModal .modal-content {
    position: relative;
    /* Let flexbox center it */
    transform: none !important;
    max-height: 85vh;
    overflow-y: auto;
    margin: auto;
    width: 90%;
    max-width: 500px;
    inset: auto;
    top: auto !important;
    left: auto !important;
    bottom: auto !important;
    right: auto !important;
  }
}

.ingredients-grid-waiter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Waiter Search Result Scroll Fix */
.waiter-product-list {
  max-height: 80vh;
  overflow-y: auto;
  padding: 4px;
}

.waiter-product-list .card:hover {
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
}


@media (min-width: 768px) {
  .modal-content {
    max-width: 600px;
    margin: 2rem auto;
    border-radius: var(--radius-xl);
  }

  /* Ensure waiter add item list is manageable on desktop */
  .waiter-product-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-height: 60vh;
  }

  /* Fix for Desktop Product Modal Positioning */
  .product-modal.active {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 500px;
    height: auto;
    max-height: 85vh;
    inset: 0;
    margin: auto;
    top: 50%;
    left: 50%;
    bottom: auto;
    right: auto;
    transform: translate(-50%, -50%) !important;
    border-radius: var(--radius-xl);
  }
}

/* Ingredient Exclusion Style */
.ingredient-toggle.excluded {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
  text-decoration: line-through;
}

/* Removed to fix contrast issue */

/* Variation Chips */
.variation-chip {
  padding: 6px 12px;
  border-radius: 30px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.6rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
}

.variation-chip:hover {
  background: var(--bg-hover);
  border-color: var(--primary-light);
}

.variation-chip.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  font-weight: 600;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-buttons .btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  transition: all 0.2s;
}

.action-buttons .btn-icon:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--primary);
  transform: translateY(-1px);
}

.action-buttons .btn-icon.delete:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.action-buttons .btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Waiter Timer Badge */
.table-timer-badge {
  z-index: 10;
  box-shadow: 0 0 10px var(--primary-glow);
}

/* ============================================

   FINAL LANDSCAPE OVERRIDES
   Moved to end to guarantee specificity
   ============================================ */
@media (max-width: 1024px) and (orientation: landscape) {
  .admin-top-header {
    padding: var(--space-xs) var(--space-md) !important;
  }

  .admin-mobile-nav {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    justify-content: flex-start !important;
    max-width: 100vw !important;
    margin-top: 4px !important;
    padding-top: 4px !important;
  }

  .admin-mobile-nav::-webkit-scrollbar {
    height: 4px;
    display: none;
    /* Hide scrollbar for cleaner look, still scrollable */
  }

  .admin-mobile-nav .admin-nav-item {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 36px !important;
    padding: 4px 12px !important;
    flex: 0 0 auto !important;
    width: auto !important;
    margin-bottom: 0 !important;
  }

  .admin-mobile-nav .admin-nav-item svg {
    width: 14px !important;
    height: 14px !important;
    margin-bottom: 0 !important;
  }

  .admin-mobile-nav .admin-nav-item span {
    display: inline-block !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }
}

/* ============================================
   MOBILE RESPONSIVENESS FIXES
   ============================================ */
@media (max-width: 480px) {

  /* Header Info adjustments */
  .header-info {
    gap: 2px;
  }

  /* Compact Table Badge */
  .table-badge {
    padding: 2px 4px;
    font-size: 10px;
    white-space: nowrap;
    height: 28px;
  }

  .table-badge svg {
    width: 12px;
    height: 12px;
  }

  /* Compact Language Button */
  .language-btn {
    padding: 2px 4px;
    font-size: 10px;
    height: 28px;
  }

  .language-btn svg {
    width: 12px;
    height: 12px;
  }

  #currentLang {
    font-size: 10px;
  }

  /* Compact Call Waiter Button */
  .call-waiter-btn-header {
    padding: 2px 8px;
    font-size: 10px;
    height: 28px;
  }

  .call-waiter-btn-header svg {
    width: 12px;
    height: 12px;
  }

  /* Sticky Nav Adjustments */
  .search-flex {
    gap: 4px;
  }

  /* Shrink and fit Allergy/Dietary Buttons */
  .allergy-btn {
    padding: 0 6px;
    font-size: 10px;
    height: 38px;
    /* Slightly smaller height */
    flex-shrink: 1;
    /* Allow shrinking if needed */
    min-width: 0;
    /* Allow Flexbox shrinking below content size if absolutely necessary */
  }

  .allergy-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Ensure text truncates if absolutely needed, but clamp handles sizing */
  #allergyBtnText,
  #dietaryBtnText {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(8px, 3vw, 10px);
    /* Responsive font sizing */
  }

  /* Search Container adjustments */
  .search-container {
    height: 38px;
    padding: 0 6px !important;
  }

  .search-container input {
    font-size: 20px !important;
    padding: 6px !important;
    padding-left: 32px !important;
  }

  .search-icon {
    width: 14px;
    height: 14px;
    left: 8px;
    /* Adjust icon position if absolute */
  }

  /* Category Tabs - Ensure they are swipeable and don't take too much vertical space */
  .category-tab {
    padding: 4px 12px !important;
    font-size: 11px;
  }
}

/* ============================================

   FULLSCREEN TOGGLE BUTTON
   ============================================ */
.fullscreen-btn {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.fullscreen-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
  transform: scale(1.05);
}

.fullscreen-btn:active {
  transform: scale(0.95);
}

.fullscreen-btn i {
  font-size: 14px;
}

/* Fullscreen-specific body styling */
:fullscreen body,
:-webkit-full-screen body,
:-moz-full-screen body,
:-ms-fullscreen body {
  overflow: auto;
}

:fullscreen .waiter-tables-view,
:-webkit-full-screen .waiter-tables-view,
:-moz-full-screen .waiter-tables-view,
:-ms-fullscreen .waiter-tables-view {
  height: 100vh;
  overflow-y: auto;
}

:fullscreen .waiter-detail-view,
:-webkit-full-screen .waiter-detail-view,
:-moz-full-screen .waiter-detail-view,
:-ms-fullscreen .waiter-detail-view {
  height: 100vh;
  overflow-y: auto;
}

/* ============================================
