/* ==========================================================================
   KasirOnline POS - Style Sheet with Preloader Animation & Refresh Button
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;
  --dark-slate: #0f172a;
  --text-main: #1e293b;
  --text-sub: #64748b;
  --text-light: #94a3b8;
  --bg-page: #f1f5f9;
  --bg-white: #ffffff;
  --border-color: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.4;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ===== PRELOADER SCREEN ===== */
.app-preloader {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.app-preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner-emerald {
  width: 48px;
  height: 48px;
  border: 4px solid var(--emerald-light);
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.preloader-text {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--dark-slate);
  letter-spacing: -0.2px;
}

/* ===== SKELETON SHIMMER PRELOADER CARDS ===== */
.skeleton-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.skeleton-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 8px;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 6px;
}

.skeleton-line.short { width: 50%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== PWA INSTALL BANNER ===== */
.pwa-install-banner {
  background: linear-gradient(90deg, #047857 0%, #10b981 100%);
  color: #ffffff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  z-index: 1000;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.pwa-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwa-banner-left i {
  font-size: 18px;
  color: #a7f3d0;
}

.pwa-banner-btn {
  background: #ffffff;
  color: #047857;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwa-banner-btn:hover {
  background: #ecfdf5;
  transform: scale(1.05);
}

.pwa-banner-close {
  background: rgba(0,0,0,0.15);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== MAIN CONTAINER ===== */
.pos-tablet-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ===== TOP COMPACT NAVBAR ===== */
.pos-navbar {
  height: 50px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  width: 32px;
  height: 32px;
  background: var(--emerald);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.brand-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--dark-slate);
  letter-spacing: -0.3px;
}

.shift-info-tag {
  background: var(--emerald-light);
  color: var(--emerald-dark);
  border: 1px solid var(--emerald-border);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

.shift-dot {
  width: 6px;
  height: 6px;
  background: var(--emerald);
  border-radius: 50%;
}

.nav-right-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  width: 180px;
}

.nav-search-box i {
  color: var(--text-light);
  font-size: 11px;
}

.nav-search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--text-main);
  width: 100%;
}

.btn-nav-refresh {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  color: var(--dark-slate);
  border-radius: 20px;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-nav-refresh:hover {
  background: var(--emerald-light);
  border-color: var(--emerald-border);
  color: var(--emerald-dark);
}

.btn-nav-refresh i.spin {
  animation: spin 0.6s linear infinite;
}

.btn-nav-install {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--emerald-light);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-dark);
  border-radius: 20px;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-nav-install:hover {
  background: var(--emerald);
  color: #fff;
}

.btn-icon-nav {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.btn-icon-nav:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

/* WORKSPACE */
.pos-body-grid {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.catalog-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.pull-refresh-bar {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--emerald-light);
  color: var(--emerald-dark);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
  transition: height 0.15s ease-out;
}

.category-tabs-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.category-tabs-bar::-webkit-scrollbar { height: 0; }

.cat-tab-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.cat-tab-btn.active {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}

.products-grid-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior-y: contain;
}

.menu-grid-4col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 900px) {
  .menu-grid-4col { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .menu-grid-4col { grid-template-columns: repeat(2, 1fr); }
}

/* SQUARE CARDS */
.product-card-compact {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  position: relative;
}

.product-card-compact:hover {
  border-color: var(--emerald);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.product-card-compact.selected {
  border-color: var(--emerald);
  background: var(--emerald-light);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.qty-selected-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--emerald);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 12px;
  z-index: 2;
}

.product-thumb-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 6px;
}

.product-thumb-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
}

.product-card-compact:hover .product-thumb-container img {
  transform: scale(1.05);
}

.product-info-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.product-name-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-stock-text {
  font-size: 0.68rem;
  color: var(--text-light);
}

.product-price-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.price-val-text {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--emerald-dark);
}

.btn-add-touch {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--emerald-light);
  color: var(--emerald-dark);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.product-card-compact.selected .btn-add-touch,
.btn-add-touch:hover {
  background: var(--emerald);
  color: #fff;
}

/* ORDER SIDEBAR */
.order-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-white);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.order-top-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.order-title-text {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--dark-slate);
}

.order-type-switch {
  display: flex;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.type-btn {
  flex: 1;
  padding: 5px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-sub);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.type-btn.active {
  background: #fff;
  color: var(--emerald-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cust-input {
  width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.75rem;
  outline: none;
}
.cust-input:focus { border-color: var(--emerald); }

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

.cart-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.cart-item-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.cart-item-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-unit-price {
  font-size: 0.68rem;
  color: var(--text-sub);
}

.cart-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-subtotal-price {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--emerald-dark);
  min-width: 55px;
  text-align: right;
}

.stepper-mini {
  display: flex;
  align-items: center;
  gap: 3px;
}

.step-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-main);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.step-btn.plus {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #fff;
}

.step-val {
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 14px;
  text-align: center;
}

.cart-empty-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  gap: 6px;
  padding: 16px;
  text-align: center;
}
.cart-empty-box i { font-size: 28px; opacity: 0.4; }
.cart-empty-box p { font-size: 0.75rem; }

.order-bottom-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: #fff;
}

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

.calc-row-total {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 800;
  color: var(--dark-slate);
  padding-top: 5px;
  border-top: 1px dashed var(--border-color);
  margin-top: 5px;
  margin-bottom: 8px;
}

.calc-row-total span:last-child {
  color: var(--emerald-dark);
}

.btn-pay-action {
  width: 100%;
  padding: 10px;
  background: var(--emerald);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-pay-action:hover:not(:disabled) {
  background: var(--emerald-dark);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-pay-action:disabled {
  background: var(--text-light);
  opacity: 0.6;
  cursor: not-allowed;
}

/* MODALS */
.modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.modal-layer.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box-card {
  background: #fff;
  border-radius: var(--radius-md);
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
  overflow: hidden;
}

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

.modal-box-header h3 {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--dark-slate);
}

.btn-modal-x {
  background: var(--bg-page);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
}

.modal-box-body {
  padding: 14px 16px;
}

.quick-pay-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.pay-card-btn {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-sub);
}

.pay-card-btn.active {
  border-color: var(--emerald);
  background: var(--emerald-light);
  color: var(--emerald-dark);
}

.pay-card-btn i {
  display: block;
  font-size: 16px;
  margin-bottom: 3px;
}

.change-display-box {
  background: var(--emerald-light);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.change-display-box span { font-size: 0.75rem; font-weight: 600; color: var(--emerald-dark); }
.change-display-box strong { font-size: 1.05rem; font-weight: 800; color: var(--emerald-dark); }

.modal-box-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

.btn-modal-cancel {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
}

.btn-modal-submit {
  flex: 1;
  padding: 8px;
  background: var(--emerald);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.install-step-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.install-step-num {
  width: 24px;
  height: 24px;
  background: var(--emerald);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.receipt-sheet {
  font-family: 'Courier New', Courier, monospace;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 14px;
  max-width: 280px;
  margin: 0 auto;
}
