/*
 * components/notification-send.css
 *
 * What:  The super-admin Send-a-notification composer and the delivery history
 *        (list, filters and detail drawer).
 * Why:   Both screens are operated rather than read, so the styling carries
 *        information: an unread row is marked, a retired device is dimmed, a
 *        section's number shows the order the decisions come in, and the phone
 *        preview shows the one thing a form cannot — what the customer sees.
 *
 *        Every colour comes from the base.css tokens.
 *
 * Used:  linked from admin/views/_layout.ejs; markup in
 *        views/notifications/send.ejs and views/notifications/history.ejs.
 */

.ns-head__links { display: flex; gap: var(--space-2); }

/* ── Reach / stats strip ─────────────────────────────────────── */
/* "Send to all customers" is a number, not a phrase. This sits above the form
   so the operator sees the scale before choosing anything. */

.nsx-reach {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.nsx-reach__item {
    flex: 1 1 120px;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 12px);
}

.nsx-reach__n {
    display: block;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.nsx-reach__l {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.nsx-note {
    margin: 0 0 var(--space-5);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* ── Sections ────────────────────────────────────────────────── */
/* Numbered because this IS a sequence: section 4 changes shape depending on
   section 1, and section 5 cannot be filled in before the rest. */

.nsx-form { display: flex; flex-direction: column; gap: var(--space-5); }

.nsx-sec__head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.nsx-sec__num {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    border-radius: 50%;
    font-size: 0.8125rem;
    font-weight: 700;
}

.nsx-sec__hint {
    margin: 2px 0 0;
    max-width: 68ch;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}

/* A locked section (audience, in test mode) still reads but cannot be used. */
.nsx-sec.is-locked .nsx-modes { opacity: 0.55; }

/* ── Radio / checkbox cards ──────────────────────────────────── */

.nsx-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-3);
}

.nsx-mode {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
}

.nsx-mode:hover { border-color: var(--color-text-soft); }

/* Selected state on the CARD, driven by the radio inside it — the whole card is
   the target, which is a far bigger hit area than the dot alone. */
.nsx-mode:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.nsx-mode input { margin-top: 3px; flex-shrink: 0; }

.nsx-mode__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.nsx-mode__t { font-size: 0.9375rem; font-weight: 600; color: var(--color-text); }
.nsx-mode__d { font-size: 0.75rem; line-height: 1.45; color: var(--color-text-muted); }

.nsx-mode input:disabled ~ .nsx-mode__body { opacity: 0.5; }

.nsx-checks { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.nsx-check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill, 999px);
    font-size: 0.875rem;
    cursor: pointer;
}

.nsx-check em {
    margin-left: var(--space-1);
    font-style: normal;
    font-size: 0.75rem;
    color: var(--color-text-soft);
    font-variant-numeric: tabular-nums;
}

/* ── Inputs ──────────────────────────────────────────────────── */

.nsx-input {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 10px);
    background: var(--color-surface);
    font: inherit;
    font-size: 0.9375rem;
    color: var(--color-text);
}

.nsx-input:focus-visible {
    outline: 2px solid var(--color-info);
    outline-offset: 1px;
    border-color: var(--color-info);
}

.nsx-textarea { resize: vertical; line-height: 1.5; }

.nsx-count {
    float: right;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-soft);
    font-variant-numeric: tabular-nums;
}

/* Revealed when the chosen type is switched off — a real send would deliver
   nothing, and that is worth saying before the message is written. */
.nsx-warn {
    margin: var(--space-2) 0 0;
    padding: var(--space-2) var(--space-3);
    background: #FEF3DC;
    border-left: 3px solid var(--color-warn);
    border-radius: 4px;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #7A4E00;
}

.nsx-warn a { color: inherit; font-weight: 600; }

/* ── Customer picker ─────────────────────────────────────────── */

.nsx-picker,
.nsx-tokens { margin-top: var(--space-4); }

.nsx-results {
    list-style: none;
    margin: var(--space-2) 0 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 10px);
    background: var(--color-surface);
}

.nsx-results__row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3);
    border: 0;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.nsx-results__row:hover { background: var(--color-bg-alt); }
.nsx-results__row small { color: var(--color-text-soft); }

.nsx-results__none {
    padding: var(--space-3);
    font-size: 0.875rem;
    color: var(--color-text-soft);
}

.nsx-picker__count {
    margin: var(--space-3) 0 var(--space-2);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.nsx-picker__count strong { font-variant-numeric: tabular-nums; }

.nsx-chosen {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.nsx-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px var(--space-2) 4px var(--space-3);
    background: var(--color-primary-soft);
    border-radius: var(--radius-pill, 999px);
    font-size: 0.8125rem;
    color: var(--color-primary-dark);
}

.nsx-chip__x {
    border: 0;
    background: none;
    padding: 0 2px;
    font-size: 1rem;
    line-height: 1;
    color: inherit;
    cursor: pointer;
}

/* ── Compose + preview ───────────────────────────────────────── */

.nsx-compose {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr);
    gap: var(--space-6);
    align-items: start;
}

.nsx-compose__fields {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
}

.nsx-preview__cap {
    margin: 0 0 var(--space-2);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-soft);
}

/* The phone mock. Worth the space: it is the only place an operator can see
   that a title is three words too long before thousands of people do. */
.nsx-phone,
.nhx-phone {
    padding: var(--space-4);
    background: linear-gradient(160deg, #2B3350, #171C2E);
    border-radius: var(--radius-lg, 14px);
}

.nsx-phone__ntf,
.nhx-phone__ntf {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    background: rgba(255, 255, 255, 0.94);
    border-radius: 12px;
}

.nsx-phone__ic { flex-shrink: 0; font-size: 1.125rem; }
.nsx-phone__txt { min-width: 0; }

.nsx-phone__app {
    margin: 0 0 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #6B6B6B;
}

.nsx-phone__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 700;
    color: #1C1C1C;
    overflow-wrap: anywhere;
}

.nsx-phone__body {
    margin: 2px 0 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #3B3B3B;
    overflow-wrap: anywhere;
}

/* ── Confirm + send ──────────────────────────────────────────── */

/* The gate on the one irreversible action here. Deliberately loud. */
.nsx-confirm {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    background: var(--color-primary-soft);
    border-radius: var(--radius-md, 10px);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text);
    cursor: pointer;
}

.nsx-confirm input { margin-top: 3px; flex-shrink: 0; }

.nsx-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.nsx-result { font-size: 0.875rem; color: var(--color-text-muted); }
.nsx-result.is-ok  { color: var(--color-success); font-weight: 600; }
.nsx-result.is-bad { color: var(--color-error);   font-weight: 600; }
.nsx-result__link  { color: var(--color-primary); font-weight: 600; }

/* ── History: filters ────────────────────────────────────────── */

.nhx-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-3);
    align-items: end;
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 12px);
}

.nhx-filters__actions { display: flex; gap: var(--space-2); }

/* ── History: table ──────────────────────────────────────────── */
/* Wrapped so a narrow window scrolls the TABLE, never the page sideways. */

.nhx-tablewrap {
    overflow-x: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 12px);
}

.nhx-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.nhx-table th {
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-alt);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.nhx-table td {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border-soft);
    vertical-align: top;
}

/* Unread rows carry a rail as well as bolder text — colour alone is not a
   signal everyone can read. */
.nhx-table tr.is-unread td:first-child { box-shadow: inset 3px 0 0 var(--color-primary); }
.nhx-table tr.is-unread .nhx-msg__t    { font-weight: 700; }

.nhx-when {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
}

.nhx-cust { display: block; font-weight: 600; color: var(--color-text); }

.nhx-sub {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--color-text-soft);
}

.nhx-msg { max-width: 380px; }
.nhx-msg__t { display: block; color: var(--color-text); }

.nhx-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill, 999px);
    font-size: 0.6875rem;
    font-weight: 700;
    white-space: nowrap;
}

/* One tint per category, matching the customer-facing bell so the two read as
   the same taxonomy. */
.nhx-badge--order     { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.nhx-badge--loyalty   { background: #E6F6EE; color: #0F7A45; }
.nhx-badge--offers    { background: #FEF3DC; color: #8A5B00; }
.nhx-badge--community { background: #E7F0FE; color: #1B5FC1; }
.nhx-badge--account   { background: var(--color-bg-alt); color: var(--color-text-muted); }
.nhx-badge--admin     { background: #EFE7FE; color: #5B2BC1; }

.nhx-read { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.nhx-read--yes { color: var(--color-success); }
.nhx-read--no  { color: var(--color-primary); }

.nhx-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.nhx-paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-5);
}

.nhx-paging__at {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── History: detail drawer ──────────────────────────────────── */

.nhx-drawer { position: fixed; inset: 0; z-index: 200; }

.nhx-drawer__bg { position: absolute; inset: 0; background: rgba(18, 24, 46, 0.5); }

.nhx-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(480px, 100%);
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    box-shadow: -8px 0 30px rgba(18, 24, 46, 0.18);
}

.nhx-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.nhx-drawer__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.nhx-drawer__x {
    border: 0;
    background: none;
    padding: 0 var(--space-2);
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}

.nhx-drawer__body { flex: 1; overflow-y: auto; padding: var(--space-4); }

/* Stops the page behind the drawer scrolling under it. */
body.nhx-locked { overflow: hidden; }

.nhx-d { margin: 0 0 var(--space-4); }

.nhx-d__row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border-soft);
}

.nhx-d__row dt { font-size: 0.75rem; font-weight: 700; color: var(--color-text-soft); }

.nhx-d__row dd {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.nhx-d__h {
    margin: var(--space-5) 0 var(--space-2);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-soft);
}

.nhx-d__none {
    margin: 0;
    padding: var(--space-3);
    background: var(--color-bg-alt);
    border-radius: var(--radius-md, 10px);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}

.nhx-code,
.nhx-json {
    display: block;
    padding: var(--space-2) var(--space-3);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-soft);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.nhx-json { margin: 0; overflow-x: auto; white-space: pre; }

.nhx-devs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.nhx-dev {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 10px);
    font-size: 0.8125rem;
}

/* A retired token is dimmed rather than hidden: "this device used to work" is
   part of the answer to "why was there no push". */
.nhx-dev.is-off { opacity: 0.55; }

.nhx-dev__p { font-weight: 700; text-transform: capitalize; }
.nhx-dev__s { color: var(--color-text-muted); }

.nhx-dev small {
    margin-left: auto;
    color: var(--color-text-soft);
    font-size: 0.6875rem;
}

/* ── Phone ──────────────────────────────────────────────────── */

@media (max-width: 900px) {
    /* The preview drops below the fields rather than squeezing both. */
    .nsx-compose { grid-template-columns: minmax(0, 1fr); }
}
