body {
  font-family: "Noto Sans Lao", "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.navbar-brand {
  font-weight: bold;
}
.btn-qty {
  min-width: 2.5rem;
}
#cart-items td, #cart-items th {
  vertical-align: middle;
}
@media print {
  .no-print { display: none !important; }
}

/* Menu grid improvements */
.card.h-100 { transition: transform .15s ease, box-shadow .15s ease; }
.card.h-100:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
/* Generic card images (non-menu). Menu images are overridden below */
.card:not(.menu-card) > .card-img-top { object-fit: cover; height: 200px; }

/* Responsive columns: 1 on mobile, 2 on tablet, 3-4 on desktop */
/* 1 column mobile (default via col-12), 2 columns on >=576px, 4 on >=992px */
@media (min-width: 576px) { #menu > .col-sm-6 { width: 50%; } }
@media (min-width: 992px) { #menu > .col-lg-3 { width: 25%; } }

/* --- Modern theme enhancements --- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --accent: #14b8a6;
  --border: #e5e7eb;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
}

body {
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% -10%, #eaf2ff 0%, rgba(234, 242, 255, 0) 60%),
              radial-gradient(1000px 700px at 120% 10%, #e8fff9 0%, rgba(232, 255, 249, 0) 50%),
              var(--bg);
}

/* Navbar */
.navbar.navbar-dark.bg-dark {
  background: #1f2937 !important; /* A solid, dark slate gray */
  border-bottom: 1px solid #374151;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0;
}

.navbar-brand {
  letter-spacing: 0.5px;
}

.navbar .nav-link {
  color: #d1d5db !important; /* Lighter gray for better contrast */
  font-weight: 500;
  padding: 0.6rem 1rem !important;
  margin: 0 0.25rem;
  border-radius: 0.375rem; /* rounded-md */
  transition: color 0.2s ease, background-color 0.2s ease;
  position: relative;
  top: 0;
}

.navbar .nav-link:hover {
  color: #ffffff !important;
  background-color: #374151; /* A slightly lighter gray for hover */
}

.navbar .nav-link.active {
  color: #ffffff !important;
  background-color: var(--primary, #2563eb);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.navbar .nav-link.active:hover {
  background-color: var(--primary-600, #1d4ed8);
}

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.card .card-header {
  background-color: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* Summary stat cards */
.card .fs-3.fw-bold { letter-spacing: 0.2px; }
.text-muted { color: var(--muted) !important; }

/* Buttons */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover { background-color: var(--primary-600); border-color: var(--primary-600); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { color: #fff; background-color: var(--primary); border-color: var(--primary); }
.btn { transition: background-color .15s ease, box-shadow .15s ease, transform .05s ease; }
.btn:active { transform: translateY(1px); }

/* Tables */
.table {
  --tbl-border: var(--border);
  border-color: var(--border) !important;
}
.table thead th {
  background: var(--surface-2);
  color: var(--muted);
  border-bottom: 1px solid var(--border) !important;
}
.table tbody tr:hover { background-color: rgba(37, 99, 235, 0.06); }
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table tr:last-child td:first-child { border-bottom-left-radius: 10px; }
.table tr:last-child td:last-child { border-bottom-right-radius: 10px; }

/* --- Page-specific styles --- */

/* Expenses Page */
#expense-form {
  transition: background-color 0.3s ease;
}
#expense-form.editing {
  background-color: #fffbeb; /* Light yellow to indicate editing */
}

/* Report Page */
.report-card {
  border-left-width: 4px;
}
.report-card-today { border-left-color: var(--primary); }
.report-card-week { border-left-color: #0ea5e9; } /* sky-500 */
.report-card-month { border-left-color: #10b981; } /* emerald-500 */

.report-card .card-header {
  font-weight: 600;
}

.report-card .net-value {
  font-size: 1.4rem;
  font-weight: 700;
}

/* Orders List */
#orders-container .list-group-item {
  margin-bottom: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
#orders-container .list-group-item:last-child {
  margin-bottom: 0;
}

/* Pagination area */
#orders-pagination {
  display: flex;
  justify-content: center;
}
#orders-pagination .btn { min-width: 80px; }
#orders-pagination .small { color: var(--muted); }

/* Utility */
.section-title {
  font-weight: 700;
  position: relative;
}
.section-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  margin-top: .35rem;
}

/* Report-specific tweaks */
#top-subtitle { color: var(--muted); }
#top-items tr td:first-child { font-weight: 600; }

/* Edit bill modal and inline add form styles */
.modal-fullscreen .modal-content { border-radius: 0; height: 100vh; }
.modal-fullscreen .modal-body { overflow: auto; }
#add-item-form { background: var(--surface-2); padding: .6rem; border-radius: .5rem; border: 1px solid var(--border); }
#menu-select { max-height: 220px; overflow: auto; }
#menu-select option { padding: .35rem .5rem; }
#menu-search { border-radius: .35rem; }
#menu-category { max-width: 200px; }

/* Make the inline form visually distinct on small screens */
@media (max-width: 767.98px) {
  #add-item-form { display: block; }
  #menu-select { max-height: 160px; }
}

/* --- POS Menu Grid (mobile-first) --- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns on mobile <768px */
  gap: 10px; /* compact but tappable spacing */
}

/* Tablet: increase gaps and columns */
@media (min-width: 768px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
}
/* Desktop: more columns */
@media (min-width: 992px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}
@media (min-width: 1400px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

/* POS menu card overrides for full image visibility */
.menu-grid .card {
  /* allow height to grow with content so contained images not cropped */
  height: auto;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.menu-grid .card-img-top {
  object-fit: contain !important; /* show full image */
  background: #f5f7fa; /* subtle backdrop for transparent / letterboxed areas */
  height: 120px; /* mobile default */
  padding: 4px; /* small breathing space */
  border-radius: 10px 10px 6px 6px; /* soften corners */
}
@media (min-width: 768px) {
  .menu-grid .card-img-top { height: 130px; }
}
@media (min-width: 992px) {
  .menu-grid .card-img-top { height: 150px; }
}
@media (min-width: 1400px) {
  .menu-grid .card-img-top { height: 160px; }
}
.menu-grid .card-body { padding: .5rem .6rem; }
.menu-grid .card-title { font-size: .9rem; line-height: 1.1rem; max-height: 2.2rem; overflow: hidden;}
.menu-grid .price-row { font-size: .8rem; }

/* Touch targets */
.btn-touch, .menu-grid .btn {
  min-height: 36px; /* larger tap target */
  padding: .35rem .6rem;
}
.menu-grid .btn { font-size: .8rem; }

/* Ensure cards are individually tappable-friendly */
.menu-grid .card { cursor: default; }
.menu-grid > * { min-width: 0; }

/* --- POS Mobile Enhancements --- */
.pos-sticky-top {
  position: sticky;
  top: 56px; /* below navbar */
  background: var(--bg, #f6f7fb);
  z-index: 900;
  padding-top: .5rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.pos-sticky-top .cat-buttons button { flex: 1 1 auto; }
.mini-summary { font-size: .9rem; }
.mini-summary .btn { font-size: .75rem; }

/* Bottom action bar (mobile) */
.pos-bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.95);
  color: #fff;
  padding: .5rem .9rem .65rem;
  backdrop-filter: saturate(180%) blur(8px);
  display: flex;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.25);
}
.pos-bottom-bar .btn-outline-light { border-color: rgba(255,255,255,.4); }

/* Hide desktop-only actions on small screens */
@media (max-width: 991.98px) {
  .desktop-actions { display: none !important; }
  #cart { margin-bottom: 60px; } /* space for bottom bar */
}

/* Show mini summary & bottom bar only on mobile/tablet */
@media (min-width: 992px) {
  .mini-summary, .pos-bottom-bar { display: none !important; }
  .pos-sticky-top { top: 70px; }
  body { padding-bottom: 0; }
}

/* Adjust container spacing when sticky elements present */
body { padding-bottom: 70px; }

/* Desktop: sticky cart with scrollable items and pinned footer */
@media (min-width: 992px) {
  :root {
    /* Adjust if your fixed navbar + top bar height differs */
    --cart-stick-top: 96px;
  }

  /* Keep the cart column visible while scrolling the menu */
  #cart {
    position: sticky;
    top: var(--cart-stick-top);
    align-self: flex-start; /* ensure it doesn't stretch to row height */
    min-width: 0; /* prevent overflow in Bootstrap grid */
  }

  /* Visual elevation and rounded corners */
  #cart .card {
    border-radius: 0.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden; /* keep rounded corners clean */
  }

  /* Make the card body a column layout so the table can flex/scroll */
  #cart .card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    /* Fill the viewport below the sticky top bar, minus some breathing room */
    max-height: calc(100vh - var(--cart-stick-top) - 1.5rem);
    padding: 1rem;
  }

  /* Support dynamic viewport units when available */
  @supports (height: 100dvh) {
    #cart .card-body {
      max-height: calc(100dvh - var(--cart-stick-top) - 1.5rem);
    }
  }

  /* The items area scrolls; totals and actions stay visible below */
  #cart .table-responsive {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 120px; /* keeps layout stable when few/zero items */
  }

  /* Optional: keep the table header visible while scrolling items */
  #cart .table-responsive thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
  }

  /* Totals row and buttons do not shrink and remain at the bottom */
  #cart .d-flex.justify-content-between,
  #cart .desktop-actions {
    flex: 0 0 auto;
  }

  /* Balanced spacing from surrounding content */
  #cart {
    margin-top: 0.25rem; /* small offset from top bar */
  }
}

@media print {
  .pos-bottom-bar, .pos-sticky-top, .mini-summary { display: none !important; }
  body { padding-bottom: 0; }
}

