/* DineFlow on top of Tabler (docs/12-Frontend-UI-UX.md §3), in the BeUNIQ POS visual language:
   Aubergine #282239 (sidebar, brand panels), Action purple #5C477C (primary actions), Warm gold #E9BF79 (current
   place, highlights) and Soft white #F7F7F5. Loaded after tabler.min.css. */
:root {
  --df-aubergine: #282239;
  --df-aubergine-raised: #352d4c;
  --df-purple: #5C477C;
  --df-purple-dark: #4a3866;
  --df-gold: #E9BF79;
  --df-soft: #F7F7F5;
  --df-page: #F4F2EE;
  --df-line: #E6E1EA;
  --df-on-dark: #EDE8F5;
  --df-on-dark-muted: #A99DC2;

  --tblr-primary: #5C477C;
  --tblr-primary-rgb: 92, 71, 124;
  --tblr-primary-fg: #fff;
  --tblr-primary-darken: #4a3866;
  --tblr-primary-lt: rgba(92, 71, 124, .1);
  --tblr-body-bg: var(--df-page);
  --df-touch: 48px;
}
:root:not([data-bs-theme="dark"]) body { background: var(--df-page); }

/* Dark mode: a lighter purple with dark text on it, so buttons keep strong contrast. */
[data-bs-theme="dark"] {
  --tblr-primary: #A58BD4;
  --tblr-primary-rgb: 165, 139, 212;
  --tblr-primary-fg: #1B1626;
  --tblr-primary-darken: #8F74C2;
  --tblr-primary-lt: rgba(165, 139, 212, .14);
  --tblr-body-bg: #17131F;
  --tblr-bg-surface: #201A2C;
  --tblr-bg-surface-secondary: #2A2338;
  --tblr-border-color: #352D45;
  --df-line: #352D45;
}

.btn-primary { --tblr-btn-hover-bg: var(--tblr-primary-darken); --tblr-btn-active-bg: var(--tblr-primary-darken); --tblr-btn-color: var(--tblr-primary-fg); }

/* Touch targets on floor screens */
.df-touch .btn, .df-touch .list-group-item { min-height: var(--df-touch); }

/* ---------- Table floor ---------- */
.df-table-card { cursor: pointer; transition: transform .08s ease; border-width: 2px; min-height: 120px; }
.df-table-card:hover { transform: translateY(-2px); }
.df-table-card:focus-visible { outline: 3px solid var(--tblr-primary); outline-offset: 2px; }
.df-table-available { border-color: var(--tblr-success); }
.df-table-occupied { border-color: var(--tblr-warning); background: rgba(var(--tblr-warning-rgb), .08); }
.df-table-billrequested { border-color: var(--tblr-info); background: rgba(var(--tblr-info-rgb), .08); }
.df-table-reserved { border-color: var(--tblr-secondary); }

/* ---------- POS ---------- */
.df-pos { display: grid; grid-template-columns: 200px 1fr 380px; gap: 1rem; height: calc(100vh - 140px); min-height: 520px; }
.df-pos > * { min-height: 0; min-width: 0; } /* grid columns may shrink below their content (chip row, long names) */
.df-pos-scroll { overflow-y: auto; overflow-x: hidden; } /* row gutters must not add a sideways scrollbar */
.df-item-card { cursor: pointer; user-select: none; min-height: 92px; }
.df-item-card:active { transform: scale(.98); }
.df-item-card.df-unavailable { opacity: .45; cursor: not-allowed; }
.df-item-photo { width: 100%; height: 84px; object-fit: cover; border-top-left-radius: inherit; border-top-right-radius: inherit; background: var(--tblr-bg-surface-secondary); }
.df-thumb { width: 44px; height: 44px; border-radius: var(--tblr-border-radius); object-fit: cover; flex-shrink: 0; background: var(--tblr-bg-surface-secondary); }
.df-thumb-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--tblr-secondary); }
.df-photo-preview { width: 96px; height: 96px; border-radius: var(--tblr-border-radius); object-fit: cover; flex-shrink: 0; background: var(--tblr-bg-surface-secondary); }
.df-veg-dot { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--tblr-success); position: relative; vertical-align: middle; }
.df-veg-dot::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: var(--tblr-success); }
.df-veg-dot.df-nonveg { border-color: var(--tblr-danger); }
.df-veg-dot.df-nonveg::after { background: var(--tblr-danger); }
.df-receipt-preview { font-family: ui-monospace, "Courier New", monospace; font-size: .8rem; line-height: 1.35; max-width: 300px; margin: 0 auto; padding: .75rem; border: 1px dashed var(--tblr-border-color); background: var(--tblr-bg-surface); overflow-wrap: anywhere; }
.df-receipt-preview-rule { border-top: 1px dashed var(--tblr-border-color); margin: .5rem 0; }
/* Simple bar charts (reports): bars grow from the bottom of a fixed-height row. */
.df-bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; }
.df-bar-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
.df-bar { border-radius: 3px 3px 0 0; min-height: 0; }
.df-bar-label { font-size: .65rem; text-align: center; color: var(--tblr-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; }
.df-att-grid td, .df-att-grid th { padding: .25rem .3rem; font-size: .75rem; min-width: 1.6rem; }
.df-access-grid td:first-child { min-width: 220px; }
.df-access-grid .form-check-input { width: 1.25rem; height: 1.25rem; cursor: pointer; }
.df-otp { letter-spacing: .6em; font-size: 1.75rem; font-variant-numeric: tabular-nums; }
.df-grand-total { font-size: 1.75rem; font-weight: 700; }
@media (max-width: 991.98px) {
  .df-pos { grid-template-columns: 1fr; height: auto; }
}

/* ---------- PIN pad ---------- */
.df-pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 280px; margin: 0 auto; }
.df-pinpad .btn { height: 64px; font-size: 1.5rem; }
.df-pin-dots { display: flex; gap: .75rem; justify-content: center; margin: 1rem 0; }
.df-pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tblr-primary); }
.df-pin-dots span.filled { background: var(--tblr-primary); }

/* ---------- Kitchen display ---------- */
.df-kds { font-size: 1.05rem; }
.df-kds-col { min-height: 70vh; }
.df-kot-card .df-kot-item { font-size: 1.25rem; padding: .5rem .75rem; cursor: pointer; }
.df-kot-card .card-header { cursor: pointer; }
.df-kot-late { border-color: var(--tblr-warning) !important; border-width: 2px; }
.df-kot-overdue { border-color: var(--tblr-danger) !important; border-width: 2px; animation: df-pulse 1.5s infinite; }
.df-kot-new { animation: df-flash 3s ease-out; }
.df-kot-note { color: var(--tblr-warning); font-style: italic; font-size: 1rem; }
@keyframes df-pulse { 50% { box-shadow: 0 0 0 4px rgba(var(--tblr-danger-rgb), .35); } }
@keyframes df-flash { from { box-shadow: 0 0 0 6px rgba(var(--tblr-primary-rgb), .6); } to { box-shadow: none; } }

/* ---------- Toasts ---------- */
.df-toast-host { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; width: 340px; max-width: calc(100vw - 2rem); }
@media (max-width: 575.98px) { .df-toast-host { top: auto; bottom: 1rem; } }

/* ---------- Receipt (thermal 80 mm) ---------- */
#df-receipt { display: none; }
@media print {
  @page { size: 80mm auto; margin: 0; }
  body * { visibility: hidden; }
  #df-receipt, #df-receipt * { visibility: visible; }
  #df-receipt { display: block; position: absolute; left: 0; top: 0; width: 72mm; padding: 4mm; font: 12px/1.35 monospace; color: #000; }
  #df-receipt table { width: 100%; border-collapse: collapse; }
  #df-receipt td { padding: 1px 0; }
  #df-receipt .r { text-align: right; }
  #df-receipt hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }
  /* Restaurant logo: small and in greyscale on the 80 mm slip, larger on A4. */
  #df-receipt .df-receipt-logo { display: inline-block; max-width: 48mm; max-height: 18mm; margin-bottom: 2mm; object-fit: contain; filter: grayscale(1); }
  #df-receipt .df-a4-logo { display: block; max-width: 60mm; max-height: 22mm; margin-bottom: 3mm; filter: none; }
  /* Split billing prints the food and bar invoices as separate slips. */
  #df-receipt .df-receipt-part + .df-receipt-part { break-before: page; padding-top: 4mm; }

  /* A4 invoice (Restaurant profile → Receipt → A4). DfReceipt sets the A4 page size. */
  #df-receipt.df-a4 { width: 100%; padding: 0; font: 10.5pt/1.45 "Segoe UI", Arial, sans-serif; }
  #df-receipt.df-a4 .df-receipt-part + .df-receipt-part { padding-top: 0; }
  #df-receipt.df-a4 table { width: 100%; border-collapse: collapse; }
  #df-receipt.df-a4 .c { text-align: center; }
  .df-a4-head { display: flex; justify-content: space-between; gap: 12mm; padding-bottom: 5mm; border-bottom: 2px solid #000; margin-bottom: 6mm; }
  .df-a4-name { font-size: 16pt; font-weight: 700; margin-bottom: 1mm; }
  .df-a4-meta { min-width: 70mm; }
  .df-a4-title { font-size: 14pt; font-weight: 700; letter-spacing: .05em; text-align: right; margin-bottom: 2mm; }
  .df-a4-meta td { padding: .5mm 0; }
  .df-a4-meta td:first-child { color: #444; padding-right: 4mm; }
  .df-a4-lines th { text-align: left; border-bottom: 1px solid #000; padding: 1.5mm 2mm; font-weight: 600; background: #f2f2f2; }
  .df-a4-lines td { padding: 1.5mm 2mm; border-bottom: 1px solid #ddd; vertical-align: top; }
  .df-a4-lines th.r { text-align: right; }
  .df-a4-lines tr { break-inside: avoid; }
  .df-a4-bottom { display: flex; justify-content: space-between; gap: 12mm; margin-top: 6mm; break-inside: avoid; }
  .df-a4-paid { flex: 1; }
  #df-receipt.df-a4 .df-a4-totals { width: 75mm; }
  .df-a4-totals td { padding: 1mm 0; }
  .df-a4-grand td { border-top: 2px solid #000; font-size: 12.5pt; font-weight: 700; padding-top: 2mm; }
  .df-a4-footer { margin-top: 10mm; padding-top: 3mm; border-top: 1px solid #999; text-align: center; }
  .df-a4-note { color: #555; font-size: 9pt; margin-top: 1mm; }

  /* Full-page print (reports): show the page body, hide the app chrome. */
  html.df-print-page body * { visibility: visible; }
  html.df-print-page #df-receipt, html.df-print-page .d-print-none, html.df-print-page .navbar { display: none !important; }
  html.df-print-page .card { break-inside: avoid; }
}
.df-half-btn { min-height: 36px; font-weight: 600; }
.df-bell-count { position: absolute; top: 2px; right: 0; font-size: .65rem; padding: .15rem .35rem; }
.df-bell-menu { width: min(380px, 92vw); padding: 0; right: 0; left: auto; margin-top: .4rem; overflow: hidden; }
.df-bell-menu > .card { border: 0; margin: 0; }
.df-bell-list { max-height: 60vh; overflow-y: auto; }
/* Titles in the body colour, not the link purple, so they read clearly on the unread tint in both themes. */
.df-bell-menu .list-group-item { color: var(--tblr-body-color); border-color: var(--df-line); }
.df-bell-menu .card-header { border-color: var(--df-line); }
/* Unread: a soft purple tint and a dot, with the text in the normal colour (Tabler's bg-primary-lt would force purple text). */
.df-bell-menu .df-unread { background: rgba(var(--tblr-primary-rgb), .08); position: relative; }
.df-bell-menu .df-unread::before { content: ""; position: absolute; left: .45rem; top: 1.15rem; width: 6px; height: 6px; border-radius: 50%; background: var(--tblr-primary); }
.df-kitchen-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }

/* =====================================================================================
   Responsive layer: phones (<576), large phones / small tablets (<768), tablets (<992),
   laptops (992–1399) and desktops. Desktop layout is unchanged; smaller screens get a
   compact top bar, a drawer, a bottom tab bar, and a POS whose cart opens as a panel.
   ===================================================================================== */

/* iPhone notch / home bar */
.df-bottom-nav, .df-cart-bar { padding-bottom: env(safe-area-inset-bottom); }

/* ---- Drawer (tablet & phone menu): the sidebar, sliding in ---- */
.df-drawer { width: min(300px, 86vw); visibility: visible; z-index: 1060; background: var(--df-aubergine); border: 0; }
.offcanvas-backdrop { z-index: 1055; }

/* ---- Bottom tab bar (below 768px) ---- */
.df-bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; background: var(--df-aubergine); box-shadow: 0 -2px 10px rgba(40, 34, 57, .25);
}
.df-bottom-link {
  flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 4px 2px; border: 0; background: none; color: var(--df-on-dark-muted); font-size: .7rem; text-decoration: none;
}
.df-bottom-link:hover { color: #fff; text-decoration: none; }
.df-bottom-link .ti { font-size: 1.35rem; }
.df-bottom-link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-bottom-link.active { color: var(--df-gold); font-weight: 600; }
@media (max-width: 767.98px) {
  /* Room for the tab bar under the last row of content */
  .df-has-bottom-nav .page-wrapper { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .df-has-bottom-nav .df-toast-host { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ---- POS ---- */
.df-chip-row { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.df-chip-row .btn { flex: 0 0 auto; min-height: 40px; }
.df-cart-bar {
  position: fixed; left: .75rem; right: .75rem; bottom: .75rem; z-index: 1025;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  min-height: 52px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
@media (min-width: 992px) and (max-width: 1199.98px) {
  /* Small laptops and landscape tablets: narrower side columns so dishes keep room */
  .df-pos { grid-template-columns: 160px 1fr 320px; }
}
@media (max-width: 991.98px) {
  .df-pos { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .df-pos .df-pos-scroll.flex-fill { overflow: visible; }
  .df-pos { padding-bottom: 72px; } /* the cart bar never covers the last dishes */
  /* The cart becomes a full-screen panel, opened from the cart bar */
  .df-pos-cart { display: none !important; }
  .df-pos-cart.df-cart-open {
    display: flex !important; position: fixed; inset: 0; z-index: 1040; border-radius: 0; margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .df-pos-cart.df-cart-open .df-pos-scroll { flex: 1 1 auto; overflow-y: auto; }
}
@media (max-width: 767.98px) {
  .df-has-bottom-nav .df-cart-bar { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .df-has-bottom-nav .df-pos { padding-bottom: 136px; }
  .df-item-photo { height: 72px; }
  .df-item-card { min-height: 84px; }
}

/* ---- Bell menu: anchored to the screen on phones so it can't spill off the left edge ---- */
@media (max-width: 575.98px) {
  .df-bell-menu { position: fixed !important; top: 56px; left: .5rem; right: .5rem; width: auto; }
}

/* ---- Pages ---- */
@media (max-width: 767.98px) {
  .page-header .page-title { font-size: 1.45rem; }
  .page-header .col-auto { width: 100%; }               /* header buttons drop below the title… */
  .page-header .col-auto > .d-flex { flex-wrap: wrap; } /* …and wrap instead of overflowing */
  .df-bar-label { display: none; }                      /* report charts: bars only on narrow screens */
  .df-table-card { min-height: 100px; }
  .df-grand-total { font-size: 1.5rem; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* ---- Kitchen display: header wraps; columns stack on phones (Bootstrap col-md-4) ---- */
.df-kds > .d-flex { flex-wrap: wrap; row-gap: .25rem; }
@media (max-width: 767.98px) {
  .df-kds { font-size: 1rem; }
  .df-kds-col { min-height: 0; }
  .df-kot-card .df-kot-item { font-size: 1.1rem; }
}

/* ---- Login: three sign-in tabs fit on the narrowest phones (320–375px) ---- */
.card-md .btn-group .btn { white-space: nowrap; }
@media (max-width: 389.98px) {
  .card-md .btn-group .btn { font-size: .8rem; padding-left: .4rem; padding-right: .4rem; }
  .card-md .btn-group .btn .ti { margin-right: .15rem !important; }
}

/* ---- Fixes from the screenshot pass ---- */
/* Blazor focuses each page's heading after navigation (for screen readers); don't draw a box around it. */
h1:focus, h1:focus-visible, [tabindex="-1"]:focus { outline: none; }
/* Top bar: keep button labels on one line. */
.df-topbar .btn { white-space: nowrap; }
/* Drawer: a side panel, not full screen (beats Tabler's own offcanvas width). */
.offcanvas.offcanvas-start.df-drawer { --tblr-offcanvas-width: min(300px, 86vw); width: min(300px, 86vw); }
/* Role access on phones: the Owner column is always ticked, so hide it and narrow the first column; all four roles fit. */
@media (max-width: 575.98px) {
  .df-access-owner { display: none; }
  .df-access-grid td:first-child { min-width: 0; width: 38%; }
  .df-access-grid td:first-child .small { font-size: .7rem; }
  .card:has(> .card-body > .table-responsive > .df-access-grid) > .card-body { padding: .5rem; }
  .df-access-grid th { font-size: .7rem; padding-left: .25rem; padding-right: .25rem; }
  .df-access-grid td { padding-left: .25rem; padding-right: .25rem; }
}
