/* ==========================================================================
   CareMetrix — Policy Management. A category-sidebar policy browser (quick
   filters, pinning, search + filter + export) with a 3-column card grid and
   a centered Add/Edit Policy modal. Purple/pink/teal design system, same
   page-scoped-CSS + IIFE + mountOverlays() convention used across the app.
   ========================================================================== */

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

.pol-pagepath { margin-bottom: 20px; }

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

/* ----------------------------------------------------------------- body -- */
.pol-body { display: flex; align-items: flex-start; gap: 20px; }

/* -------------------------------------------------------------- sidebar -- */
.pol-sidebar { flex: 0 0 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; position: sticky; top: 16px; }
.pol-sidebar__label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.pol-sidebar__label:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.pol-catitem { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--text-2); text-align: left; transition: background .14s var(--ease); }
.pol-catitem:hover { background: var(--surface-2); }
.pol-catitem.is-active { background: var(--pol-pink-soft); color: var(--pol-pink); font-weight: 600; }
.pol-catitem__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.pol-catitem__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pol-catitem__count { flex: none; background: var(--surface-3); color: var(--text-2); border-radius: 999px; font-size: 10.5px; font-weight: 600; padding: 1px 8px; }
.pol-catitem.is-active .pol-catitem__count { background: var(--pol-pink); color: #fff; }

.pol-sidebar__pinnedrow { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 12px; font-weight: 600; color: var(--text-2); text-align: left; }
.pol-sidebar__pinnedrow:hover { color: var(--brand-purple); }
.pol-sidebar__pinnedrow svg { width: 13px; height: 13px; flex: none; color: var(--brand-purple); fill: var(--brand-purple); }
.pol-sidebar__pinnedrow span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pol-checkbox { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.pol-checkbox input { width: 15px; height: 15px; accent-color: var(--brand-purple); cursor: pointer; }

/* ----------------------------------------------------------------- main -- */
.pol-main { flex: 1; min-width: 0; }

.pol-searchrow { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pol-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 240px; }
.pol-search svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.pol-search input {
  width: 100%; box-sizing: border-box;
  font-size: 13px; padding: 10px 14px 10px 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;
}
.pol-search input:focus { border-color: var(--form-focus); box-shadow: 0 0 0 3px var(--form-focus-ring); }

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

.pol-iconbtn { flex: none; width: 40px; height: 40px; border: 1.5px solid var(--pol-pink); border-radius: var(--r-btn); background: var(--surface); color: var(--pol-pink); display: grid; place-items: center; transition: background .14s var(--ease); }
.pol-iconbtn:hover { background: var(--pol-pink-soft); }
.pol-iconbtn svg { width: 17px; height: 17px; }

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

.pol-section-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 10px; }

/* ------------------------------------------------------------- cardgrid */
.pol-cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.pol-cardgrid:empty { display: none; }

.pol-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: box-shadow .16s var(--ease), border-color .16s var(--ease); }
.pol-card:hover { border-color: var(--border-strong); box-shadow: 0 6px 18px -8px rgba(36,28,60,.18); }

.pol-card__top { display: flex; align-items: center; gap: 8px; }
.pol-codepill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--violet-bg); color: var(--brand-purple); }
.pol-status { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pol-status--active { background: var(--green-bg); color: var(--green); }
.pol-status--inactive { background: var(--surface-3); color: var(--text-3); }
.pol-status__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pol-star { margin-left: auto; flex: none; width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent; color: var(--text-3); display: grid; place-items: center; transition: all .14s var(--ease); }
.pol-star:hover { background: var(--violet-bg); color: var(--brand-purple); }
.pol-star svg { width: 17px; height: 17px; }
.pol-star.is-pinned { color: var(--brand-purple); }
.pol-star.is-pinned svg { fill: var(--brand-purple); }

.pol-card__title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.35; }

.pol-card__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pol-catpill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pol-verpill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }

.pol-card__foot { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }
.pol-card__foot span { display: flex; align-items: center; gap: 6px; }
.pol-card__foot svg { width: 13px; height: 13px; flex: none; }

.pol-listrow-note { grid-column: 1 / -1; text-align: center; color: var(--text-3); padding: 60px 16px; }
.pol-listrow-note svg { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 12px; }
.pol-listrow-note__title { font-size: 15px; font-weight: 700; color: var(--text-2); }
.pol-listrow-note__sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.pol-spinner { width: 22px; height: 22px; border: 3px solid var(--violet-bg); border-top-color: var(--brand-purple); border-radius: 50%; animation: pol-spin .7s linear infinite; margin: 0 auto 10px; }
@keyframes pol-spin { to { transform: rotate(360deg); } }
.pol-errorbanner { display: flex; align-items: center; gap: 10px; background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 12.5px; font-weight: 600; }
.pol-errorbanner button { margin-left: auto; flex: none; border: 1px solid var(--red); border-radius: 8px; padding: 6px 12px; color: var(--red); font-weight: 700; font-size: 12px; }

/* ---------------------------------------------------------------- footer */
.pol-listmeta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pol-listmeta__pagination { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.pol-listmeta__perpage { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.pol-listmeta__perpage select { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; background: var(--surface); color: var(--text); }

/* --------------------------------------------------------- policy drawer */
.pol-modal__section { font-size: 11.5px; font-weight: 600; color: var(--pol-pink); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 12px; }
.pol-modal__section:first-child { margin-top: 0; }
.drawer-body > .field { margin-bottom: 16px; }
.pol-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.pol-grid2 .field { margin-bottom: 0; }
.pol-modal__spacer { flex: 1; }
.pol-formerror { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 16px; }
.pol-danger-btn { color: var(--red); border-color: var(--red-bg); }
.pol-danger-btn:hover { background: var(--red-bg); }

.pol-upload { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px; margin-top: 8px; border: 1.5px dashed var(--border-strong); border-radius: 12px; text-align: center; cursor: pointer; color: var(--text-2); transition: all .14s var(--ease); }
.pol-upload:hover { border-color: var(--brand-purple); background: var(--violet-bg); }
.pol-upload svg { width: 20px; height: 20px; color: var(--brand-purple); }
.pol-upload b { font-size: 13px; font-weight: 700; color: var(--brand-purple); }
.pol-upload small { font-size: 11px; color: var(--text-3); }

.pol-attachlist { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pol-attach { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.pol-attach__icon { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--violet-bg); color: var(--brand-purple); display: grid; place-items: center; }
.pol-attach__icon svg { width: 15px; height: 15px; }
.pol-attach__name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pol-attach__name a { color: inherit; text-decoration: underline; }
.pol-attach__state { flex: none; font-size: 11px; font-weight: 700; }
.pol-attach__state--uploading { color: var(--amber); }
.pol-attach__state--success { color: var(--green); }
.pol-attach__state--error { color: var(--red); }
.pol-attach__retry { flex: none; font-size: 11px; font-weight: 700; color: var(--brand-purple); text-decoration: underline; }
.pol-attach__remove { flex: none; width: 22px; height: 22px; border-radius: 6px; border: none; background: transparent; color: var(--text-3); display: grid; place-items: center; cursor: pointer; }
.pol-attach__remove:hover { background: var(--red-bg); color: var(--red); }
.pol-attach__remove svg { width: 12px; height: 12px; }

.pol .btn.is-loading { pointer-events: none; opacity: .85; }
.pol .btn.is-loading::after { content: ''; display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: -2px; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: pol-spin .7s linear infinite; }

@media (max-width: 900px) {
  .pol-body { flex-direction: column; }
  .pol-sidebar { flex: none; width: 100%; position: static; }
}
@media (max-width: 640px) {
  .pol-grid2 { grid-template-columns: 1fr; }
  .pol-filters__row { flex-direction: column; align-items: stretch; }
  .pol-filters__actions { margin-left: 0; }
}
