/* =====================================================================
   Rental System - app styles
   Built for a shop counter: large touch targets, high contrast,
   readable on a phone in daylight, and clean on paper.
   ===================================================================== */

:root {
  --ink:        #0f172a;
  --ink-soft:   #475569;
  --line:       #e2e8f0;
  --surface:    #ffffff;
  --canvas:     #f1f5f9;
  --brand:      #1d4ed8;
  --brand-dark: #1e3a8a;
  --ok:         #15803d;
  --warn:       #b45309;
  --bad:        #b91c1c;
  --radius:     .65rem;
}

body {
  background: var(--canvas);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  padding-bottom: 2rem;
}

/* ---------- Navigation ---------- */
.app-nav {
  background: linear-gradient(180deg, #0f172a, #172554);
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 4px 16px rgba(15,23,42,.18);
}
.app-nav .navbar-brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; }
.app-nav .brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: .95rem; font-weight: 800;
}
.app-nav .brand-logo {
  width: 30px; height: 30px; border-radius: 7px; object-fit: contain;
  background: #fff; padding: 2px; flex: 0 0 auto;
}
.app-nav .brand-text { font-size: 1rem; letter-spacing: -.01em; }

/* Logo on a printed bill or the login card */
.doc-logo { max-height: 64px; max-width: 190px; object-fit: contain; }
.login-logo { max-height: 72px; max-width: 200px; object-fit: contain; }
@media print { .doc-logo { max-height: 56px; } }
.app-nav .nav-link { color: rgba(255,255,255,.78); font-weight: 500; padding: .5rem .8rem; border-radius: .45rem; }
.app-nav .nav-link:hover,
.app-nav .nav-link:focus { color: #fff; background: rgba(255,255,255,.08); }
.app-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.16); }
.app-nav .nav-link.nav-accent { color: #bef264; }
.app-nav .nav-link.nav-accent.active { background: rgba(190,242,100,.18); color: #ecfccb; }
.app-nav .navbar-toggler { border-color: rgba(255,255,255,.3); }
.app-nav .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.85)' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
@media (max-width: 991.98px) {
  .app-nav .nav-user { padding-top: .75rem; border-top: 1px solid rgba(255,255,255,.12); }
}
/* The name and role of whoever is signed in were being drawn in the page's
   own near-black text colour on top of the dark blue bar, which made them
   all but invisible. They are the one thing on the bar that says whose
   till this is, so they have to be readable.                            */
.app-nav .nav-user     { color: #fff; }
.app-nav .nav-user div { white-space: nowrap; }
/* On a small laptop the menu already needs two rows; the role underneath
   the name would push it to three, so there only the name is kept. */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .app-nav .nav-user .opacity-75 { display: none; }
}

/* The menu has fifteen sections in it now, which is more than fits across
   a laptop screen - the last few were sitting off the right edge
   with no way to reach them. Between the width the menu opens out at and
   the width it actually fits at, the links are set tighter and allowed to
   run onto a second line rather than off the screen.                    */
@media (min-width: 992px) and (max-width: 1699.98px) {
  .app-nav .navbar-nav { flex-wrap: wrap; }
  .app-nav .nav-link   { padding: .4rem .55rem; font-size: .93rem; }
  .app-nav .brand-text { font-size: .92rem; }
}

/* ---------- Cards, tables, forms ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #f8fafc; border-bottom: 1px solid var(--line); font-weight: 600; }

.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .6rem .7rem; vertical-align: middle; }
.table thead th {
  background: #f8fafc; color: var(--ink-soft);
  font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
.table-hover tbody tr:hover { background: #f8fafc; }

.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-soft); margin-bottom: .25rem; }
.form-control, .form-select { border-color: #cbd5e1; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(29,78,216,.15); }
/* Stop iOS zooming in when a field is tapped */
@media (max-width: 767.98px) { .form-control, .form-select { font-size: 16px; } }

.btn { border-radius: .5rem; font-weight: 600; }
.btn-lg { padding: .7rem 1.1rem; }

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; height: 100%;
  border-left: 4px solid var(--brand);
}
.stat .stat-value { font-size: 1.65rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.stat .stat-label { font-size: .8rem; color: var(--ink-soft); font-weight: 600; margin-top: .15rem; }
.stat .stat-note  { font-size: .75rem; color: var(--ink-soft); opacity: .85; margin-top: .3rem; }
.stat.is-ok   { border-left-color: var(--ok); }
.stat.is-ok   .stat-value { color: var(--ok); }
.stat.is-warn { border-left-color: var(--warn); }
.stat.is-warn .stat-value { color: var(--warn); }
.stat.is-bad  { border-left-color: var(--bad); }
.stat.is-bad  .stat-value { color: var(--bad); }

/* On a phone three tiles share 390px, so a figure like 1,25,000 at this
   size is wider than its own box and drags the whole page sideways -
   the buttons then sit off the right edge and cannot be reached. Smaller
   type and tighter padding keep the row inside the screen, and the
   break-word is a last resort for a figure in lakhs.                   */
@media (max-width: 575.98px) {
  .stat { padding: .6rem .65rem; border-left-width: 3px; }
  .stat .stat-value { font-size: 1.05rem; overflow-wrap: anywhere; }
  .stat .stat-label { font-size: .7rem; }
  .stat .stat-note  { font-size: .68rem; }
}

/* ---------- Where money is entered ----------
   The one box on a screen that takes cash off a customer sat in a row of
   grey read-only totals that looked exactly like it. Giving it a colour
   of its own lets a staff member at the counter find it without reading
   the labels, and the same colour means the same thing on every screen:
   this is the box money goes into.                                    */
.money-box {
  background: #fffbeb;                    /* warm, unlike every other field */
  border: 2px solid #f59e0b;
  border-radius: var(--radius);
  padding: .5rem .6rem .6rem;
}
.money-box > .form-label {
  font-weight: 700; color: #92400e; margin-bottom: .25rem;
}
.money-box .form-control,
.money-box .form-select {
  border: 1px solid #f59e0b; background: #fff; font-weight: 700;
}
.money-box .form-control:focus,
.money-box .form-select:focus {
  border-color: #b45309; box-shadow: 0 0 0 .2rem rgba(245, 158, 11, .25);
}
.money-box input[type="number"] { font-size: 1.05rem; }
/* Money going the other way - a refund - is not the same action, and
   must not be reached for out of habit. */
.money-box.is-out { background: #fef2f2; border-color: var(--bad); }
.money-box.is-out > .form-label { color: #7f1d1d; }
.money-box.is-out .form-control,
.money-box.is-out .form-select { border-color: var(--bad); }
.money-box.is-out .form-control:focus,
.money-box.is-out .form-select:focus {
  border-color: #7f1d1d; box-shadow: 0 0 0 .2rem rgba(185, 28, 28, .2);
}
@media print { .money-box { border: 1px solid #999; background: #fff; } }

/* ---------- Searchable dropdown ----------
   A box you can type in, over a real <select> that is still what the
   form posts. The list sits above everything else so it is not clipped
   by a modal or a table cell.                                       */
.ss-wrap { position: relative; }
.ss-hidden { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.ss-box { cursor: text; }
.ss-box:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(29,78,216,.15); }
.ss-list {
  position: absolute; z-index: 1080; left: 0; right: 0; top: 100%;
  max-height: 15rem; overflow-y: auto; background: #fff;
  border: 1px solid #cbd5e1; border-radius: var(--radius);
  box-shadow: 0 .6rem 1.4rem rgba(15,23,42,.16); margin-top: .15rem;
}
.ss-opt {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: .45rem .7rem; font-size: .9rem; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.ss-opt:last-child { border-bottom: 0; }
.ss-opt:hover, .ss-opt.is-on { background: #eff6ff; color: var(--brand-dark); }
.ss-none { padding: .6rem .7rem; font-size: .88rem; color: var(--ink-soft); }
@media print { .ss-list { display: none !important; } }

/* ---------- Thumbnails ---------- */
.thumb {
  width: 46px; height: 46px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; background: #fff;
}
.thumb-lg { width: 64px; height: 64px; }
.thumb:hover { border-color: var(--brand); }

/* ---------- Scanner ---------- */
.scan-box {
  background: var(--surface); border: 2px dashed #94a3b8;
  border-radius: var(--radius); padding: 1rem;
}
.scan-box.is-live { border-color: var(--ok); border-style: solid; }
#scanInput, .scan-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.25rem; letter-spacing: .06em; text-transform: uppercase;
}
#qrReader { width: 100%; max-width: 420px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; }
#qrReader video { width: 100% !important; border-radius: var(--radius); }

/* Result panel after a scan */
.scan-result { border-left: 5px solid var(--line); }
.scan-result.ok      { border-left-color: var(--ok); }
.scan-result.blocked { border-left-color: var(--bad); }
.scan-result.warn    { border-left-color: var(--warn); }

/* ---------- Conflict / warning strip on the billing screen ---------- */
.conflict {
  border-radius: .5rem; padding: .55rem .75rem; margin-top: .4rem;
  font-size: .85rem; line-height: 1.35;
  background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d;
}
.conflict.is-warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }

/* ---------- Barcode label sheet ---------- */
.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.label {
  border: 1px dashed #cbd5e1; border-radius: 4px; padding: 6px 4px;
  text-align: center; background: #fff; break-inside: avoid; page-break-inside: avoid;
}
.label .label-name { font-size: 10px; font-weight: 700; line-height: 1.15; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .label-meta { font-size: 9px; color: #475569; margin-bottom: 2px; }
.label .label-price { font-size: 10px; font-weight: 700; margin-top: 1px; }
.label svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* ---------- Footer ---------- */
.app-footer {
  margin-top: 2.5rem; padding: 1rem 0;
  border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--ink-soft);
}

/* ---------- Utility ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.text-money { font-variant-numeric: tabular-nums; font-weight: 700; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5;
  background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); padding: .75rem; margin: 1rem -.75rem -.75rem;
  border-radius: 0 0 var(--radius) var(--radius);
}
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }
.empty-state .icon { font-size: 2.2rem; opacity: .5; display: block; margin-bottom: .5rem; }

/* =====================================================================
   PRINT  -  A4 documents and 58/80mm thermal receipts
   ===================================================================== */
@media print {
  .app-nav, .app-footer, .no-print, .navbar, .btn, .alert-dismissible .btn-close { display: none !important; }

  /*
   * Anything that takes input belongs on a screen, never on paper. The
   * search boxes and the sort dropdowns were coming out on the printed
   * report because only buttons had been hidden - this covers the rest
   * of them, including the labels that sit above them.
   *
   * A page that genuinely needs a box on paper (a form to fill in by
   * hand) opts back in with .print-field.
   */
  input:not(.print-field),
  select:not(.print-field),
  textarea:not(.print-field),
  .input-group:not(.print-field),
  .form-check,
  .btn-group, .btn-check + .btn,
  .dropdown-menu, .pagination, .nav-tabs, .breadcrumb,
  .filter-bar, .no-print-form { display: none !important; }
  form.card-body:not(.print-keep), form.card:not(.print-keep) { display: none !important; }
  label.form-label:not(.print-field) { display: none !important; }

  body { background: #fff !important; padding: 0; color: #000; }
  main.container-xl { max-width: none !important; padding: 0 !important; }
  .card { border: none !important; box-shadow: none !important; margin-bottom: 4mm !important; }
  .card-header {
    background: #fff !important; border-bottom: 1px solid #334155 !important;
    font-size: 10.5pt; font-weight: 700; padding: 0 0 1mm !important;
  }
  .card-body  { padding: 0 !important; }
  .card-footer { background: #fff !important; border: 0 !important; padding: 1mm 0 0 !important;
                 font-size: 7.5pt; color: #475569; }
  .table thead th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a[href]:after { content: ""; }
  a { color: #000 !important; text-decoration: none !important; }
  .print-only { display: block !important; }
  .label-sheet { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px; }
  .label { border-style: solid; border-color: #ddd; }

  /* ---- a table that runs over the page break ----
     The column headings are repeated on each sheet, no row is ever cut
     in half, and a heading never sits alone at the foot of a page. */
  table { break-inside: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-row-group; }
  tr    { break-inside: avoid; break-after: auto; }
  h1, h2, h3, h4, h5, .card-header { break-after: avoid; }
  .card { break-inside: auto; }

  /* Screen chrome that means nothing in ink. An alert is guidance for
     somebody looking at the screen - "open a product and press + Add
     pieces" is not something a printed report should be telling anyone.
     A page with a notice that genuinely belongs on paper marks it
     .print-keep. */
  .thumb, .doc-logo-screen, .stat-note,
  .alert:not(.print-keep), .empty-state, .page-head { display: none !important; }
  .badge {
    border: 1px solid #94a3b8 !important; background: #fff !important; color: #000 !important;
    font-weight: 600; padding: .5mm 1mm;
  }
  .table > :not(caption) > * > * { padding: 1.1mm 1.6mm !important; }
  .table { font-size: 8pt; }
  .table thead th { font-size: 7pt; letter-spacing: .02em; }
}
.print-only { display: none; }

/* =====================================================================
   THE PRINTED REPORT

   Every report leaves the shop looking the same: the shop's own details
   at the top, what the report is and the period it covers, then the
   figures. Before this each page printed whatever the screen showed,
   which meant no letterhead, no margins, and the search box on the
   paper.
   ===================================================================== */
.rpt-head { margin-bottom: 5mm; }
.rpt-shop-name { font-size: 15pt; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.rpt-shop-line { font-size: 8pt; color: #334155; line-height: 1.45; }
.rpt-title-row {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm;
  border-top: .6mm solid #0f172a; margin-top: 2mm; padding-top: 2.5mm;
}
.rpt-title  { font-size: 12pt; font-weight: 700; line-height: 1.2; }
.rpt-period { font-size: 8.5pt; color: #334155; margin-top: .6mm; }
.rpt-note   { font-size: 7.5pt; color: #64748b; margin-top: .6mm; }
.rpt-meta   { font-size: 7.5pt; color: #64748b; text-align: right; white-space: nowrap; }

/* Thermal receipt: the page itself is the paper width */
.receipt {
  width: 100%; max-width: 302px;     /* 80mm at 96dpi ~ 302px; 58mm sheet overrides below */
  margin: 0 auto; background: #fff; color: #000;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 12px; line-height: 1.35;
}
.receipt.w58 { max-width: 216px; font-size: 11px; }
/*
 * The shop name is the heading of the slip, so it has to carry weight.
 * It never set one, which left Bootstrap's h1 rule (font-weight 500)
 * applying - it only LOOKED bold while the "RENT RECEIPT" line sat under
 * it, and when that went the whole header read as thin.
 */
.receipt h1 { font-size: 15px; font-weight: 700; margin: 0 0 2px; text-align: center;
              letter-spacing: .3px; }
.receipt h2 { font-size: 14px; font-weight: 700; margin: 0 0 2px; text-align: center; }
.receipt .rc-sub { text-align: center; font-size: 10px; margin-bottom: 4px; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 5px 0; }
.receipt table { width: 100%; border-collapse: collapse; font-size: 11px; }
.receipt td, .receipt th { padding: 1px 0; vertical-align: top; }
.receipt .r { text-align: right; }
.receipt .c { text-align: center; }
.receipt .big { font-size: 13px; font-weight: 700; }

@media print {
  /*
   * A4 with real margins, for every page that does not say otherwise.
   * This used to be 4mm for everything, which suited the thermal roll
   * and nothing else - it is why reports printed with their figures
   * running into the edge of the sheet.
   *
   * The receipt and label pages each declare their own @page in their
   * own <style> block, which comes after this file and so still wins
   * for the paper they were written for.
   */
  @page { size: A4; margin: 14mm 12mm 15mm; }
  .receipt { max-width: none; width: auto; }
}

/* =====================================================================
   PLACEHOLDER TEXT

   The grey a placeholder gets by default is dark enough to be mistaken
   for a value that is already in the box - people were reading "1294"
   in an empty field and believing the number was saved. Lighter, and
   italic, so the eye can tell an example from an entry at a glance.
   ===================================================================== */
.form-control::placeholder,
.form-select::placeholder {
  color: #aab2bd !important;
  opacity: 1;              /* Firefox dims placeholders again without this */
  font-style: italic;
  font-weight: 400;
}
/* A barcode box is monospaced and bold; its placeholder should not be. */
.form-control.mono::placeholder {
  font-family: inherit;
  letter-spacing: normal;
}
