/* public/assets/css/s46-notification-channel-picker.css
   KHMER HRMS — Settings → Notification Channels → "Add Notification Channel"
   multi-select event picker (search, grouped/collapsible, chips, bottom
   sheet on phones), Add Device full-width form, and tab-link underline fix.
   UI-only; theme tokens only (works in light + dark). */

/* ── Add Device: use the whole desktop width ─────────────────────── */
.device-form-card { width: 100%; max-width: none !important; box-sizing: border-box; }

/* ── Layout ──────────────────────────────────────────────────────── */
.nc-add-form { display: block; width: 100%; box-sizing: border-box; }
.nc-field-row { display: flex; align-items: flex-end; gap: 12px; }
.nc-picker-group { flex: 1; min-width: 0; }
.nc-field-label { display: block; margin: 0 0 6px; font-weight: 600; font-size: .85rem; color: var(--text-muted); }
.nc-add-btn { flex: 0 0 auto; }
.nc-add-submit { height: 48px; padding: 0 20px; border-radius: 12px; gap: 8px; display: inline-flex; align-items: center; }
.nc-add-submit[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.nc-add-count {
    min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: .75rem; font-weight: 700;
    background: rgba(255,255,255,.28); color: #fff; text-align: center;
}
.nc-add-count[hidden] { display: none; }

/* ── Trigger ─────────────────────────────────────────────────────── */
.nc-picker { position: relative; width: 100%; }
.nc-picker-trigger {
    width: 100%; display: flex; align-items: center; gap: 10px;
    min-height: 48px; padding: 8px 14px;
    background: var(--surface); color: var(--text);
    border: 1.5px solid var(--border); border-radius: 12px;
    font: inherit; text-align: left; cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.nc-picker-trigger:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.nc-picker.is-open .nc-picker-trigger,
.nc-picker-trigger:focus-visible {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.nc-picker.has-value .nc-picker-trigger { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.nc-trigger-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 8px; flex: 0 0 28px;
    color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.nc-trigger-icon svg { width: 16px; height: 16px; }
.nc-picker-summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.nc-picker.has-value .nc-picker-summary { color: var(--text); font-weight: 600; }
.nc-picker-count {
    flex: 0 0 auto; min-width: 24px; padding: 1px 8px; border-radius: 999px;
    background: var(--primary); color: #fff; font-size: .78rem; font-weight: 700; text-align: center;
}
.nc-picker-count[hidden] { display: none; }
.nc-picker-chevron { display: inline-flex; color: var(--text-muted); transition: transform .2s ease; }
.nc-picker-chevron svg { width: 16px; height: 16px; }
.nc-picker.is-open .nc-picker-chevron { transform: rotate(180deg); color: var(--primary); }

/* ── Panel ───────────────────────────────────────────────────────── */
.nc-picker-panel {
    position: absolute; z-index: 60; top: calc(100% + 8px); left: 0; right: 0;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 18px 44px color-mix(in srgb, var(--text) 18%, transparent);
    overflow: hidden;
}
.nc-picker-panel[hidden], .nc-backdrop[hidden] { display: none; }
.nc-sheet-handle { display: none; }

.nc-panel-head { padding: 12px 14px 8px; display: grid; gap: 10px; background: var(--surface); }
.nc-search-wrap { position: relative; }
.nc-search-wrap svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.nc-picker-search {
    width: 100%; box-sizing: border-box; height: 42px; padding: 0 12px 0 36px;
    border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-alt, var(--surface)); color: var(--text);
}
.nc-picker-search:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.nc-bulk-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nc-muted { color: var(--text-muted); font-style: normal; font-weight: 500; }
.nc-link-btn {
    background: none; border: 0; padding: 4px 6px; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600;
    color: var(--primary); border-radius: 6px;
}
.nc-link-btn:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.nc-link-danger { color: var(--danger, #dc2626); }
.nc-link-danger:hover { background: color-mix(in srgb, var(--danger, #dc2626) 10%, transparent); }

.nc-picker-list { max-height: 340px; overflow-y: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ── Custom checkbox ─────────────────────────────────────────────── */
.nc-check { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; }
.nc-input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.nc-box {
    position: relative; flex: 0 0 20px; width: 20px; height: 20px; box-sizing: border-box;
    border: 1.8px solid color-mix(in srgb, var(--text-muted) 70%, var(--border)); border-radius: 6px;
    background: var(--surface); transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.nc-input:focus-visible + .nc-box { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent); }
.nc-input:checked + .nc-box,
.nc-input:indeterminate + .nc-box { background: var(--primary); border-color: var(--primary); }
.nc-input:checked + .nc-box::after {
    content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.nc-input:indeterminate + .nc-box::after {
    content: ""; position: absolute; left: 4px; right: 4px; top: 8px; height: 2px; border-radius: 2px; background: #fff;
}
.nc-check-all { font-weight: 700; font-size: .92rem; }

/* ── Groups + items ──────────────────────────────────────────────── */
.nc-group[hidden], .nc-item[hidden] { display: none; }
.nc-group-head {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    background: var(--surface-alt, var(--surface));
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 2;
}
.nc-group:first-child .nc-group-head { border-top: 0; }
.nc-group-title {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
    background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit; color: var(--text); text-align: left;
}
.nc-group-name { flex: 1; min-width: 0; font-size: .8rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-group-count {
    flex: 0 0 auto; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.nc-group.has-selection .nc-group-count { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); color: var(--primary); }
.nc-group-chevron { display: inline-flex; color: var(--text-muted); transition: transform .18s ease; }
.nc-group-chevron svg { width: 16px; height: 16px; }
.nc-group.is-collapsed .nc-group-chevron { transform: rotate(-90deg); }
.nc-group.is-collapsed .nc-group-body { display: none; }

.nc-item { padding: 10px 14px 10px 16px; transition: background .1s ease; }
.nc-item:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.nc-item:has(.nc-input:checked) { background: color-mix(in srgb, var(--primary) 11%, transparent); }
.nc-item-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.nc-item-label { font-size: .92rem; line-height: 1.35; color: var(--text); }
.nc-item-key { font-size: .72rem; color: var(--text-muted); letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-no-results { padding: 22px 14px; text-align: center; margin: 0; color: var(--text-muted); }

/* ── Footer ──────────────────────────────────────────────────────── */
.nc-panel-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface);
}
.nc-foot-count { font-size: .88rem; color: var(--text-muted); }
.nc-foot-count b { color: var(--text); font-size: .95rem; }

/* ── Selected chips tray ─────────────────────────────────────────── */
.nc-tray {
    margin-top: 12px; padding: 12px 14px; border-radius: 14px;
    border: 1px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
    background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}
.nc-tray[hidden] { display: none; }
.nc-tray-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.nc-tray-title { font-size: .8rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-muted); }
.nc-tray-chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 148px; overflow-y: auto; }
.nc-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    padding: 4px 4px 4px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600;
    background: var(--surface); color: var(--text);
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
}
.nc-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-chip-x {
    flex: 0 0 22px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-size: 1.1rem;
    background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-muted);
}
.nc-chip-x:hover { background: var(--danger, #dc2626); color: #fff; }

/* ── Phones: bottom sheet ────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .nc-field-row { flex-direction: column; align-items: stretch; gap: 12px; }
    .nc-add-btn, .nc-add-submit { width: 100%; justify-content: center; }
    .nc-add-submit { height: 50px; }

    .nc-backdrop { position: fixed; inset: 0; z-index: 1190; background: rgba(15, 23, 42, .5); }
    .nc-picker-panel {
        position: fixed; z-index: 1200; left: 0; right: 0; bottom: 0; top: auto;
        max-height: 82vh; border-radius: 20px 20px 0 0; border-width: 1px 0 0;
        box-shadow: 0 -12px 40px rgba(15, 23, 42, .28);
        animation: nc-sheet-up .22s ease-out;
    }
    .nc-sheet-handle { display: block; width: 42px; height: 4px; border-radius: 4px; margin: 10px auto 0; background: var(--border); }
    .nc-picker-list { max-height: none; flex: 1 1 auto; min-height: 0; }
    .nc-item { padding-block: 13px; }
    .nc-box { flex-basis: 22px; width: 22px; height: 22px; }
    .nc-input:checked + .nc-box::after { left: 7px; top: 3px; }
    .nc-input:indeterminate + .nc-box::after { top: 9px; }
    .nc-panel-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
    .nc-panel-foot .btn { min-height: 44px; padding-inline: 22px; }
    body.nc-sheet-open { overflow: hidden; }
}
@keyframes nc-sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Tab links (<a class="tab-btn">) must not show the browser's default
   underline (Attendance / Locations tabs). The active tab keeps its
   2px bottom border as the indicator. ── */
a.tab-btn, a.tab-btn:hover, a.tab-btn:focus, a.tab-btn:active { text-decoration: none; }

/* ── Telegram destination form: a .form-row-2 has no bottom margin of its own,
   so the field below ("Message Language") touched the Audience select. ── */
#telegram-destination-form .form-row-2 { margin-bottom: var(--space-2, 16px); }
