:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --accent: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --bg-dark: #0f172a;
  --card-dark: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 75px; /* bottom nav space */
}

/* -------------------------------------------------------------
 * Top Header
 * ----------------------------------------------------------- */
.top-header {
  background-color: var(--card-dark);
  border-bottom: 1px solid var(--card-border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.brand-badge {
  background-color: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.quick-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 14px;
}

/* -------------------------------------------------------------
 * Layout Grid (POS Screen)
 * ----------------------------------------------------------- */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  padding: 16px;
  flex: 1;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 900px) {
  .pos-container {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
}

/* -------------------------------------------------------------
 * Scanner & Search Bar
 * ----------------------------------------------------------- */
.search-scanner-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.input-search-wrap {
  flex: 1;
  position: relative;
}

.input-search {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--card-dark);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s;
}

.input-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.btn-scan-cam {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
  transition: transform 0.1s;
}

.btn-scan-cam:active {
  transform: scale(0.96);
}

/* -------------------------------------------------------------
 * Category Pills
 * ----------------------------------------------------------- */
.category-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  background-color: var(--card-dark);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn.active, .pill-btn:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* -------------------------------------------------------------
 * Products Grid
 * ----------------------------------------------------------- */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

@media (min-width: 600px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

.product-card {
  background-color: var(--card-dark);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, border-color 0.15s;
  user-select: none;
}

.product-card:active {
  transform: scale(0.97);
  border-color: var(--primary);
}

.prod-stock-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: #334155;
  color: #cbd5e1;
  align-self: flex-start;
  margin-bottom: 8px;
}

.prod-stock-badge.low {
  background-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
  font-weight: 600;
}

.prod-name {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
  color: #f1f5f9;
}

.prod-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.prod-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: #34d399;
}

.btn-add-quick {
  background-color: #334155;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* -------------------------------------------------------------
 * Cart & Order Section
 * ----------------------------------------------------------- */
.cart-panel {
  background-color: var(--card-dark);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  position: sticky;
  top: 75px;
}

@media (max-width: 900px) {
  .cart-panel {
    height: auto;
    position: static;
  }
}

.cart-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-clear-cart {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

.cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-cart-msg {
  text-align: center;
  color: var(--text-muted);
  margin-top: 40px;
  font-size: 0.9rem;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #0f172a;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #1e293b;
}

.cart-item-info {
  flex: 1;
}

.cart-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}

.cart-item-rate {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-qty {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background-color: #334155;
  color: white;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

.cart-qty-text {
  font-size: 0.88rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

.cart-item-total {
  font-size: 0.95rem;
  font-weight: 700;
  color: #34d399;
  min-width: 60px;
  text-align: right;
}

.btn-del-item {
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  margin-left: 6px;
}

.cart-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--card-border);
  background-color: #172033;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.calc-row.grand {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--card-border);
}

.btn-checkout {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #047857);
  color: white;
  border: none;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-checkout:disabled {
  background: #334155;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

/* -------------------------------------------------------------
 * Bottom Navigation (Mobile Native Feel)
 * ----------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--card-dark);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 4px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 8px;
  transition: all 0.15s;
}

.nav-item.active, .nav-item:hover {
  color: var(--primary);
}

.nav-icon {
  font-size: 1.25rem;
}

/* -------------------------------------------------------------
 * Modal Windows
 * ----------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal-card {
  background-color: var(--card-dark);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background-color: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: white;
  font-size: 0.95rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
}

.payment-methods-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.payment-method-card {
  background-color: #0f172a;
  border: 2px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.payment-method-card.selected {
  border-color: var(--primary);
  color: #fff;
  background-color: rgba(16, 185, 129, 0.1);
}

/* -------------------------------------------------------------
 * Toast Notification
 * ----------------------------------------------------------- */
.toast-msg {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #1e293b;
  color: white;
  border: 1px solid var(--primary);
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 0.88rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { top: 40px; opacity: 0; }
  to { top: 70px; opacity: 1; }
}

/* -------------------------------------------------------------
 * Scanner Container
 * ----------------------------------------------------------- */
#camera-reader {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background-color: #000;
}

/* -------------------------------------------------------------
 * Receipt Print Formatting
 * ----------------------------------------------------------- */
@media print {
  body {
    background-color: #fff !important;
    color: #000 !important;
    padding: 0 !important;
  }
  .top-header, .pos-container, .bottom-nav, .modal-overlay:not(.print-mode) {
    display: none !important;
  }
  .receipt-box {
    width: 80mm;
    margin: 0 auto;
    padding: 8px;
    font-size: 12px;
    color: #000;
  }
}
