/**
 * Messages hub shared UI — Conversations · Team · Broadcasts · Campaigns
 *
 * Implements the "Kovello messaging UI optimization v2" design handoff:
 * one underline tab bar, a lighter neutral scale, numbered step headers and
 * a single set of stage pills shared by every panel in the hub.
 *
 * The handoff renders the app blue as #1a73e8; we keep the app's own
 * --primary-color (#0d6efd) and adopt the handoff's neutrals and tints.
 */

:root {
    /* Handoff neutral scale */
    --hub-border: #eceef1;
    --hub-border-soft: #f1f2f4;
    --hub-line: #e5e7eb;
    --hub-ink: #1f2937;
    --hub-ink-soft: #4b5563;
    --hub-muted: #6b7280;
    --hub-faint: #9ca3af;
    --hub-canvas: #fafbfc;
    --hub-fill: #f3f4f6;
    --hub-tint: #e8f0fe;
    --hub-row-active: #f8faff;
    --hub-radius: 8px;
}

/* ==========================================================================
   1d — UNDERLINE TAB BAR
   ========================================================================== */
.messages-hub-nav {
    background: #fff;
    border-bottom: 1px solid var(--hub-border);
}

.messages-hub-nav .nav-tabs {
    border-bottom: 0;
    gap: 1.625rem;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    flex-wrap: nowrap;
}

.messages-hub-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    padding: 0.8125rem 0.125rem;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 0;
    color: var(--hub-muted);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.messages-hub-nav .nav-link:hover,
.messages-hub-nav .nav-link:focus {
    border-color: transparent;
    border-bottom-color: var(--hub-line);
    color: var(--hub-ink);
    background: transparent;
    isolation: auto;
}

.messages-hub-nav .nav-link.active {
    background: transparent;
    border-color: transparent;
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

.messages-hub-nav .nav-link .badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.0625rem 0.375rem;
}

/* ==========================================================================
   NUMBERED STEP HEADERS (1b broadcasts, 2a campaign modal)
   ========================================================================== */
.hub-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hub-step-num {
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    line-height: 1;
}

.hub-step-title {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--hub-ink);
}

.hub-step-note {
    font-size: 0.75rem;
    color: var(--hub-faint);
}

/* ==========================================================================
   STAGE PILLS — one vocabulary across conversations, broadcasts, campaigns
   ========================================================================== */
.stage-pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.45;
    padding: 0.1875rem 0.625rem;
    border-radius: 99px;
    white-space: nowrap;
    background: var(--hub-fill);
    color: var(--hub-muted);
}

.stage-pill-arriving,
.stage-pill-pre_arrival {
    background: #e0f5fa;
    color: #0e7490;
}

.stage-pill-in_house {
    background: #fef3e2;
    color: #b45309;
}

.stage-pill-departing,
.stage-pill-pre_departure,
.stage-pill-departure {
    background: #f1eafe;
    color: #7c3aed;
}

.stage-pill-past,
.stage-pill-post_departure {
    background: var(--hub-fill);
    color: var(--hub-muted);
}

.stage-pill-cancelled {
    background: #fdeaea;
    color: #b42318;
}

/* ==========================================================================
   FILTER PILLS — lighter than a btn-group (1a)
   ========================================================================== */
.hub-filter-pills {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.hub-filter-pill {
    border: 1px solid var(--hub-line);
    background: #fff;
    color: var(--hub-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
    padding: 0.40625rem 0.875rem;
    border-radius: 99px;
    white-space: nowrap;
}

.hub-filter-pill:hover {
    border-color: #cfd6dd;
    color: var(--hub-ink);
}

.hub-filter-pill.active {
    background: var(--hub-tint);
    border-color: var(--hub-tint);
    color: var(--primary-color);
    font-weight: 600;
}

.hub-filter-pill .pill-count::before {
    content: " · ";
}

.hub-filter-pill .pill-count:empty {
    display: none;
}

/* ==========================================================================
   SEARCH PILL — filled, borderless (1a, 1b)
   ========================================================================== */
.hub-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--hub-fill);
    border-radius: var(--hub-radius);
    padding: 0 0.75rem;
}

.hub-search > i {
    color: var(--hub-faint);
    font-size: 0.8125rem;
    flex: none;
}

.hub-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0.5625rem 0;
    font-size: 0.84375rem;
    color: var(--hub-ink);
}

.hub-search input::placeholder {
    color: var(--hub-faint);
}

.hub-search input:focus {
    outline: none;
    box-shadow: none;
}

.hub-search .hub-search-clear {
    border: 0;
    background: transparent;
    color: var(--hub-faint);
    padding: 0;
    line-height: 1;
    flex: none;
}

/* ==========================================================================
   RECIPIENT / SELECTION CHIPS (1b)
   ========================================================================== */
.hub-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.78125rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--hub-tint);
    padding: 0.25rem 0.6875rem;
    border-radius: 99px;
    white-space: nowrap;
}

.hub-chip button {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    line-height: 1;
    font-size: 0.75rem;
    opacity: 0.7;
}

.hub-chip button:hover {
    opacity: 1;
}

/* ==========================================================================
   TOGGLE CHIPS — multi-select audience (2a), stage quick picks (1b)
   ========================================================================== */
.hub-toggle-chip {
    border: 1px solid var(--hub-line);
    background: #fff;
    color: var(--hub-ink-soft);
    font-size: 0.8125rem;
    line-height: 1.45;
    padding: 0.4375rem 0.875rem;
    border-radius: 99px;
    white-space: nowrap;
}

.hub-toggle-chip:hover {
    border-color: #cfd6dd;
}

.hub-toggle-chip.active {
    background: var(--hub-tint);
    border-color: var(--hub-tint);
    color: var(--primary-color);
    font-weight: 600;
}

.hub-toggle-chip .bi-check-lg {
    display: none;
    margin-right: 0.1875rem;
}

.hub-toggle-chip.active .bi-check-lg {
    display: inline-block;
}

/* ==========================================================================
   AVATAR (1a)
   ========================================================================== */
.hub-avatar {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
    background: var(--hub-tint);
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.75rem;
    display: grid;
    place-items: center;
    text-transform: uppercase;
}

/* On/off and warning tones for the stage pill, used by settings-style tables
   (room types, add-ons) where the pill reports state rather than a stay stage. */
.stage-pill.pill-on {
    background: #e3f5ea;
    color: #15803d;
}

.stage-pill.pill-off {
    background: #fdeaea;
    color: #b42318;
}

.stage-pill.pill-warn {
    background: #fef3e2;
    color: #b45309;
}

/* ==========================================================================
   UPGRADE TIER PILLS
   Coloured by ascending exclusivity — grey floor, cool steel, warm gold, then
   indigo for the top tier — so the ladder reads at a glance and none of them
   collide with the stay-stage colours above.
   ========================================================================== */
.stage-pill-tier-base {
    background: var(--hub-fill);
    color: var(--hub-muted);
}

.stage-pill-tier-silver {
    background: #e7edf3;
    color: #4a5b6e;
}

.stage-pill-tier-gold {
    background: #fbefd3;
    color: #8a6100;
}

.stage-pill-tier-diamond {
    background: #e8e6fd;
    color: #4f39c9;
}

/* ==========================================================================
   INSERT BOX — the one message-composer pattern
   A bordered box holding the editor with its variable chips in a footer bar.
   Used by the campaign editor, message templates, journey stages and the
   departure survey, so "drag a variable in" looks the same everywhere.
   ========================================================================== */
.insert-box {
    border: 1px solid var(--hub-line);
    border-radius: var(--hub-radius);
    overflow: hidden;
    background: #fff;
}

.insert-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--hub-tint);
}

.insert-box textarea,
.insert-box .var-editor {
    display: block;
    width: 100%;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.75rem;
    line-height: 1.5;
    resize: vertical;
}

.insert-box textarea:focus,
.insert-box .var-editor:focus {
    outline: none;
    box-shadow: none !important;
}

.insert-foot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-top: 1px solid var(--hub-border-soft);
}

.insert-label {
    flex: none;
    font-size: 0.71875rem;
    color: var(--hub-muted);
}

.insert-foot .variable-chips {
    gap: 0.3125rem;
}

.insert-foot .variable-chip {
    font-size: 0.71875rem;
    padding: 0.1875rem 0.5625rem 0.1875rem 0.4375rem;
    background: #fff;
}

.insert-count {
    margin-left: auto;
    flex: none;
    font-size: 0.71875rem;
    color: var(--hub-faint);
}

/* "+N more" reveals the long tail of a variable list */
.variable-chip-more {
    border: 0;
    background: transparent;
    color: var(--primary-color);
    font-size: 0.71875rem;
    font-weight: 600;
    padding: 0.1875rem 0.25rem;
    white-space: nowrap;
}

.variable-chip-more:hover {
    text-decoration: underline;
}

/* ==========================================================================
   DATE / FILTER POPOVER
   Shared by the Broadcasts audience picker and the Analytics date range, so a
   popover looks the same wherever one opens.
   ========================================================================== */
/* Popover shell shared by the stage picker and the date range */
.audience-popover {
    position: absolute;
    top: calc(100% + 0.375rem);
    width: 290px;
    max-width: calc(100vw - 2rem);
    z-index: 1050;
    background: #fff;
    border: 1px solid var(--hub-line);
    border-radius: 0.625rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.audience-stage-panel {
    left: 0;
    gap: 0.25rem;
}

.audience-dates-panel {
    right: 0;
}

.audience-quick-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3125rem;
}

.audience-quick-pick {
    font-size: 0.75rem;
    color: var(--hub-ink-soft);
    background: #fff;
    border: 1px solid var(--hub-line);
    padding: 0.3125rem 0.6875rem;
    border-radius: 99px;
}

.audience-quick-pick:hover {
    border-color: #cfd6dd;
}

.audience-quick-pick.active {
    font-weight: 600;
    color: var(--primary-color);
    background: var(--hub-tint);
    border-color: var(--hub-tint);
}

.audience-date-inputs {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.audience-date-inputs input[type="date"] {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.audience-dates-hint {
    font-size: 0.6875rem;
    color: var(--hub-faint);
    line-height: 1.4;
}

.audience-dates-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--hub-border-soft);
}

