/* ==========================================================================
   CareMetrix — Notice Board Management. A location/property-scoped notice
   list (search, filters, pagination) plus a Create/Edit/View Notice drawer
   with per-file attachment upload states, a delete-confirmation modal, and
   permission/role-aware fields (Organization Administrator vs a
   property-level user). Follows the same page-scoped-CSS + IIFE +
   mountOverlays() convention as Leave Approval (.pagination,
   .commonstyletabletwo, .breadcrumb, .drawer, .overlay).
   ========================================================================== */

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

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

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

.nb-card { overflow: hidden; }

.nb-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); }
.nb-headrow__title h1 { font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.nb-headrow__title p { margin-top: 3px; font-size: 12.5px; color: var(--text-2); }
.nb-headrow__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nb-headrow__actions select#nbOrgSelect { flex: none; height: 38px; width: 190px; 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); }


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

/* ------------------------------------------------------------ searchrow -- */
.nb-searchrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.nb-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 240px; max-width: 480px; }
.nb-search svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.nb-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;
}
.nb-search input:focus { border-color: var(--form-focus); box-shadow: 0 0 0 3px var(--form-focus-ring); }

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

.nb-searchrow__pagination { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.nb-searchrow__perpage { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.nb-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 */
.nb-card .table-wrap { width: auto; margin: 0 24px 24px; border: 1px solid var(--commontable2-cell-border); border-radius: 12px; overflow-x: auto; }
.nb-card .table-wrap thead tr th:first-child { border-top-left-radius: 11px; }
.nb-card .table-wrap thead tr th:last-child { border-top-right-radius: 11px; }

.nb-table th.t-right, .nb-table td.t-right { width: 1%; white-space: nowrap; }
.nb-table tbody td:first-child { position: relative; padding-left: 26px; }
.nb-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); }

.nb-notice__title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.nb-notice__desc { font-size: 11.5px; color: var(--text-3); margin-top: 2px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-locprop { font-size: 12.5px; color: var(--text-2); }
.nb-locprop small { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; }

.nb-pill { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.nb-pill--high { background: var(--red-bg); color: var(--red); }
.nb-pill--medium { background: var(--amber-bg); color: var(--amber); }
.nb-pill--low { background: var(--surface-3); color: var(--text-2); }

.nb-schedpill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.nb-schedpill--instant { background: var(--violet-bg); color: var(--brand-purple); }
.nb-schedpill--scheduled { background: var(--amber-bg); color: var(--amber); }
.nb-schedpill svg { width: 13px; height: 13px; }
.nb-schedsub { display: block; font-size: 10.5px; color: var(--text-3); margin-top: 3px; }

.nb-status { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.nb-status--1 { background: var(--green-bg); color: var(--green); }
.nb-status--0 { background: var(--surface-3); color: var(--text-3); }
.nb-status--2 { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-strong); }
.nb-hiddennote { display: block; font-size: 10px; color: var(--text-3); margin-top: 3px; font-style: italic; }

.nb-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); }
.nb-morebtn svg { width: 18px; height: 18px; }
.nb-morebtn:hover, .nb-morebtn[aria-expanded="true"] { background: var(--violet-bg); color: var(--brand-purple); }

.nb-rowmenu { position: fixed; z-index: 120; min-width: 170px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); display: none; }
.nb-rowmenu.is-open { display: block; }
.nb-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); }
.nb-rowmenu__item svg { width: 16px; height: 16px; flex: none; }
.nb-rowmenu__item--view:hover { background: var(--violet-bg); color: var(--brand-purple); }
.nb-rowmenu__item--edit:hover { background: var(--amber-bg); color: var(--amber); }
.nb-rowmenu__item--status:hover { background: var(--green-bg); color: var(--green); }
.nb-rowmenu__item--danger { color: var(--red); }
.nb-rowmenu__item--danger:hover { background: var(--red-bg); }

/* list states: loading / empty / error */
.nb-listrow-note { text-align: center; color: var(--text-3); padding: 40px 16px; }
.nb-listrow-note svg { width: 30px; height: 30px; color: var(--text-3); margin-bottom: 8px; }
.nb-spinner { width: 22px; height: 22px; border: 3px solid var(--violet-bg); border-top-color: var(--brand-purple); border-radius: 50%; animation: nb-spin .7s linear infinite; margin: 0 auto 10px; }
@keyframes nb-spin { to { transform: rotate(360deg); } }
.nb-errorbanner { display: flex; align-items: center; gap: 10px; background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 12px 14px; margin: 0 24px 16px; font-size: 12.5px; font-weight: 600; }
.nb-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; }

/* ---------------------------------------------------------- create drawer */

.nb-section { font-size: 11.5px; font-weight: 600; color: var(--nb-pink); text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.nb-section:first-child { margin-top: 0; }
.nb-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.nb-grid2 .field { margin-bottom: 0; }
.drawer-body > .field { margin-bottom: 16px; }
.nb-hint { font-size: 11.5px; color: var(--text-3); margin: -8px 0 16px; }
.nb-formerror { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 16px; }

/* audience tabs */
.nb-audtabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.nb-audtabs button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border: 1.5px solid var(--border-strong); border-radius: 12px; font-size: 12.5px; font-weight: 700; color: var(--text-2); background: var(--surface); transition: all .14s var(--ease); }
.nb-audtabs button.is-active { border-color: var(--brand-purple); color: var(--brand-purple); background: var(--violet-bg); }
.nb-audtabs button:disabled { opacity: .6; cursor: not-allowed; }
.nb-audtabs__icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.nb-audtabs__icon--participant { background: linear-gradient(135deg, #E24FA8, #9B5CF6); }
.nb-audtabs__icon--staff { background: linear-gradient(135deg, #7C3AED, #4F46E5); }
.nb-audtabs__icon--family { background: linear-gradient(135deg, #EC4899, #9B5CF6); }

/* member search + results */
.nb-searchsel { position: relative; }
.nb-searchsel__results { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; right: 0; max-height: 220px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.nb-searchsel__results[hidden] { display: none; }
.nb-searchsel__item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 12.5px; }
.nb-searchsel__item:hover { background: var(--violet-bg); }
.nb-searchsel__item .nb-avatar { width: 28px; height: 28px; font-size: 10.5px; }
.nb-searchsel__empty { padding: 10px; font-size: 12px; color: var(--text-3); text-align: center; }
.nb-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(135deg, #C026D3, #7C3AED); }

/* selected member cards */
.nb-membergrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; margin-bottom: 16px; }
.nb-membercard { position: relative; display: flex; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.nb-membercard__name { font-size: 12.5px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nb-membercard__sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.nb-membercard__remove { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--red-bg); background: var(--red-bg); color: var(--red); display: grid; place-items: center; cursor: pointer; }
.nb-membercard__remove svg { width: 11px; height: 11px; }
.nb-membertype { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; font-size: 9.5px; font-weight: 600; text-transform: uppercase; background: var(--violet-bg); color: var(--brand-purple); }
.nb-membergrid:empty { display: none; }

@media (max-width: 560px) { .nb-audtabs, .nb-membergrid { grid-template-columns: 1fr; } }

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

.nb-attachlist { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.nb-attach { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.nb-attach__icon { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--violet-bg); color: var(--brand-purple); display: grid; place-items: center; }
.nb-attach__icon svg { width: 15px; height: 15px; }
.nb-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; }
.nb-attach__name a { color: inherit; text-decoration: underline; }
.nb-attach__state { flex: none; font-size: 11px; font-weight: 700; }
.nb-attach__state--uploading { color: var(--amber); }
.nb-attach__state--success { color: var(--green); }
.nb-attach__state--error { color: var(--red); }
.nb-attach__retry { flex: none; font-size: 11px; font-weight: 700; color: var(--brand-purple); text-decoration: underline; }
.nb-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; }
.nb-attach__remove:hover { background: var(--red-bg); color: var(--red); }
.nb-attach__remove svg { width: 12px; height: 12px; }

.nb-audit { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 11.5px; color: var(--text-3); }
.nb-audit b { display: block; color: var(--text-2); font-weight: 700; }

.nb-danger-btn { color: var(--red); border-color: var(--red-bg); }
.nb-danger-btn:hover { background: var(--red-bg); }

.nb .btn.is-loading { pointer-events: none; opacity: .85; }
.nb .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: nb-spin .7s linear infinite; }

@media (max-width: 760px) {
  .nb-headrow, .nb-searchrow { flex-direction: column; align-items: stretch; }
  .nb-grid2, .nb-audit { grid-template-columns: 1fr; }
  .nb-filters__row { flex-direction: column; align-items: stretch; }
  .nb-filters__actions { margin-left: 0; }
}
