/* =====================================================================
   Coffee POS — theme
   ===================================================================== */
:root {
  --brand: #6F4E37;
  --brand-dark: #4B3325;
  --brand-light: #F3E9DF;
  --accent: #C8A27A;
  --bg: #F6F1EB;
  --card: #FFFFFF;
  --text: #2E2420;
  --muted: #8A7B72;
  --border: #EADFD4;
  --success: #2E9E6A;
  --warning: #E9A23B;
  --danger: #D9534F;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(75, 51, 37, .07);
  --sidebar-w: 250px;
  --bs-body-font-family: 'Prompt', system-ui, sans-serif;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-primary: var(--brand);
  --bs-primary-rgb: 111, 78, 55;
  --bs-link-color: var(--brand);
  --bs-link-hover-color: var(--brand-dark);
  --bs-link-color-rgb: 111, 78, 55;
}

body { background: var(--bg); font-weight: 300; -webkit-tap-highlight-color: transparent; }
b, strong, .fw-semibold { font-weight: 500 !important; }
.fw-bold, h1, h2, h3, h4, h5, h6 { font-weight: 600 !important; }

/* ---------- Bootstrap overrides ---------- */
.btn { border-radius: 10px; font-weight: 400; }
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand);
}
.btn-soft { background: var(--brand-light); color: var(--brand-dark); border: 0; }
.btn-soft:hover { background: #EADBCB; color: var(--brand-dark); }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; }
.form-control, .form-select { border-radius: 10px; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(200, 162, 122, .25);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.nav-pills .nav-link.active { background: var(--brand); }
.nav-pills .nav-link { color: var(--brand-dark); }
.modal-content { border: 0; border-radius: 18px; }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }
.badge { font-weight: 400; }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.bg-brand-light { background: var(--brand-light) !important; }

.card { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; font-weight: 500; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, var(--brand-dark), #3A271C);
  color: #fff; display: flex; flex-direction: column; flex-shrink: 0;
}
@media (min-width: 992px) {
  .layout-default .sidebar { position: sticky; top: 0; height: 100vh; }
}
.sidebar.offcanvas, .sidebar.offcanvas-lg { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: var(--brand-dark); --bs-offcanvas-color: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { font-size: 1.8rem; width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.1); display: grid; place-items: center; }
.brand-name { font-weight: 500; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.nav-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.4); padding: 1rem .75rem .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-radius: 10px;
  color: rgba(255,255,255,.75); text-decoration: none; margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--accent); color: var(--brand-dark); font-weight: 500; }
.sidebar-user { display: flex; align-items: center; gap: .6rem; padding: 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--brand-dark); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; height: 64px; display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem; background: rgba(246, 241, 235, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.page-title { font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 1.25rem; flex: 1; }
.layout-full .content { padding: 0; }
@media (max-width: 575.98px) {
  .content { padding: .9rem; }
  .topbar { padding: 0 .6rem; height: 56px; }
  .page-title { font-size: 1.05rem; }
}

/* ---------- Stat cards ---------- */
.stat-card { padding: 1.1rem 1.25rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; flex-shrink: 0; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.55rem; font-weight: 600; line-height: 1.2; }
.stat-sub { font-size: .8rem; }
.ic-brown { background: var(--brand-light); color: var(--brand); }
.ic-green { background: #E3F4EC; color: var(--success); }
.ic-orange { background: #FDF0DD; color: #C77C12; }
.ic-blue { background: #E4EEFB; color: #2F6BC4; }
.ic-red { background: #FBE6E5; color: var(--danger); }

/* ---------- DataTables ---------- */
table.dataTable { font-size: .92rem; }
table.dataTable thead th { font-weight: 500; background: var(--brand-light); color: var(--brand-dark); border-bottom: 0 !important; white-space: nowrap; }
table.dataTable thead th:first-child { border-top-left-radius: 10px; }
table.dataTable thead th:last-child { border-top-right-radius: 10px; }
table.dataTable > tbody > tr > td { vertical-align: middle; }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
div.dt-container .dt-paging .page-link { color: var(--brand); }
div.dt-container div.dt-search input { border-radius: 10px; }
.table-actions { white-space: nowrap; }
.table-actions .btn { padding: .2rem .5rem; }

/* ---------- Status pills ---------- */
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; white-space: nowrap; }
.pill-OPEN, .pill-UNPAID { background: #EEE; color: #555; }
.pill-PREPARING, .pill-PARTIAL, .pill-QUEUED { background: #FDF0DD; color: #A8650B; }
.pill-READY { background: #E4EEFB; color: #2F6BC4; }
.pill-COMPLETED, .pill-PAID, .pill-DONE { background: #E3F4EC; color: #1F7A50; }
.pill-VOIDED, .pill-REFUNDED { background: #FBE6E5; color: #B23B37; }
.pill-MERGED { background: #EFE7F7; color: #6A47A0; }

/* ---------- SweetAlert ---------- */
.swal2-popup { border-radius: 18px !important; font-family: 'Prompt', sans-serif !important; }
.swal2-styled.swal2-confirm { background: var(--brand) !important; border-radius: 10px !important; }
.swal2-styled.swal2-cancel, .swal2-styled.swal2-deny { border-radius: 10px !important; }
.swal2-input, .swal2-textarea, .swal2-select { border-radius: 10px !important; font-family: inherit; }

/* =====================================================================
   POS
   ===================================================================== */
.pos { display: flex; height: calc(100vh - 64px); height: calc(100dvh - 64px); }
.pos-menu { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pos-toolbar { padding: .9rem 1rem .5rem; }
.cat-pills { display: flex; gap: .5rem; overflow-x: auto; padding: .25rem 1rem .75rem; scrollbar-width: none; }
.cat-pills::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: .45rem 1rem; display: inline-flex; gap: .4rem; align-items: center; color: var(--text); font-size: .92rem;
}
.cat-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.product-grid {
  flex: 1; overflow-y: auto; padding: 0 1rem 6rem; display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); align-content: start;
}
.product-card {
  position: relative; border: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .6rem; text-align: left; display: flex; flex-direction: column; gap: .4rem; transition: transform .1s, box-shadow .15s;
}
.product-card:hover { box-shadow: 0 6px 18px rgba(75,51,37,.13); }
.product-card:active { transform: scale(.97); }
.product-thumb {
  aspect-ratio: 4/3; border-radius: 10px; display: grid; place-items: center; font-size: 2.2rem; color: #fff;
  background-size: cover; background-position: center;
}
.product-name { font-size: .92rem; font-weight: 400; line-height: 1.3; min-height: 2.4em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-price { color: var(--brand); font-weight: 600; }
.product-card.oos { opacity: .55; }
.product-card .oos-badge { position: absolute; top: .9rem; right: .9rem; }

.pos-cart {
  width: 400px; background: var(--card); border-left: 1px solid var(--border); display: flex; flex-direction: column;
}
.pos-cart.offcanvas-lg { --bs-offcanvas-width: 420px; }
.cart-head { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.channel-switch .btn { flex: 1; font-size: .85rem; padding: .4rem .2rem; }
.channel-switch .btn-check:checked + .btn { background: var(--brand); color: #fff; border-color: var(--brand); }
.member-box { background: var(--brand-light); border-radius: 12px; padding: .5rem .75rem; }
.cart-items { flex: 1; overflow-y: auto; padding: .5rem 1rem; }
.cart-line { display: flex; gap: .6rem; padding: .65rem 0; border-bottom: 1px dashed var(--border); }
.cart-line .info { flex: 1; min-width: 0; cursor: pointer; }
.cart-line .name { font-weight: 400; }
.cart-line .opts { font-size: .8rem; color: var(--muted); }
.cart-line.saved { opacity: .8; }
.cart-line.saved .info { cursor: default; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; }
.qty-stepper button { border: 0; background: none; width: 30px; height: 30px; font-size: 1rem; color: var(--brand); }
.qty-stepper span { min-width: 26px; text-align: center; font-weight: 500; }
.cart-empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.cart-empty i { font-size: 3rem; opacity: .35; }
.cart-foot { border-top: 1px solid var(--border); padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom)); background: #FFFCF9; }
.cart-total { font-size: 1.6rem; font-weight: 600; color: var(--brand-dark); }
.btn-pay { font-size: 1.15rem; padding: .7rem; }
.mobile-cart-bar {
  position: fixed; left: .75rem; right: .75rem; bottom: calc(.75rem + env(safe-area-inset-bottom)); z-index: 1030;
  border-radius: 14px; padding: .8rem 1.1rem; display: flex; align-items: center; gap: .75rem; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
@media (max-width: 991.98px) {
  .pos-cart { width: auto; border-left: 0; }
}

/* Option modal chips */
.opt-group + .opt-group { margin-top: 1rem; }
.opt-group-title { font-weight: 500; margin-bottom: .45rem; display: flex; gap: .5rem; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip input { display: none; }
.chip span {
  display: inline-block; padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  user-select: none; transition: all .12s; background: #fff;
}
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip small { opacity: .75; }

/* Payment modal */
.pay-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: .5rem; }
.pay-method {
  border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: .7rem .3rem; text-align: center; font-size: .82rem;
}
.pay-method i { font-size: 1.5rem; display: block; margin-bottom: .2rem; color: var(--brand); }
.pay-method.active { border-color: var(--brand); background: var(--brand-light); box-shadow: inset 0 0 0 1px var(--brand); }
.due-box { background: var(--brand-dark); color: #fff; border-radius: 14px; padding: 1rem 1.25rem; }
.due-box .amount { font-size: 2.2rem; font-weight: 600; line-height: 1.1; }
.cash-quick .btn { min-width: 70px; }
.qr-box { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 1rem; display: inline-block; }
.qr-box img, .qr-box canvas { margin: 0 auto; }
.pp-header { background: #113566; color: #fff; border-radius: 10px 10px 0 0; padding: .4rem; font-weight: 500; }

/* =====================================================================
   KDS + queue display
   ===================================================================== */
.kds-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); padding: 1rem; align-items: start; }
.ticket { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border-top: 6px solid var(--success); }
.ticket.warn { border-top-color: var(--warning); }
.ticket.late { border-top-color: var(--danger); }
.ticket-head { padding: .7rem 1rem; display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.ticket-queue { font-size: 1.6rem; font-weight: 600; color: var(--brand-dark); }
.ticket-timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; }
.ticket-items { list-style: none; margin: 0; padding: 0; }
.ticket-item { padding: .6rem 1rem; border-bottom: 1px dashed var(--border); cursor: pointer; display: flex; gap: .6rem; }
.ticket-item:hover { background: #FFFAF5; }
.ticket-item .qty { font-weight: 600; color: var(--brand); min-width: 28px; }
.ticket-item.PREPARING { background: #FFF6E8; }
.ticket-item.DONE { opacity: .45; text-decoration: line-through; }
.ticket-item .opts { font-size: .85rem; color: #6b5a4f; }
.ticket-item .note { font-size: .85rem; color: var(--danger); }
.ticket-foot { padding: .6rem; display: flex; gap: .5rem; }

.queue-display { min-height: 100vh; background: var(--brand-dark); color: #fff; display: flex; flex-direction: column; }
.queue-display header { padding: 1.2rem 2rem; display: flex; align-items: center; gap: 1rem; font-size: 1.5rem; }
.queue-cols { flex: 1; display: grid; grid-template-columns: 1fr 1.3fr; gap: 1.5rem; padding: 0 2rem 2rem; }
.queue-col { background: rgba(255,255,255,.06); border-radius: 22px; padding: 1.5rem; }
.queue-col h2 { font-size: 1.8rem; margin-bottom: 1.2rem; }
.queue-numbers { display: flex; flex-wrap: wrap; gap: 1rem; }
.queue-num { font-size: 3rem; font-weight: 600; background: rgba(255,255,255,.1); border-radius: 16px; padding: .4rem 1.2rem; }
.queue-col.ready .queue-num { background: var(--accent); color: var(--brand-dark); font-size: 4rem; }
.queue-num.flash { animation: flash 1s ease-in-out 5; }
@keyframes flash { 50% { background: #fff; transform: scale(1.08); } }
@media (max-width: 767.98px) {
  .queue-cols { grid-template-columns: 1fr; padding: 0 1rem 1rem; }
  .queue-num { font-size: 2rem; }
  .queue-col.ready .queue-num { font-size: 2.6rem; }
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 20%, #8B5E3C 0, transparent 45%), radial-gradient(circle at 80% 80%, #C8A27A 0, transparent 40%), var(--brand-dark); }
.login-card { width: 100%; max-width: 410px; border-radius: 22px; }
.pin-display { font-size: 2rem; letter-spacing: .6rem; text-align: center; height: 3rem; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.pin-pad button { height: 60px; font-size: 1.4rem; border-radius: 14px; }

/* ---------- Heatmap ---------- */
.heatmap { border-collapse: separate; border-spacing: 3px; font-size: .75rem; width: 100%; }
.heatmap td, .heatmap th { text-align: center; padding: .35rem .1rem; border-radius: 4px; font-weight: 400; }
.heatmap th { color: var(--muted); }

/* ---------- Misc ---------- */
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.6rem; opacity: .4; display: block; margin-bottom: .5rem; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; }
.cursor-pointer { cursor: pointer; }
.img-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; }
.icon-thumb { width: 42px; height: 42px; border-radius: 8px; display: inline-grid; place-items: center; color: #fff; font-size: 1.2rem; }
