:root {
  --primary: #f97316;
  --primary-hover: #ea580c;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 12px;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.pos-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-emoji {
  font-size: 26px;
}

.brand h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.branch-tag {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

/* Header Center Search */
.header-center {
  flex: 1;
  max-width: 320px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 14px;
  opacity: 0.6;
}

#searchInput {
  width: 100%;
  padding: 8px 30px 8px 32px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: white;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#searchInput:focus {
  border-color: var(--primary);
}

.btn-clear-search {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cashier-tag {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
}

/* Main Body */
.pos-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Products Section */
.products-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  background-color: var(--bg-dark);
}

.categories-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}

.categories-bar::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  padding: 8px 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.cat-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.products-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.product-card {
  position: relative;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  height: 120px;
}

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

.product-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.product-stock {
  font-size: 11px;
  color: var(--text-muted);
}

.product-price {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  margin-top: auto;
}

.product-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background-color: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Cart Section */
.cart-section {
  width: 380px;
  background-color: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

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

.cart-header h2 {
  font-size: 16px;
  font-weight: 800;
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

/* Customer CRM Row */
.customer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border);
}

.customer-icon {
  font-size: 16px;
}

#customerPhoneInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12px;
}

#customerPhoneInput::placeholder {
  color: var(--text-muted);
}

.cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.cart-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.item-info {
  flex: 1;
  padding-right: 8px;
}

.item-name {
  font-size: 13px;
  font-weight: 700;
}

.item-subtotal {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 2px;
}

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

.btn-qty {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: var(--bg-hover);
  border: none;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-qty:active {
  background-color: var(--primary);
}

.item-qty {
  font-size: 13px;
  font-weight: 700;
  width: 18px;
  text-align: center;
}

.cart-footer {
  padding: 14px 16px;
  background-color: #0b1120;
  border-top: 1px solid var(--border);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}

.total-price {
  font-size: 20px;
  font-weight: 900;
  color: var(--primary);
}

.payment-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-pay {
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.btn-pay:active {
  transform: scale(0.98);
}

.btn-cash {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-card {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background-color: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Cash Modal Specific */
.cash-modal-box {
  background: #1e293b;
  color: white;
}

.cash-modal-box h3 {
  font-size: 17px;
  margin-bottom: 12px;
  text-align: center;
}

.cash-summary {
  background: #0f172a;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 14px;
  text-align: center;
  font-size: 14px;
}

.cash-summary strong {
  color: var(--primary);
  font-size: 16px;
}

.input-group label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.cash-input {
  width: 100%;
  padding: 12px;
  background: #0f172a;
  border: 2px solid var(--primary);
  border-radius: 8px;
  color: white;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  outline: none;
  margin-bottom: 12px;
}

.quick-cash-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.btn-quick-cash {
  padding: 8px 4px;
  background: #334155;
  border: 1px solid #475569;
  color: white;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-quick-cash:active {
  background: var(--primary);
}

.change-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.change-amount {
  font-size: 18px;
  font-weight: 900;
  color: var(--success);
}

.modal-actions-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
}

.btn-primary {
  background: var(--success);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary {
  background: #334155;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

/* Receipt Paper */
.receipt-paper {
  background-color: #ffffff;
  color: #000000;
  padding: 16px;
  border-radius: 8px;
  font-family: 'Courier New', Courier, monospace;
}

.receipt-header {
  text-align: center;
  margin-bottom: 8px;
}

.receipt-header h3 {
  font-size: 16px;
  font-weight: 800;
}

.receipt-header p {
  font-size: 11px;
  color: #555;
}

.divider {
  text-align: center;
  font-size: 10px;
  color: #999;
  margin: 6px 0;
}

.receipt-items {
  margin: 8px 0;
}

.receipt-item-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 3px;
}

.receipt-total {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 900;
  margin-top: 6px;
}

.receipt-paytype,
.receipt-change-row,
.receipt-bonus-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-top: 3px;
}

.receipt-bonus-row span {
  color: #059669;
  font-weight: bold;
}

.receipt-footer {
  text-align: center;
  margin-top: 12px;
  font-size: 11px;
}

.receipt-footer small {
  display: block;
  font-size: 9px;
  color: #888;
  margin-top: 4px;
}

/* Receipt Actions */
.receipt-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.btn-print {
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-kot {
  background: #f97316;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-modal-close {
  grid-column: span 2;
  background: #0f172a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* 💳 QR Code Payment Modal */
.qr-modal-box {
  text-align: center;
  max-width: 360px;
}

.qr-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.qr-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.qr-amount-badge {
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid rgba(249, 115, 22, 0.4);
  padding: 8px 14px;
  border-radius: 8px;
  margin: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.qr-amount-badge strong {
  font-size: 16px;
  color: var(--primary);
}

.qr-code-wrapper {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.qr-card {
  background: #ffffff;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-visual {
  margin-bottom: 8px;
}

.qr-logos-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.pay-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.click-badge {
  background: #0077ff;
  color: #fff;
}

.payme-badge {
  background: #00cccc;
  color: #000;
}

.card-badge {
  background: #1e293b;
  color: #fff;
}

.qr-instruction {
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0 14px;
  line-height: 1.4;
}

/* 🖨️ Thermal Receipt Printing Stylesheet (58mm / 80mm) */
@media print {
  body * {
    visibility: hidden;
  }
  #printableReceipt, #printableReceipt * {
    visibility: visible;
  }
  #printableReceipt {
    position: absolute;
    left: 0;
    top: 0;
    width: 58mm;
    margin: 0;
    padding: 2mm;
    background: #fff;
    color: #000;
    font-size: 11px;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .pos-header {
    flex-wrap: wrap;
  }
  .header-center {
    order: 3;
    max-width: 100%;
    width: 100%;
    margin-top: 6px;
  }
  .pos-body {
    flex-direction: column;
  }
  .cart-section {
    width: 100%;
    height: 46vh;
  }
}
