/* =========================================================
   style.css — POS Customer Display
   ABA KHQR template3_color design system
   ========================================================= */

/* ── Google Fonts ──────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Noto+Sans+Khmer:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
  /* ABA brand colours */
  --aba-red:          #E1251B;
  --aba-red-dark:     #B81E15;
  --aba-red-light:    #FF4D42;
  --aba-red-glow:     rgba(225, 37, 27, 0.25);

  /* Neutrals */
  --white:            #FFFFFF;
  --off-white:        #F8F9FA;
  --gray-100:         #F1F3F5;
  --gray-200:         #E9ECEF;
  --gray-300:         #DEE2E6;
  --gray-500:         #ADB5BD;
  --gray-700:         #495057;
  --gray-900:         #212529;

  /* Left panel / base neutral */
  --panel-bg:         #FFFFFF;
  --panel-surface:    #162235;
  --panel-border:     rgba(255,255,255,0.07);
  --panel-accent:     #4FC3F7;

  /* Brand Luxury Gold (#C08207) */
  --brand-gold:       #C08207;
  --brand-gold-light: #DF9B16;
  --brand-gold-bright:#F59E0B;
  --brand-gold-dark:  #9A6704;
  --brand-gold-glow:  rgba(192, 130, 7, 0.35);

  /* Success / Brand Celebration */
  --success:          #C08207;
  --success-dark:     #9A6704;
  --success-glow:     rgba(192, 130, 7, 0.35);

  /* Typography */
  --font-main:        'Outfit', sans-serif;
  --font-khmer:       'Noto Sans Khmer', sans-serif;

  /* Sizing */
  --radius-sm:        8px;
  --radius-md:        16px;
  --radius-lg:        24px;
  --radius-xl:        32px;

  /* Shadows */
  --shadow-card:      0 8px 32px rgba(0,0,0,0.35);
  --shadow-qr:        0 4px 24px rgba(0,0,0,0.18);
  --shadow-glow-red:  0 0 40px var(--aba-red-glow), 0 8px 32px rgba(0,0,0,0.4);
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--panel-bg);
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Shell ─────────────────────────────────────────── */
#app {
  width: 100vw; height: 100vh;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* =========================================================
   IDLE / WELCOME SCREEN
   ========================================================= */
#screen-idle {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  gap: 28px;
  position: absolute; inset: 0;
  transition: opacity 0.5s ease;
}

.idle-brand-container {
  max-width: 320px;
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logoPulse 4s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08)); }
  50%      { transform: scale(1.03); filter: drop-shadow(0 8px 24px rgba(0,0,0,0.15)); }
}

.idle-brand-logo {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.idle-tagline {
  font-size: clamp(0.95rem, 1.5vw, 1.15rem);
  font-weight: 500;
  color: #495057;
  text-align: center;
  max-width: 420px;
  line-height: 1.6;
}

.idle-scan-indicator {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px;
  border-radius: 999px;
  border: 1.5px solid #DEE2E6;
  background: #F8F9FA;
  color: #6C757D;
  font-size: 0.88rem;
  font-weight: 600;
}

.idle-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--aba-red);
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; } 50% { opacity: 0.2; }
}

.idle-store-indicator {
  display: none;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(225,37,27,0.08);
  border: 1px solid rgba(225,37,27,0.2);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--aba-red);
  letter-spacing: 0.5px;
}

/* =========================================================
   PENDING / SPLIT SCREEN — ODOO POS RECEIPT DESIGN
   ========================================================= */
#screen-pending {
  width: 100%; height: 100%;
  display: flex;
  position: absolute; inset: 0;
  transition: opacity 0.5s ease;
  background: #F8F9FA;
}

/* ── Left Panel (50%): Hero Brand Logo ────────────────── */
.panel-left {
  width: 50%;
  height: 100%;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  border-right: 1px solid #E9ECEF;
  position: relative;
}

.brand-hero-wrapper {
  max-width: 340px;
  width: 85%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-brand-logo {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.08));
}

.panel-left-footer {
  position: absolute;
  bottom: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-ref-chip {
  padding: 6px 18px;
  border-radius: 999px;
  background: #F1F3F5;
  border: 1px solid #DEE2E6;
  font-size: 0.82rem;
  font-weight: 700;
  color: #212529;
}

/* ── Right Panel (50%): Clean Receipt & Payment ───────── */
.panel-right {
  width: 50%;
  height: 100%;
  background: #F8F9FA;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 0;  /* no bottom padding — total row sits flush */
  position: relative;
  overflow: hidden;      /* prevent panel itself from scrolling */
}

.right-content-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  flex: 1;               /* fill remaining height */
  min-height: 0;         /* allow flex children to shrink */
  overflow: hidden;
}

.receipt-header {
  border-bottom: 2px solid #DEE2E6;
  padding-bottom: 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.receipt-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0F172A;
  letter-spacing: -0.3px;
}

.items-list-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;               /* grow to fill space between header and total */
  min-height: 0;         /* critical: allow shrink inside flex parent */
  overflow-y: auto;
  padding-right: 4px;
}

.items-list-container::-webkit-scrollbar { width: 5px; }
.items-list-container::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }

/* Item Row matching Odoo POS Receipt Layout */
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #E2E8F0;
  animation: slideIn 0.25s ease-out;
}

/* Item Thumbnail (Modern retail aesthetic) */
.item-thumb-wrapper {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 14px;
  flex-shrink: 0;
  position: relative;
}

.item-thumb-wrapper.item-thumb-empty {
  background: #F8FAFC;
  border-color: #E2E8F0;
}

.item-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.item-placeholder-icon {
  width: 22px;
  height: 22px;
  color: #94A3B8;
  opacity: 0.8;
}

.item-main-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding-right: 16px;
}

.item-name {
  font-size: 0.96rem;
  font-weight: 700;
  color: #0F172A;
  line-height: 1.35;
}

.item-sub-detail {
  font-size: 0.82rem;
  font-weight: 500;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 4px;
}

.item-qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background: #E2E8F0;
  border: 1px solid #CBD5E1;
  font-weight: 800;
  color: #0F172A;
  font-size: 0.76rem;
}

.item-line-total {
  font-size: 1rem;
  font-weight: 800;
  color: #0F172A;
  white-space: nowrap;
}

/* Receipt Total Row — pinned at bottom of right panel */
.receipt-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 2px solid #0F172A;
  margin-top: 4px;
  flex-shrink: 0;        /* never compress */
}

.receipt-total-label {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0F172A;
}

.receipt-total-value {
  font-size: 1.7rem;
  font-weight: 900;
  color: #E1251B;
}

/* KHQR Card Section — shown below total, no extra bottom space */
.khqr-card-section {
  margin-top: 10px;
  margin-bottom: 0;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  padding-bottom: 16px;  /* breathing room at very bottom only when QR shown */
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 1;
  transform: translateY(0);
}

.khqr-card-section.hidden-qr {
  display: none !important;
  opacity: 0 !important;
  transform: translateY(20px) !important;
  pointer-events: none !important;
}

/* Decorative circles */
.panel-right::before,
.panel-right::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.panel-right::before {
  width: 500px; height: 500px;
  top: -180px; right: -180px;
  background: radial-gradient(circle, rgba(225,37,27,0.15) 0%, transparent 70%);
}
.panel-right::after {
  width: 300px; height: 300px;
  bottom: -100px; left: -80px;
  background: radial-gradient(circle, rgba(225,37,27,0.1) 0%, transparent 70%);
}

/* ── ABA KHQR Modal Popup Overlay (Official ABA PayWay template3_color) ── */
.khqr-modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Dark semi-transparent backdrop overlay */
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  opacity: 1;
  visibility: visible;
}

.khqr-modal-overlay.hidden-modal {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* =========================================================
   OFFICIAL ABA PAYWAY template3_color SPECIFICATION
   ========================================================= */

/* Template 3 Popup Wrapper — clean light gray rounded container box matching reference */
.t3-modal-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90%;
  max-width: 386px;
  animation: t3Popup 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;

  /* Clean solid light neutral gray squarcle card container matching reference */
  border-radius: 34px;
  padding: 26px 85px 26px;
  background: #E8EAEF;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.42);
}

/* When showing direct pre-rendered ABA PayWay official Base64 image, keep generous side margins matching reference */
.t3-modal-wrapper.t3-wrapper-raw-image {
  background: #E8EAEF !important;
  border-radius: 34px !important;
  padding: 26px 76px !important;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.42) !important;
  max-width: 380px !important;
  width: 90% !important;
  box-sizing: border-box !important;
}

@keyframes t3Popup {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ABA' PAY Logo Centered Above Ticket */
.t3-brand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}

.t3-aba-pay-logo {
  height: 28px;
  width: auto;
  display: block;
}

/* Official PayWay Pre-rendered template3_color Base64 Image */
.t3-official-image {
  max-width: 226px;
  width: 100%;
  height: auto;
  border-radius: 0;
  display: block;
  margin: 0 auto;
  filter: none;
  animation: modalPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.t3-official-image.hidden {
  display: none !important;
}

/* Official template3_color Single White Card — Exact Reference Proportions */
.t3-card {
  position: relative;
  width: 100%;
  max-width: 206px;
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Red Ribbon Banner with Signature Chamfer Cut & Centered KHQR Logo */
.t3-banner {
  position: relative;
  width: 100%;
  height: 40px;
  background: #E1251B;
  /* Official diagonal chamfer cut on bottom-right corner */
  clip-path: polygon(0 0, 100% 0, 100% 55%, 85% 100%, 0 100%);
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 55%, 85% 100%, 0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.t3-khqr-logo {
  height: 14px;
  width: auto;
  display: block;
}

/* Merchant Info: Left-aligned */
.t3-merchant-box {
  padding: 10px 14px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.t3-merchant-name {
  font-size: 11.5px;
  font-weight: 500;
  color: #374151;
  margin: 0 0 2px 0;
  letter-spacing: -0.01em;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.t3-amount {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* Dashed divider line across ticket */
.t3-dashed-divider {
  width: calc(100% - 28px);
  margin: 8px 14px 10px;
  border-top: 1.5px dashed #D8DCE0;
}

/* QR Code Box — Exact Square */
.t3-qr-wrap {
  position: relative;
  width: 154px;
  height: 154px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.t3-qr-container {
  width: 154px;
  height: 154px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  position: relative;
}

.t3-qr-container canvas,
.t3-qr-container img,
.t3-qr-container svg,
.pw-khqr-qr-image {
  width: 154px !important;
  height: 154px !important;
  display: block;
  border-radius: 4px;
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #94A3B8;
  font-size: 0.85rem;
}

/* Official Circular Red Bakong Emblem Badge centered in QR */
.t3-bakong-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
  z-index: 5;
}

/* Official footer caption below ticket */
.t3-caption {
  text-align: center;
  color: #7E8B9B;
  font-size: 11px;
  font-weight: 500;
  margin: 14px 0 0;
  padding: 0 4px;
  line-height: 1.35;
  max-width: 200px;
}

/* =========================================================
   LUXURY BOUTIQUE OVERLAYS — SUCCESS & EXPIRED
   Cohesive with SK Cosmetic Brand (Gold #C08207 & Clean Light Porcelain)
   ========================================================= */

#screen-success,
#screen-expired {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  overflow: hidden;
  padding: 20px;
  box-sizing: border-box;
}

/* Boutique Luxury Modal Card */
.boutique-modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 34px 38px 28px;
  border-radius: 30px;
  max-width: 460px;
  width: 92%;
  box-sizing: border-box;
  background: #FFFFFF;
  border: 1.5px solid rgba(192, 130, 7, 0.25);
  box-shadow:
    0 24px 60px -12px rgba(15, 23, 42, 0.14),
    0 8px 24px -4px rgba(192, 130, 7, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  animation: boutiquePop 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes boutiquePop {
  from { opacity: 0; transform: scale(0.93) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Card Brand Header */
.card-brand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.card-brand-logo {
  height: 44px;
  max-width: 140px;
  object-fit: contain;
}

/* Delicate Status Icon Rings */
.status-icon-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  animation: iconPulseIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes iconPulseIn {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}

/* Success Ring: Fresh Emerald with subtle Gold shimmer */
.status-icon-ring.success-ring {
  background: #ECFDF5;
  border: 2.5px solid #10B981;
  box-shadow: 0 10px 25px -4px rgba(16, 185, 129, 0.35);
  color: #059669;
}

/* Expired Ring: Soft Rose / Coral */
.status-icon-ring.expired-ring {
  background: #FEF2F2;
  border: 2.5px solid #EF4444;
  box-shadow: 0 10px 25px -4px rgba(239, 68, 68, 0.3);
  color: #DC2626;
}

.status-icon-svg {
  width: 36px;
  height: 36px;
  display: block;
}

/* Status Micro Badge */
.status-pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.status-pill-tag.success-tag {
  background: #DEF7EC;
  color: #03543F;
  border: 1px solid #BCF0DA;
}

.status-pill-tag.expired-tag {
  background: #FDE8E8;
  color: #9B1C1C;
  border: 1px solid #FBD5D5;
}

/* Main Titles */
.card-main-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0F172A;
  margin: 0;
  line-height: 1.25;
  font-family: var(--font-khmer), var(--font-main);
}

.card-sub-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #C08207;
  margin: 2px 0 0;
  letter-spacing: 0.2px;
}

/* Amount Box — High Luxury Ivory Card */
.card-amount-box {
  background: #FCFAF6;
  border: 1px solid #EFE6D3;
  border-radius: 18px;
  padding: 10px 18px;
  width: 100%;
  box-sizing: border-box;
  margin: 12px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-amount-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #8C7B65;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.card-amount-val {
  font-size: 1.95rem;
  font-weight: 900;
  color: #0F172A;
  line-height: 1.1;
  font-family: var(--font-main);
}

.card-amount-val .currency-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: #C08207;
  margin-left: 4px;
}

/* Receipt Details List */
.card-meta-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  padding-bottom: 6px;
  border-bottom: 1px dashed #E2E8F0;
}

.card-meta-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.meta-label {
  color: #64748B;
  font-weight: 500;
}

.meta-value {
  color: #1E293B;
  font-weight: 700;
  font-family: var(--font-main), var(--font-khmer);
}

.meta-value.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  color: #334155;
  background: #F1F5F9;
  padding: 2px 8px;
  border-radius: 6px;
}

.meta-value.success-status {
  color: #059669;
  font-weight: 700;
}

.meta-value.expired-status {
  color: #DC2626;
  font-weight: 700;
}

/* Card Message / Advice */
.card-client-message {
  font-size: 0.84rem;
  color: #64748B;
  line-height: 1.45;
  margin: 0 0 12px;
}

/* Auto-Reset Countdown Bar */
.card-countdown-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748B;
}

.countdown-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #C08207;
  animation: pulseDot 1.4s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.75); }
}

/* =========================================================
   UTILITY — visibility helpers
   ========================================================= */
.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* =========================================================
   RESPONSIVE SAFEGUARDS (TV / kiosk landscape)
   ========================================================= */
@media (max-width: 900px) {
  #screen-pending { flex-direction: column; }
  .panel-left, .panel-right { width: 100%; height: 50%; }
  .panel-left { border-right: none; border-bottom: 1px solid var(--panel-border); }
  .khqr-outer-card { max-width: 280px; }
}
