/* ==========================================================================
   CareMetrix — Asset Allocation
   Follows the same conventions as asset-register.css / asset-master.css:
   rules scoped under `.aalloc`, listing card built from the shared
   card/table/pagination components, inline filter bar, a single
   fixed-position 3-dot row menu, and slide-over drawers + delete-confirm
   modal moved to <body> to escape the page's fade-up animation (see
   asset-allocation.js's mountOverlays()).
   ========================================================================== */

.aalloc {
  --aalloc-pink: #D0479A; --aalloc-pink-soft: #FBEAF4;
}

/* -------------------------------------------------------------- pagepath -- */

.aalloc-pagepath { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* -------------------------------------------------------------- headrow -- */

.aalloc-card { overflow: hidden; }

.aalloc-headrow {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.aalloc-headrow__title h1 { font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.aalloc-headrow__title p { margin-top: 3px; font-size: 12.5px; color: var(--text-2); }

.aalloc-headrow__actions { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; flex: none; }
.aalloc-headrow__actions select {
  height: 38px; padding: 0 14px; border-radius: var(--r-btn);
  border: 1.5px solid var(--border-strong); background: var(--surface);
  font-size: 13px; color: var(--text-2); min-width: 170px;
}

.aalloc-pinkbtn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1.5px solid var(--aalloc-pink); border-radius: var(--r-btn);
  background: var(--surface); color: var(--aalloc-pink);
  font-size: 13px; font-weight: 700;
  transition: all .14s var(--ease);
}
.aalloc-pinkbtn:hover { background: var(--aalloc-pink-soft); }
.aalloc-pinkbtn svg { width: 16px; height: 16px; }
.aalloc-pinkbtn.is-open { background: var(--aalloc-pink-soft); }

/* ---- inline filter bar, same pattern as asset-register.css's .areg-filters ---- */

.aalloc-filters {
  padding: 18px 24px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.aalloc-filters[hidden] { display: none; }
.aalloc-filters__row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.aalloc-filter { display: flex; flex-direction: column; gap: 6px; flex: 1 1 160px; min-width: 0; }
.aalloc-filter__label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.aalloc-filters__actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; margin-left: auto; }

/* ------------------------------------------------------------ searchrow -- */

.aalloc-searchrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.aalloc-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 240px; max-width: 480px; }
.aalloc-search svg { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; }
.aalloc-search input {
  width: 100%; box-sizing: border-box;
  font-size: 13px; padding: 9px 14px 9px 40px;
  border: 1.5px solid var(--form-border); border-radius: var(--r-pill);
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.aalloc-search input:focus { border-color: var(--form-focus); box-shadow: 0 0 0 3px var(--form-focus-ring); }

.aalloc-searchrow__pagination { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.aalloc-searchrow__perpage { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.aalloc-searchrow__perpage select { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; background: var(--surface); color: var(--text); }

/* ----------------------------------------------------------------- table */

.aalloc-sort { margin-left: 5px; font-size: 12px; font-weight: 600; color: #A99FBE; }

.aalloc-card .table-wrap { width: auto; margin: 20px 24px 24px; border: 1px solid var(--commontable2-cell-border); border-radius: 12px; overflow-x: auto; }
.aalloc-card .table-wrap thead tr th:first-child { border-top-left-radius: 11px; }
.aalloc-card .table-wrap thead tr th:last-child { border-top-right-radius: 11px; }

.aalloc-table tbody tr { cursor: pointer; transition: background .12s var(--ease); }
.aalloc-table tbody tr:hover { background: var(--surface-2); }

/* gradient row marker, matching asset-register.css's listing table exactly */
.aalloc-table tbody td:first-child { position: relative; padding-left: 26px; }
.aalloc-table tbody td:first-child::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #E24FA8, #9B5CF6);
}

.aalloc-asset__name { font-weight: 600; color: var(--text); font-size: 13.5px; }
.aalloc-asset__serial { display: block; margin-top: 3px; font-size: 11.5px; color: var(--text-3); }
.aalloc-asset__code { display: inline-block; margin-top: 4px; font-size: 10.5px; font-weight: 700; color: var(--text-3); background: var(--surface-2); border-radius: 6px; padding: 2px 7px; }

.aalloc-holder { display: flex; align-items: center; gap: 10px; }
.aalloc-holder__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600;
}
.aalloc-holder__name { font-weight: 700; color: var(--text); font-size: 13px; }
.aalloc-holder__role { display: block; margin-top: 1px; font-size: 11.5px; color: var(--text-3); }

.aalloc-pill { display: inline-flex; align-items: center; height: 24px; padding: 0 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.aalloc-pill--participant { background: var(--blue-bg); color: var(--blue); }
.aalloc-pill--staff { background: #FCE7F3; color: #BE185D; }

.aalloc-cond { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.aalloc-cond--good, .aalloc-cond--excellent { background: var(--green-bg); color: var(--green); }
.aalloc-cond--fair { background: var(--amber-bg); color: var(--amber); }
.aalloc-cond--damaged { background: var(--red-bg); color: var(--red); }

.aalloc-status { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.aalloc-status--allocated { background: var(--green-bg); color: var(--green); }
.aalloc-status--cancelled { background: var(--surface-3); color: var(--text-3); }
.aalloc-status--lost { background: var(--red-bg); color: var(--red); }
.aalloc-status--returned { background: var(--violet-bg); color: var(--brand-purple); }

.aalloc-morebtn {
  width: 32px; height: 32px; border-radius: 9px; border: none;
  background: transparent; color: var(--text-3);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: all .16s var(--ease);
}
.aalloc-morebtn svg { width: 18px; height: 18px; }
.aalloc-morebtn:hover, .aalloc-morebtn[aria-expanded="true"] { background: var(--violet-bg); color: var(--brand-purple); }

/* shared 3-dot row action menu — single fixed-position instance reused by
   every row, same pattern as asset-register.css's .areg-rowmenu. */
.aalloc-rowmenu {
  position: fixed; z-index: 120; min-width: 150px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); display: none;
}
.aalloc-rowmenu.is-open { display: block; }
.aalloc-rowmenu__item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2); text-align: left;
  transition: background .16s var(--ease);
}
.aalloc-rowmenu__item svg { width: 16px; height: 16px; flex: none; }

.aalloc-rowmenu__item--view { color: var(--brand-purple); }
.aalloc-rowmenu__item--view:hover { background: var(--violet-bg); }
.aalloc-rowmenu__item--edit { color: var(--amber); }
.aalloc-rowmenu__item--edit:hover { background: var(--amber-bg); }
.aalloc-rowmenu__item--return { color: var(--green); }
.aalloc-rowmenu__item--return:hover { background: var(--green-bg); }
.aalloc-rowmenu__item--history { color: var(--blue); }
.aalloc-rowmenu__item--history:hover { background: var(--blue-bg); }
.aalloc-rowmenu__item--print { color: var(--slate); }
.aalloc-rowmenu__item--print:hover { background: var(--slate-bg); }
.aalloc-rowmenu__item--danger { color: var(--red); }
.aalloc-rowmenu__item--danger:hover { background: var(--red-bg); }

/* ------------------------------------------------------ allocate/edit drawer */

.aalloc-fd__body .field { margin-bottom: 16px; }
.aalloc-fd__body .field__label b { color: var(--red); font-weight: 700; margin-left: 2px; }

.aalloc-fd__section {
  font-size: 11.5px; font-weight: 600; color: var(--aalloc-pink);
  text-transform: uppercase; letter-spacing: .05em;
  margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.aalloc-fd__section:first-child { margin-top: 0; }

.aalloc-fd__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.aalloc-fd__grid .field { margin-bottom: 0; }

.aalloc-rte {
  border: 1.5px solid var(--form-border); border-radius: var(--form-radius);
  background: var(--surface); overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.aalloc-rte:focus-within { border-color: var(--form-focus); box-shadow: 0 0 0 3px var(--form-focus-ring); }

.aalloc-rte__toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 8px 10px; background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.aalloc-rte__sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 6px; }
.aalloc-rte__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 4px; border-radius: 6px;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  transition: background .14s var(--ease), color .14s var(--ease);
}
.aalloc-rte__btn:hover { background: var(--violet-bg); color: var(--brand-purple); }
.aalloc-rte__tt { font-weight: 600; }

.aalloc-rte__body {
  min-height: 90px; padding: 12px 14px; font-size: 13px; color: var(--text);
  line-height: 1.5; outline: none;
}
.aalloc-rte__body:empty:before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }

/* --------------------------------------------------------- view drawer -- */

.aalloc-view__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin-bottom: 8px; }
.aalloc-view__field { display: flex; flex-direction: column; gap: 5px; }
.aalloc-view__label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.aalloc-view__value { font-size: 13.5px; font-weight: 700; color: var(--text); }
.aalloc-view__note { margin-top: 4px; }
.aalloc-view__notebody { font-size: 13px; color: var(--text-2); line-height: 1.55; }

.aalloc-view__badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }

.aalloc-return--overdue { color: var(--red); }
.aalloc-return--ontrack { color: var(--green); }
.aalloc-return--done { color: var(--text-3); }

/* -------------------------------------------------------- history drawer -- */

.aalloc-hist__body { padding: 22px 26px 30px; }

.aalloc-hist__item { display: flex; gap: 14px; }
.aalloc-hist__rail { display: flex; flex-direction: column; align-items: center; flex: none; }
.aalloc-hist__icon {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.aalloc-hist__icon svg { width: 16px; height: 16px; }
.aalloc-hist__icon--allocated { background: var(--green-bg); color: var(--green); }
.aalloc-hist__icon--registered { background: var(--amber-bg); color: var(--amber); }
.aalloc-hist__icon--returned { background: var(--violet-bg); color: var(--brand-purple); }
.aalloc-hist__line { flex: 1; width: 2px; background: var(--border); margin: 4px 0; min-height: 24px; }
.aalloc-hist__item:last-child .aalloc-hist__line { display: none; }

.aalloc-hist__card {
  flex: 1; min-width: 0; margin-bottom: 18px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); overflow: hidden;
}
.aalloc-hist__head {
  width: 100%; display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px; text-align: left; cursor: pointer;
}
.aalloc-hist__title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.aalloc-hist__meta { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.aalloc-hist__meta b { color: var(--text-2); font-weight: 700; }
.aalloc-hist__when { flex: none; text-align: right; }
.aalloc-hist__date { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.aalloc-hist__time { margin-top: 2px; font-size: 11px; color: var(--text-3); }
.aalloc-hist__chev { flex: none; width: 16px; height: 16px; margin-top: 3px; color: var(--text-3); transition: transform .16s var(--ease); }
.aalloc-hist__item.is-open .aalloc-hist__chev { transform: rotate(180deg); }

.aalloc-hist__body2 { display: none; padding: 0 16px 16px; }
.aalloc-hist__item.is-open .aalloc-hist__body2 { display: block; }
.aalloc-hist__note {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); font-size: 12.5px; color: var(--text-2); line-height: 1.5;
}

/* ------------------------------------------------------- delete confirm -- */

.aalloc-modal {
  position: fixed; inset: 0; z-index: 150; padding: 20px;
  display: none; align-items: center; justify-content: center;
  background: rgba(36, 28, 60, .45); backdrop-filter: blur(1px);
}
.aalloc-modal.show { display: flex; }
.aalloc-modal__box { width: 420px; max-width: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 26px; }
.aalloc-modal__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--red-bg); color: var(--red); margin-bottom: 14px;
}
.aalloc-modal__icon svg { width: 20px; height: 20px; }
.aalloc-modal__box h3 { font-size: 16.5px; font-weight: 600; margin: 0 0 8px; }
.aalloc-modal__box p { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 0; }
.aalloc-modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.aalloc-modal__danger { background: var(--red); color: #fff; border-radius: var(--r-btn); border: none; }
.aalloc-modal__danger:hover { background: #C81E1E; }

@media (max-width: 760px) {
  .aalloc-headrow, .aalloc-searchrow { flex-direction: column; align-items: stretch; }
  .aalloc-headrow__actions select { min-width: 0; flex: 1; }
  .aalloc-fd__grid, .aalloc-view__grid { grid-template-columns: 1fr; }
  .aalloc-filters__row { flex-direction: column; align-items: stretch; }
  .aalloc-filters__actions { margin-left: 0; }
}
