/* ==========================================================================
   The Café Nook POS — app styles (on top of Bootstrap 5.3)
   ========================================================================== */

:root {
  --brand: #7a5230;
  --brand-dark: #5c3d22;
  --brand-soft: #f3e9dd;
  --ink: #2a211b;
  --muted: #7b6f66;
  --bg: #f6f2ed;
  --surface: #ffffff;
  --line: #e8e0d6;
  --sidebar: #2a1f17;
  --sidebar-ink: #d9cbbd;
  --success: #2f7d4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 33, 27, .06), 0 4px 16px rgba(42, 33, 27, .06);

  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--line);
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 122, 82, 48;
  --bs-link-hover-color: var(--brand-dark);
  --bs-primary-rgb: 122, 82, 48;
}

body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }

/* ---- Buttons in brand colours ---- */
.btn { border-radius: 10px; font-weight: 500; }
.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);
  --bs-btn-focus-shadow-rgb: 122, 82, 48;
}
.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-dark); --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-focus-shadow-rgb: 122, 82, 48;
}
.btn-success {
  --bs-btn-bg: var(--success); --bs-btn-border-color: var(--success);
  --bs-btn-hover-bg: #256641; --bs-btn-hover-border-color: #256641;
  --bs-btn-disabled-bg: #9bbfa9; --bs-btn-disabled-border-color: #9bbfa9;
}
.btn-icon { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; padding: .25rem .5rem; color: var(--ink); }
.form-control, .form-select { border-radius: 10px; border-color: var(--line); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #b48a63; box-shadow: 0 0 0 .2rem rgba(122, 82, 48, .15);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.text-muted { color: var(--muted) !important; }
.min-w-0 { min-width: 0; }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  /* !important: Bootstrap makes .offcanvas-lg transparent on large screens */
  background: var(--sidebar) !important; color: var(--sidebar-ink);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .sidebar { width: 236px; flex: 0 0 236px; position: sticky; top: 0; height: 100vh; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--sidebar); }
}
.sidebar-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.25rem 1.1rem; color: #fff;
  font-family: 'Playfair Display', Georgia, serif; font-size: 1.15rem;
}
.sidebar-brand img { object-fit: contain; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: .5rem .75rem; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .85rem; border-radius: 10px;
  color: var(--sidebar-ink); text-decoration: none; font-weight: 500;
}
.sidebar-nav a i { font-size: 1.15rem; opacity: .85; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-nav a.active i { color: #e7b98a; opacity: 1; }
.sidebar-user {
  display: flex; align-items: center; gap: .65rem;
  padding: 1rem; border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
  display: grid; place-items: center; background: #e7b98a; color: var(--sidebar); font-weight: 700;
}
.sidebar-user .name { color: #fff; font-weight: 600; font-size: .9rem; }
.sidebar-user .role { font-size: .75rem; text-transform: capitalize; }
.sidebar-user .logout { margin-left: auto; color: var(--sidebar-ink); font-size: 1.25rem; }
.sidebar-user .logout:hover { color: #ff9b8a; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.content { padding: 1.5rem; flex: 1; }
.flash-stack { padding: 0 1.5rem; }
.flash-stack .alert { margin: 1rem 0 0; border-radius: 12px; }
@media (max-width: 575.98px) {
  .topbar { padding: .75rem 1rem; }
  .content { padding: 1rem; }
  .flash-stack { padding: 0 1rem; }
}

/* ---- Cards, tables, badges ---- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-header {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.panel-header h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.panel-body { padding: 1.25rem; }

.stat { padding: 1.1rem 1.25rem; }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .85rem; }

.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .75rem 1rem; border-color: var(--line); }
.table thead th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; background: #faf7f3; white-space: nowrap;
}
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #faf6f1; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-link { cursor: pointer; }

.badge-soft { font-weight: 600; padding: .35em .65em; border-radius: 999px; font-size: .75rem; }
.badge-paid { background: #e3f2e8; color: #22603b; }
.badge-void { background: #fde5e2; color: #a5352a; }
.badge-off  { background: #eee9e3; color: #6d625a; }
.badge-cash { background: #f3e9dd; color: #6b4524; }
.badge-card { background: #e4ecf7; color: #2b4f80; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }

.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--brand-soft); }
.thumb-placeholder { display: grid; place-items: center; color: #b99a7c; font-size: 1.25rem; }

/* ==========================================================================
   POS screen
   ========================================================================== */
.pos .content { padding: 0; display: flex; min-height: 0; }
.pos-layout { display: flex; flex: 1; min-width: 0; min-height: calc(100vh - 61px); }

.pos-menu { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 6rem; }
.pos-search { position: relative; max-width: 520px; }
.pos-search i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pos-search input { padding-left: 2.5rem; height: 46px; background: var(--surface); }
.pos-search kbd {
  position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); font-size: .7rem;
}

.cat-chips { display: flex; gap: .5rem; overflow-x: auto; padding: 1rem 0 .75rem; scrollbar-width: thin; }
.cat-chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .5rem .95rem; border-radius: 999px; font-weight: 500; font-size: .9rem; white-space: nowrap;
}
.cat-chip:hover { border-color: #c9ad91; }
.cat-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.cat-chip .count { opacity: .65; margin-left: .25rem; font-size: .8rem; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.item-tile {
  position: relative; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius); padding: .85rem .9rem; min-height: 96px;
  display: flex; flex-direction: column; gap: .35rem;
  box-shadow: 0 1px 2px rgba(42,33,27,.04);
  transition: transform .08s ease, border-color .15s ease, box-shadow .15s ease;
}
.item-tile:hover { border-color: #c9ad91; box-shadow: var(--shadow); }
.item-tile:active { transform: scale(.97); }
.item-tile.in-cart { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.item-tile img { width: 100%; height: 90px; object-fit: cover; border-radius: 10px; margin-bottom: .25rem; }
.item-tile .name { font-weight: 600; font-size: .92rem; line-height: 1.25; color: var(--ink); }
.item-tile .price { margin-top: auto; color: var(--brand); font-weight: 700; font-variant-numeric: tabular-nums; }
.item-tile .qty-badge {
  position: absolute; top: -8px; right: -8px; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 13px; background: var(--brand); color: #fff; font-size: .8rem; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.item-tile.pop { animation: pop .25s ease; }
@keyframes pop { 50% { transform: scale(1.04); } }
.cat-heading { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 1.25rem 0 .6rem; }
.cat-heading:first-child { margin-top: .25rem; }

/* Cart panel */
.pos-cart {
  display: flex; flex-direction: column; background: var(--surface) !important; border-left: 1px solid var(--line);
}
@media (min-width: 992px) {
  .pos-cart { width: 400px; flex: 0 0 400px; position: sticky; top: 61px; height: calc(100vh - 61px); }
}
@media (max-width: 991.98px) {
  .pos-cart.offcanvas-lg { --bs-offcanvas-width: 100%; }
}
.cart-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.cart-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.cart-lines { flex: 1; overflow-y: auto; padding: .25rem 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; padding: .7rem 1.25rem; border-bottom: 1px dashed var(--line); }
.cart-line .name { font-weight: 600; font-size: .92rem; }
.cart-line .unit { color: var(--muted); font-size: .8rem; }
.cart-line .line-total { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.stepper { justify-self: start; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--bg); font-size: 1.1rem; color: var(--ink); }
.stepper button:hover { background: var(--brand-soft); }
.stepper input { width: 44px; height: 34px; border: 0; text-align: center; font-weight: 600; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cart-line .remove { border: 0; background: none; color: #b0a399; padding: 0 .25rem; }
.cart-line .remove:hover { color: #c0392b; }
.cart-empty { text-align: center; color: var(--muted); padding: 3rem 1.5rem; }
.cart-empty i { font-size: 2.75rem; opacity: .4; display: block; margin-bottom: .5rem; }

.cart-foot { border-top: 1px solid var(--line); padding: 1rem 1.25rem 1.25rem; background: #fcfaf8; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; font-size: .9rem; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: .3rem .5rem; border-radius: 8px; font-size: .85rem; font-weight: 500; color: var(--ink); }
.seg button.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--brand); font-weight: 700; }
.seg-lg { display: flex; width: 100%; }
.seg-lg button { flex: 1; padding: .55rem; font-size: .95rem; }
.totals { margin: .75rem 0; font-variant-numeric: tabular-nums; }
.totals .row-t { display: flex; justify-content: space-between; font-size: .92rem; padding: .15rem 0; }
.totals .row-t.discount { color: #b03a2e; }
.totals .grand { font-size: 1.35rem; font-weight: 800; border-top: 1px solid var(--line); margin-top: .4rem; padding-top: .5rem; }
.cash-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem; margin-top: .6rem; }
.quick-cash { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.quick-cash button { flex: 1 0 auto; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: .3rem .5rem; font-size: .82rem; font-weight: 600; }
.quick-cash button:hover { border-color: var(--brand); color: var(--brand); }
.change-due { display: flex; justify-content: space-between; margin-top: .6rem; font-weight: 700; }
.change-due.short { color: #b03a2e; }
.change-due.ok { color: var(--success); }
.cart-actions { display: grid; grid-template-columns: auto 1fr; gap: .5rem; margin-top: .85rem; }
.btn-charge { padding: .85rem 1rem; font-size: 1.1rem; font-weight: 700; }

/* Mobile "view cart" bar */
.cart-fab {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 1030;
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.25rem; border-radius: 14px; border: 0;
  background: var(--brand); color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.cart-fab .pill { background: rgba(255,255,255,.2); border-radius: 999px; padding: .1rem .6rem; margin-right: .5rem; }

/* Success modal */
.done-icon { width: 64px; height: 64px; border-radius: 50%; background: #e3f2e8; color: var(--success); display: grid; place-items: center; font-size: 2rem; margin: 0 auto .75rem; }
.modal-content { border-radius: 18px; border: 0; }

/* ==========================================================================
   Login
   ========================================================================== */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 10% 0%, #efe1cf 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 100%, #e6d3bd 0%, transparent 60%), var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 2.25rem; }
.auth-card .logo { width: 72px; height: 72px; object-fit: contain; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.auth-card h1 { font-family: 'Playfair Display', Georgia, serif; font-size: 1.75rem; color: var(--brand-dark); }
.auth-card .form-control { height: 48px; }
.auth-card .btn { height: 48px; font-weight: 600; }

/* Daily sales bars on the reports page */
.bar-cell { min-width: 140px; }
.bar { height: 8px; border-radius: 4px; background: var(--brand-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* Hidden frame used to print receipts without popups */
#printFrame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; visibility: hidden; }
