:root {
  --pos-primary: #10b981;
  --pos-primary-hover: #059669;
  --pos-bg: #0f172a;
  --pos-card-bg: #1e293b;
  --pos-border: #334155;
  --pos-text: #f8fafc;
  --pos-text-muted: #94a3b8;
  --pos-accent: #3b82f6;
}

* {
  box-sizing: border-box;
}

body.pos-body {
  margin: 0;
  padding: 0;
  background-color: var(--pos-bg);
  color: var(--pos-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.pos-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Main Content Area */
.pos-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
  height: 100vh;
}

/* Sidebar Cart for Tablet & Desktop */
.pos-sidebar {
  width: 360px;
  min-width: 320px;
  max-width: 400px;
  background-color: var(--pos-card-bg);
  border-left: 1px solid var(--pos-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--pos-border);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pos-brand h2 {
  margin: 0;
  color: #fbbf24;
  font-size: 1.15rem;
  font-weight: 700;
}

.pos-brand span {
  font-size: 0.75rem;
  color: var(--pos-text-muted);
}

/* Category Tabs (Scrollable) */
.pos-nav-tabs {
  display: flex !important;
  visibility: visible !important;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 4px;
  min-height: 42px;
  align-items: center;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

.pos-nav-tabs::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.pos-tab {
  padding: 0.45rem 1.1rem;
  background: var(--pos-card-bg);
  border: 1px solid var(--pos-border);
  border-radius: 9999px;
  color: var(--pos-text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.pos-tab.active, .pos-tab:hover {
  background: var(--pos-primary);
  color: white;
  border-color: var(--pos-primary);
}

.pos-search {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--pos-card-bg);
  border: 1px solid var(--pos-border);
  border-radius: 8px;
  color: white;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.pos-search:focus {
  outline: none;
  border-color: var(--pos-primary);
}

/* Product Grid */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 0.75rem;
}

.pos-card {
  background: var(--pos-card-bg);
  border: 1px solid var(--pos-border);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  user-select: none;
  min-height: 110px;
}

.pos-card:active, .pos-card:hover {
  transform: translateY(-2px);
  border-color: var(--pos-primary);
}

.pos-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #ffffff;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-card-badge {
  font-size: 0.65rem;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  width: fit-content;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.pos-card-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: #34d399;
}

/* Sidebar & Cart Content */
.cart-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--pos-border);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.cart-footer {
  padding: 0.85rem 1rem;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid var(--pos-border);
}

.btn-checkout {
  width: 100%;
  padding: 0.85rem;
  background: var(--pos-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-checkout:hover {
  background: var(--pos-primary-hover);
}

/* Mobile Sticky Bottom Floating Cart Bar */
.mobile-cart-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e293b;
  border-top: 2px solid var(--pos-primary);
  padding: 0.75rem 1rem;
  z-index: 1040;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
}

/* =========================================================
   RESPONSIVE DESIGN: TABLETS & LANDSCAPE (Width >= 768px OR Landscape)
   ========================================================= */
@media (min-width: 768px), (orientation: landscape) and (min-width: 568px) {
  body.pos-body {
    overflow: hidden;
  }

  .pos-layout {
    flex-direction: row !important;
    height: 100vh;
  }

  .pos-main {
    flex: 1;
    padding-bottom: 1rem !important; /* Normal padding for tablet */
    height: 100vh;
    overflow-y: auto;
  }

  .pos-sidebar {
    display: flex !important; /* Permanently visible on Tablet & Landscape */
    width: 360px;
    height: 100vh;
  }

  .mobile-cart-bar {
    display: none !important; /* Hidden on Tablet & Landscape */
  }

  .pos-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 0.75rem;
  }

  .pos-header {
    flex-direction: row !important;
    align-items: center !important;
  }
}

/* =========================================================
   RESPONSIVE DESIGN: MOBILE PHONE PORTRAIT ONLY (Width < 768px and Portrait)
   ========================================================= */
@media (max-width: 767px) and (orientation: portrait) {
  body.pos-body {
    overflow-y: auto;
  }

  .pos-layout {
    flex-direction: column;
    min-height: 100vh;
    height: auto;
  }

  .pos-main {
    padding: 0.75rem;
    padding-bottom: 5.5rem !important; /* Spacing for bottom floating bar */
    height: auto;
  }

  .pos-sidebar {
    display: none !important; /* Use Offcanvas Drawer on mobile phones */
  }

  .mobile-cart-bar {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
  }

  .pos-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .pos-card {
    min-height: 105px;
    padding: 0.65rem;
  }

  .pos-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Thermal Receipt Printable Styling (58mm width) */
#receipt-printable {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }
  #receipt-printable, #receipt-printable * {
    visibility: visible;
  }
  #receipt-printable {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 58mm;
    margin: 0;
    padding: 2mm;
    font-family: 'Courier New', Courier, monospace;
    font-size: 9pt;
    line-height: 1.2;
    color: #000;
    background: #fff;
  }
  .receipt-header {
    text-align: center;
    font-weight: bold;
    margin-bottom: 4px;
  }
  .receipt-divider {
    border-top: 1px dashed #000;
    margin: 4px 0;
  }
  .receipt-row {
    display: flex;
    justify-content: space-between;
  }
  .receipt-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 8pt;
  }
}
