html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

:root {
  --app-bg: #0b1220;
  --app-surface: #0f172a;
  --app-card: #0b1220;
  --app-content-bg: #f5f7fb;
  --app-border: rgba(15, 23, 42, 0.12);
  --app-muted: #64748b;
  --app-text: #0f172a;
  --app-white: #ffffff;
  --app-primary: #16a34a;
  --app-primary-600: #15803d;
  --app-danger: #dc2626;
}

body {
  background: var(--app-content-bg);
  color: var(--app-text);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--app-border);
  padding: 12px 18px;
}

.app-brand {
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .3px;
  color: var(--app-text);
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-sidebar {
  width: 260px;
  padding: 18px;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  border-right: 1px solid rgba(255,255,255,0.06);
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-nav-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,0.65);
  margin-bottom: 6px;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.06);
  transition: transform .12s ease, background-color .12s ease, border-color .12s ease;
}

.app-nav-link:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
  transform: translateY(-1px);
  color: #fff;
}

.app-nav-link.active {
  background: rgba(25, 135, 84, 0.28);
  border-color: rgba(34, 197, 94, 0.45);
  color: #fff;
  font-weight: 600;
}

.app-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.app-nav-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,0.55);
  padding: 4px 12px 2px;
}

.app-nav-sublink {
  padding-left: 14px !important;
  font-size: 0.9rem;
  gap: 8px !important;
  opacity: 0.96;
}

.app-nav-sublink i {
  font-size: 1rem;
  opacity: 0.9;
}

/* Mobile drawer: same dark theme as desktop sidebar (fixes invisible white-on-white links) */
#sidebar.offcanvas {
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  max-width: min(320px, 88vw);
}

#sidebar .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 14px 16px;
}

#sidebar .offcanvas-title {
  color: #fff;
  font-size: 1rem;
}

#sidebar .btn-close {
  filter: invert(1) grayscale(100%);
  opacity: 0.85;
}

#sidebar .offcanvas-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 28px;
}

#sidebar .app-nav {
  gap: 10px;
}

#sidebar .app-nav-link {
  min-height: 48px;
}

.app-content {
  flex: 1;
  min-width: 0;
  padding: 18px;
}

.app-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--app-border);
}

/* Bootstrap polish */
.card {
  border: 1px solid var(--app-border);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.btn-primary {
  background-color: var(--app-primary) !important;
  border-color: var(--app-primary) !important;
}

.btn-primary:hover {
  background-color: var(--app-primary-600) !important;
  border-color: var(--app-primary-600) !important;
}

.btn-outline-danger {
  border-color: rgba(220, 38, 38, 0.35) !important;
}

.form-control, .form-select {
  border-radius: 12px;
  border-color: rgba(15,23,42,0.14);
}

.table {
  border-color: rgba(15,23,42,0.10);
}

.table thead th {
  font-weight: 700;
}

.badge {
  border-radius: 999px;
}

@media (min-width: 992px) {
  body {
    margin-bottom: 0;
  }
}

/* ============================================
   MOBILE & TABLET RESPONSIVE ENHANCEMENTS
   ============================================ */

/* Mobile-first: Base styles for small screens */
@media (max-width: 767.98px) {
  /* Typography */
  html {
    font-size: 14px;
  }
  
  /* Topbar adjustments */
  .app-topbar {
    padding: 10px 12px;
  }
  
  .app-brand {
    font-size: 0.95rem;
  }
  
  /* Hide text on buttons, show only icons on mobile */
  .app-topbar .btn-sm {
    padding: 6px 8px;
    min-width: 40px;
  }
  
  .app-topbar .btn-sm .bi + span,
  .app-topbar .btn-sm span:not(.bi) {
    display: none;
  }
  
  /* Content padding */
  .app-content {
    padding: 12px;
  }
  
  /* Cards */
  .card {
    border-radius: 12px;
    margin-bottom: 12px;
  }
  
  .card-body {
    padding: 16px;
  }
  
  /* Buttons - larger touch targets */
  .btn {
    min-height: 44px; /* iOS recommended touch target */
    padding: 10px 16px;
    font-size: 0.95rem;
  }
  
  .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.875rem;
  }
  
  /* Forms */
  .form-control, .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 10px 14px;
  }
  
  .form-label {
    font-size: 0.9rem;
    margin-bottom: 6px;
    font-weight: 600;
  }
  
  /* Tables - make them scrollable */
  .table-responsive {
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }
  
  .table {
    font-size: 0.875rem;
    min-width: 600px; /* Force horizontal scroll */
  }
  
  .table th,
  .table td {
    padding: 10px 8px;
    white-space: nowrap;
  }
  
  /* Stats cards - stack vertically */
  .row.g-3 > [class*="col-"] {
    margin-bottom: 12px;
  }
  
  /* Navigation */
  .offcanvas {
    width: 280px !important;
  }
  
  .app-nav-link {
    padding: 12px 14px;
    font-size: 0.95rem;
    min-height: 48px; /* Touch-friendly */
  }
  
  /* Footer */
  .app-footer {
    font-size: 0.85rem;
    padding: 12px;
    text-align: center;
  }
  
  /* Modals */
  .modal-dialog {
    margin: 10px;
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  /* Alerts */
  .alert {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 10px;
  }
  
  /* Badges */
  .badge {
    font-size: 0.75rem;
    padding: 6px 10px;
  }
  
  /* Spacing adjustments */
  .mb-4 {
    margin-bottom: 1.5rem !important;
  }
  
  .mt-4 {
    margin-top: 1.5rem !important;
  }
  
  /* Hide less important elements on mobile */
  .d-none-mobile {
    display: none !important;
  }
}

/* Tablet optimizations (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .app-content {
    padding: 16px;
  }
  
  .table {
    font-size: 0.9rem;
  }
  
  .btn {
    min-height: 42px;
  }
  
  .form-control, .form-select {
    min-height: 42px;
  }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
  /* Touch devices */
  .btn, .app-nav-link, a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
  
  /* Larger touch targets */
  .btn-sm {
    min-height: 40px;
    padding: 10px 14px;
  }
  
  /* Prevent text selection on buttons */
  .btn, .app-nav-link {
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Better form focus */
  .form-control:focus,
  .form-select:focus {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
  }
}

/* Landscape mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
  .app-topbar {
    padding: 8px 12px;
  }
  
  .app-content {
    padding: 10px;
  }
  
  .card-body {
    padding: 12px;
  }
}

/* Print optimizations */
@media print {
  .app-topbar,
  .app-sidebar,
  .app-footer,
  .btn,
  .offcanvas {
    display: none !important;
  }
  
  .app-content {
    padding: 0;
    margin: 0;
  }
}

/* Utility classes for responsive typography */
@media (min-width: 768px) {
  .h3-md {
    font-size: 1.75rem;
  }
}

@media (max-width: 767.98px) {
  .h3-md {
    font-size: 1.5rem;
  }
  
  .h4 {
    font-size: 1.25rem;
  }
}

/* Touch-friendly form elements */
.order-status-form {
  width: 100%;
}

@media (max-width: 767.98px) {
  .order-status-form .form-select,
  .order-status-form .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .order-status-form .btn {
    width: 100%;
    margin-top: 8px;
  }
}

/* Better table scrolling on mobile */
@media (max-width: 767.98px) {
  .table-responsive {
    border: 1px solid var(--app-border);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }
  
  .table thead th {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
  }
}

/* Touch device specific styles */
.touch-device .btn,
.touch-device .app-nav-link,
.touch-device a {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.touch-device .btn:active,
.touch-device .app-nav-link:active {
  opacity: 0.8;
  transform: scale(0.98);
}

/* Mobile-specific improvements */
.mobile-device .modal-dialog {
  margin: 0;
  max-width: 100%;
  height: 100%;
}

.mobile-device .modal-content {
  height: 100%;
  border-radius: 0;
  border: none;
}

.mobile-device .modal-fullscreen-sm-down {
  width: 100%;
  max-width: 100%;
  height: 100%;
  margin: 0;
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
  .app-content {
    padding: 16px;
  }
  
  .card-body {
    padding: 20px;
  }
  
  .table {
    font-size: 0.9rem;
  }
  
  .btn {
    padding: 10px 18px;
  }
}

/* Landscape mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
  .app-topbar {
    padding: 8px 12px;
  }
  
  .app-content {
    padding: 10px;
  }
  
  .card-body {
    padding: 12px;
  }
  
  .stats-cards .card-body {
    padding: 12px;
    min-height: 70px;
  }
}
/* Searchable selects (all kitchen portal dropdowns) */
.searchable-select-dd-btn {
  background: #fff;
  min-height: 38px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.searchable-select-dd-menu {
  max-height: 360px;
  overflow: hidden;
  z-index: 1080;
}

.searchable-select-dd-list {
  max-height: 260px;
  overflow: auto;
}

.searchable-select-dd-input {
  max-width: 100%;
}

.searchable-select-dd .dropdown-item.active {
  background-color: #16a34a;
  color: #fff;
}

/* Touch order page */
.customer-order-wrap .card {
  border-radius: 16px;
}

.touch-mode-strip {
  display: flex;
  gap: 10px;
}

.touch-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: #fff;
  text-decoration: none;
  font-weight: 700;
  color: #0f172a;
}

.touch-mode-btn.active {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.customer-order-menu {
  max-height: 74vh;
  overflow-y: auto;
}

.customer-order-category {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748b;
  margin: 12px 0 8px;
  font-weight: 700;
}

.customer-order-card {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.customer-order-card-img-wrap {
  height: 150px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.customer-order-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.customer-order-card-body {
  padding: 10px 10px 6px;
}

.customer-order-card-title {
  font-weight: 700;
  min-height: 42px;
}

.customer-order-card-price {
  color: #16a34a;
  font-weight: 800;
}

.customer-order-add-btn {
  min-height: 48px;
  border-radius: 0;
  border: 0;
  font-weight: 700;
}

.customer-order-cart {
  top: 1rem;
}

.customer-order-cart-list {
  max-height: 40vh;
  overflow-y: auto;
}

.customer-order-cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.customer-order-confirm-btn {
  min-height: 56px;
  font-size: 1.02rem;
  font-weight: 800;
  border-radius: 12px;
}

/* Shared order-type cards (EPOS + kiosk) */
.order-type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.order-type-cards--pos {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.order-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 92px;
  padding: 12px 8px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.order-type-card:hover {
  transform: translateY(-2px);
  border-color: rgba(22, 163, 74, 0.45);
  color: inherit;
}

.order-type-card.is-selected {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.2);
}

.order-type-card-icon { font-size: 1.45rem; line-height: 1; }
.order-type-card-title { font-size: 0.95rem; font-weight: 800; }
.order-type-card-desc { font-size: 0.72rem; color: #64748b; text-align: center; font-weight: 600; }

@media (max-width: 992px) {
  .order-type-cards--pos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
