/* =============================================
   Kasir MEK - styles.css
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --success:       #16a34a;
  --danger:        #dc2626;
  --warning:       #d97706;
  --sidebar-bg:    #1e293b;
  --sidebar-width: 220px;
  --topbar-h:      56px;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: #f1f5f9;
}

/* =============================================
   LAYOUT
   ============================================= */

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.tenant-info {
  padding: 12px 16px;
  font-size: 13px;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar nav {
  padding: 12px 10px;
  flex: 1;
}

.sidebar-bottom {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.65);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}

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

/* =============================================
   MAIN CONTENT
   ============================================= */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.topbar h2 {
  font-size: 18px;
  font-weight: 700;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* =============================================
   PAGES
   ============================================= */

.page { display: none; }
.page.active { display: block; }

/* =============================================
   QUICK ITEMS
   ============================================= */

.quick-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.quick-item-btn {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 10px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: border-color .15s, color .15s, transform .15s, box-shadow .15s;
}

.quick-item-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.quick-item-btn .price {
  color: var(--success);
  font-size: 12px;
  margin-top: 4px;
}

/* =============================================
   MANUAL ENTRY
   ============================================= */

.manual-entry {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* =============================================
   CART
   ============================================= */

.cart-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  max-height: 340px;
  margin-bottom: 12px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

.cart-item-name {
  flex: 1;
  font-weight: 600;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}

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

.cart-total {
  border-top: 2px solid #e2e8f0;
  padding-top: 12px;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}

.cart-total-row.grand {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

/* BUG FIX #1: Button text visibility */
.btn-success,
.btn-success:hover,
.btn-success:not(:disabled):not(.disabled):hover,
.btn-success:active,
.btn-success:focus {
  color: #fff !important;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.btn-success:disabled {
  opacity: 0.65;
  color: #fff !important;
}

#btnCheckout:disabled,
#btnPay:disabled {
  cursor: not-allowed;
}

/* =============================================
   PAYMENT MODAL
   ============================================= */

.payment-input {
  font-size: 24px;
  text-align: right;
  font-weight: 700;
}

.quick-amounts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-btn {
  flex: 1;
  min-width: 60px;
  padding: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  transition: background .15s, color .15s, border-color .15s;
}

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

/* =============================================
   PRINT STATUS
   ============================================= */

.print-status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  z-index: 9999;
  font-size: 14px;
  font-weight: 500;
}

.print-status.show { display: flex; }

.print-status .spinner i {
  animation: spin 1s linear infinite;
}

/* =============================================
   LOADING OVERLAY
   ============================================= */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.loading-overlay.show { display: flex; }

.loading-spinner {
  background: #fff;
  border-radius: 12px;
  padding: 30px 40px;
  text-align: center;
  font-weight: 600;
}

.loading-spinner i {
  font-size: 36px;
  color: var(--primary);
  animation: spin 1s linear infinite;
  display: block;
  margin-bottom: 10px;
}

/* =============================================
   TOAST
   ============================================= */

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
}

.toast-item {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slideIn .2s ease;
  min-width: 220px;
}

.toast-item.success { background: var(--success); }
.toast-item.error   { background: var(--danger); }
.toast-item.warning { background: var(--warning); }

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* =============================================
   HISTORY TABLE
   ============================================= */

.table th {
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
}
/* =============================================
   API TEST LOG
   ============================================= */

.api-test-log {
  background: rgba(0, 0, 0, 0.6);
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.api-test-log-entry {
  margin-bottom: 4px;
}

.api-test-info {
  color: #38bdf8;
}

.api-test-success {
  color: #22c55e;
}

.api-test-warning {
  color: #fbbf24;
}

.api-test-error {
  color: #f87171;
}

/* =============================================
   RESPONSIVE – MOBILE
   ============================================= */

/* Tombol hamburger (hanya muncul di mobile) */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #1e293b;
  font-size: 20px;
  line-height: 1;
}

/* Overlay gelap di belakang sidebar saat terbuka */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 998;
}

.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {

  /* Sidebar jadi drawer dari kiri */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 240px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Main content full-width */
  .main-content {
    width: 100%;
  }

  /* Topbar: tampilkan hamburger */
  .topbar {
    padding: 0 16px;
    gap: 12px;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .topbar h2 {
    font-size: 15px;
  }

  /* Content area padding lebih kecil */
  .content-area {
    padding: 14px 16px;
  }

  /* Quick items: 2 kolom di mobile */
  .quick-items {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Cart: height auto, hapus scroll fixed */
  .cart-items {
    max-height: 220px;
  }

  /* Payment modal quick amounts: wrap lebih baik */
  .quick-amounts {
    gap: 6px;
  }

  .quick-btn {
    min-width: 48px;
    font-size: 12px;
    padding: 7px 6px;
  }

  /* Payment input lebih kecil */
  .payment-input {
    font-size: 18px;
  }

  /* Print status: full width di bawah */
  .print-status {
    left: 16px;
    right: 16px;
    bottom: 16px;
    font-size: 13px;
  }

  /* Toast stack: full width */
  .toast-stack {
    left: 16px;
    right: 16px;
    top: 12px;
  }

  .toast-item {
    min-width: unset;
    width: 100%;
  }
}

@media (max-width: 400px) {
  /* Layar sangat kecil: quick items 2 kolom tetap tapi padding lebih tipis */
  .quick-item-btn {
    padding: 10px 6px;
    font-size: 12px;
  }

  .cart-total-row.grand {
    font-size: 15px;
  }
}