/* Hari Villa — v0.11.0 global quick-add: the + and the entry sheet.
 * Own file, linked from base.html. style.css / topbar.css untouched.
 * Tokens only: --navy --gold --paper --ink --muted --line --green --red.
 *
 * Built for one-handed phone entry. The + sits on the search row (the
 * lowest, most thumb-reachable strip of chrome, not the top corner), and
 * the sheet is a bottom sheet on a phone — it rises into the thumb, not
 * away from it.
 */

/* ---------- the + trigger, beside search ----------
   .hv-search-wrap has carried `flex: 1 1 100%; order: 3` since v0.8.0,
   meant to drop the search onto its own full-width row on a phone — but
   `.topline` was never given `flex-wrap`, so that 100% basis had nothing to
   wrap against and the search (and now the +) rode off the right edge at
   320px, unreachable. Wrapping the topline is what makes that basis mean
   what it always intended: heading + tools on the first row, the search +
   add control on a full-width row beneath, in the thumb's reach. */
.topline { flex-wrap: wrap; }
.hv-search-row { display: flex; align-items: stretch; gap: 0.5rem; }
.hv-search-row #hv-search { flex: 1 1 auto; width: auto; min-width: 0; }

.hv-quickadd-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;              /* touch target floor — never smaller on phone */
  min-height: 44px;
  padding: 0;
  background: var(--navy);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.hv-quickadd-btn:hover { background: #16305a; }
.hv-quickadd-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hv-qa-plus {
  width: 22px; height: 22px;
  fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round;
}

/* ---------- the sheet ---------- */
.hv-quickadd { position: fixed; inset: 0; z-index: 200; }
.hv-quickadd[hidden] { display: none; }
.hv-qa-backdrop { position: absolute; inset: 0; background: rgba(15, 36, 64, 0.45); }

.hv-qa-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;          /* bottom sheet on phone */
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-top: 3px solid var(--gold);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -12px 32px rgba(15, 36, 64, 0.22);
}

.hv-qa-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  color: var(--navy);
}
.hv-qa-close {
  width: 40px; height: 40px;
  background: none; border: 0; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--muted);
  border-radius: 4px;
}
.hv-qa-close:hover { background: #EEF2F7; color: var(--navy); }

.hv-qa-body { padding: 0.85rem 1rem 1.1rem; overflow-y: auto; }
.hv-qa-loading, .hv-qa-empty, .hv-qa-error {
  margin: 0.4rem 0; font-size: 0.9rem; color: var(--muted);
}
.hv-qa-error { color: var(--red); }

/* ---------- inputs & rows ---------- */
.hv-qa-input {
  width: 100%;
  min-height: 44px;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  appearance: none;
}
.hv-qa-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.22);
}
.hv-qa-row { margin-top: 0.7rem; }
.hv-qa-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- the type / entity option lists ---------- */
.hv-qa-list { margin-top: 0.5rem; display: flex; flex-direction: column; }
.hv-qa-opt {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-height: 48px;
  padding: 0.5rem 0.6rem;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.hv-qa-opt:hover, .hv-qa-opt:focus-visible {
  background: #fff; border-left-color: var(--gold); outline: none;
}
.hv-qa-opt-name { font-size: 0.95rem; color: var(--ink); }
.hv-qa-opt-sub {
  font-size: 0.74rem; color: var(--muted); text-transform: capitalize;
}
.hv-qa-opt-create .hv-qa-opt-name { color: var(--navy); font-weight: 700; }
.hv-qa-opt-create { background: #FCFAF2; }

/* The last-used type, floated to the top of the picker and pre-highlighted
   with the same gold accent the rows take on hover — so a same-type batch is
   an obvious one-tap (or Enter) without hiding the other types. */
.hv-qa-opt--last { border-left-color: var(--gold); background: #FCFAF2; }
.hv-qa-opt--last .hv-qa-opt-name { font-weight: 700; }

/* ---------- chosen entity chip ---------- */
.hv-qa-chosen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 0.4rem 0 0.75rem;
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 6px;
}
.hv-qa-chosen-name { font-size: 0.95rem; color: var(--ink); }
.hv-qa-chosen-clear {
  width: 36px; height: 36px;
  background: none; border: 0; cursor: pointer;
  font-size: 1.3rem; line-height: 1; color: var(--muted); border-radius: 4px;
}
.hv-qa-chosen-clear:hover { color: var(--red); background: #EEF2F7; }

/* ---------- actions ---------- */
.hv-qa-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.1rem;
}
.hv-qa-primary, .hv-qa-secondary {
  min-height: 48px;
  padding: 0 1.1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
}
.hv-qa-primary {
  flex: 1 1 auto;
  background: var(--navy);
  color: #fff;
  border: 0;
}
.hv-qa-primary:hover { background: #16305a; }
.hv-qa-primary:disabled { opacity: 0.6; cursor: default; }
.hv-qa-secondary {
  flex: 0 0 auto;
  background: none;
  color: var(--muted);
  border: 1px solid var(--line);
}
.hv-qa-secondary:hover { color: var(--navy); border-color: var(--navy); }

.hv-qa-toast {
  margin: 0.6rem 1rem 0;
  padding: 0.6rem 0.75rem;
  background: var(--green);
  color: #fff;
  border-radius: 6px;
  font-size: 0.86rem;
}
.hv-qa-toast[hidden] { display: none; }

/* stop the page scrolling behind an open sheet */
body.hv-qa-open { overflow: hidden; }

/* ---------- desktop: a centered modal instead of a bottom sheet ---------- */
@media (min-width: 900px) {
  .hv-quickadd-btn { width: 40px; min-height: 32px; }
  .hv-qa-sheet {
    left: 50%; right: auto; bottom: auto; top: 12vh;
    transform: translateX(-50%);
    width: min(34rem, calc(100vw - 2rem));
    max-height: 76vh;
    border-radius: 10px;
    border-top: 3px solid var(--gold);
  }
}
