/* ========================================
   Marketing Module Styles
   Styles for ASIModule.Marketing components that must load reliably
   in production. Scoped .razor.css bundles (A2GV2.styles.css) are not
   regenerated dependably for production deployments, so marketing
   component styles live here instead (same fix as text-threads.css,
   grid-toolbar/tables.css, and marketing-segmented-group/buttons.css).
   Colors come from theme variables only (themes.css).
   ======================================== */

/* ========================================
   AI Assistant Panel (AiAssistantPanel.razor)
   Shared right-side chat pane used by the template editor
   and blast compose dialogs.
   ======================================== */

.ai-toggle-rail {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.25rem;
    border-left: 1px solid var(--border-color, var(--bs-border-color));
    background-color: var(--bg-primary, var(--bs-body-bg));
}

.ai-toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-primary, var(--bs-body-color));
    border-radius: 0.375rem;
    padding: 0.35rem 0.45rem;
    line-height: 1;
    cursor: pointer;
}

.ai-toggle-btn:hover {
    background-color: var(--bg-secondary, var(--bs-secondary-bg));
}

.ai-toggle-icon {
    font-size: 1.35rem;
    display: inline-block;
}

.ai-chat-pane {
    flex: 0 0 400px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid var(--border-color, var(--bs-border-color));
    background-color: var(--bg-primary, var(--bs-body-bg));
}

.ai-chat-thread {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

/* Message-thread bubbles: user requests on the right, assistant replies on the left. */
.ai-chat-message {
    display: flex;
    width: 100%;
}

.ai-chat-message.ai-chat-user {
    justify-content: flex-end;
}

.ai-chat-message.ai-chat-assistant {
    justify-content: flex-start;
}

.ai-chat-bubble {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.85rem;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-user .ai-chat-bubble {
    background-color: var(--primary-color);
    color: var(--text-light);
    border-bottom-right-radius: 0.25rem;
}

.ai-chat-assistant .ai-chat-bubble {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 0.25rem;
}

/* The suggested-content card renders inside the thread as a full-width assistant bubble. */
.ai-chat-assistant .ai-chat-bubble.ai-draft-preview {
    max-width: 100%;
    width: 100%;
    background-color: var(--bg-primary);
    white-space: normal;
}

.ai-draft-body {
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.ai-chat-input {
    resize: vertical;
}

.ai-token-counter {
    border: 1px solid var(--border-color, var(--bs-border-color));
    border-radius: var(--bs-border-radius);
    background-color: var(--bg-secondary, var(--bs-secondary-bg));
    padding: 0.4rem 0.55rem;
}

/* Compact single-line usage meter shown only when the agency has a token limit. */
.ai-usage-compact {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    border: 1px solid var(--border-color, var(--bs-border-color));
    border-radius: var(--bs-border-radius);
    background-color: var(--bg-secondary, var(--bs-secondary-bg));
    color: var(--text-secondary, var(--bs-secondary-color));
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}

.ai-usage-compact:hover {
    color: var(--text-primary, var(--bs-body-color));
}

.ai-usage-bar {
    flex: 1 1 auto;
    height: 6px;
    border-radius: 3px;
    background-color: var(--border-color, var(--bs-border-color));
    overflow: hidden;
}

.ai-usage-bar-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
}

.ai-usage-bar-fill.usage-ok { background-color: var(--bs-success); }
.ai-usage-bar-fill.usage-warning { background-color: var(--bs-warning); }
.ai-usage-bar-fill.usage-danger { background-color: var(--bs-danger); }

.ai-usage-details-link {
    text-decoration: none;
    font-size: 0.8rem;
}

.ai-usage-popover-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 1100;
}

.ai-usage-popover {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: min(360px, calc(100vw - 2rem));
    background-color: var(--bg-primary, var(--bs-body-bg));
    border: 1px solid var(--border-color, var(--bs-border-color));
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
    z-index: 1110;
}

.ai-privacy-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.ai-privacy-warning i {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

/* Widen the host dialogs while the AI chat pane is open.
   The extra .ai-panel-open class keeps these ahead of the base dialog widths below. */
.modal-dialog.template-edit-dialog.ai-panel-open,
.modal-dialog.blast-compose-dialog.ai-panel-open {
    max-width: min(1560px, 96vw);
}

/* Compose windows (Comms email/text): the form on the left, the AI rail/chat pane on the right. */
.compose-ai-layout {
    display: flex;
    align-items: stretch;
    min-height: 0;
    width: 100%;
}

.compose-ai-layout > .compose-ai-main {
    flex: 1 1 auto;
    min-width: 0;
}

/* Dashboard Send Email / Send Text modals: body on the left, AI pane on the right inside the modal content. */
.compose-ai-modal-split {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.compose-ai-modal-split > .modal-body {
    flex: 1 1 auto;
    min-width: 0;
}

/* Widen the resizable modals while the pane is open so the form keeps its room. */
#sendTextModal .modal-dialog.modal-window-resizable.send-text-modal-dialog.ai-panel-open,
#sendEmailModal .modal-dialog.modal-window-resizable.send-email-modal-dialog.ai-panel-open {
    width: min(1200px, calc(100vw - 1rem));
}

/* ========================================
   Campaign Performance Dialog (CampaignPerformanceDialog.razor)
   Collapsible per-step performance rows.
   ======================================== */

.step-perf-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.step-perf-item {
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bg-primary);
    overflow: hidden;
}

.step-perf-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}

.step-perf-header:hover {
    background-color: var(--bg-tertiary);
}

.step-perf-caret {
    flex-shrink: 0;
}

.step-perf-template {
    flex: 1 1 auto;
    min-width: 0;
}

.step-perf-counts {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    font-size: 0.85rem;
    white-space: nowrap;
}

.step-perf-body {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Automation Delay Preset Selector
   (AutomationEditDialog.razor — quick-pick pill buttons for delay period)
   ======================================== */

.delay-preset-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.delay-preset-btn {
    padding: 4px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.5;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

.delay-preset-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--bs-primary);
}

.delay-preset-btn.delay-preset-active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: var(--text-light);
    font-weight: 500;
}

/* ========================================
   Message Performance Panel (MessagePerformancePanel.razor)
   Stat tiles + delivery queue grid shared by blast, campaign,
   and automation performance views (also used by BlastDetailDialog).
   ======================================== */

.detail-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bg-secondary);
}

.detail-stat-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.queue-container {
    max-height: 380px;
    overflow-y: auto;
}

.queue-container thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.queue-notes {
    max-width: 260px;
}

/* ========================================
   Campaign Step Card & Send Condition Panel
   (CampaignEditDialog.razor)
   Defined here for production reliability (scoped .razor.css bundles
   are not regenerated reliably in production deployments).
   ======================================== */

.campaign-step-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, var(--bs-border-color));
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    background-color: var(--bg-primary, var(--bs-body-bg));
}

.step-card-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.step-condition-panel {
    border: 1px solid var(--border-color, var(--bs-border-color));
    border-radius: var(--bs-border-radius, 0.375rem);
    overflow: hidden;
    background-color: var(--bg-primary, var(--bs-body-bg));
}

.step-condition-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0.75rem;
    background-color: var(--bg-secondary, var(--bs-secondary-bg));
    border-bottom: 1px solid var(--border-color, var(--bs-border-color));
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, var(--bs-body-color));
}

.step-condition-body {
    padding: 0.625rem 0.75rem;
}

.step-condition-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.step-condition-fields > div {
    min-width: 140px;
}

.step-condition-field-grow {
    flex-grow: 1;
    min-width: 200px !important;
}

.step-add-condition-btn {
    font-size: 0.8rem;
}

/* Agency-level guided letter signing (SigningTab). */
.letter-signing-workflow { max-width: 72rem; margin-inline: auto; color: var(--text-primary); }
.letter-workflow-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.letter-workflow-header p { color: var(--text-secondary); margin-bottom: 0; max-width: 48rem; }
.letter-workflow-header > button { flex-shrink: 0; }
.letter-workflow-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); list-style: none; padding: 0; margin: 0 0 1.25rem; gap: .5rem; }
.letter-workflow-steps > li { display: flex; align-items: center; gap: .6rem; padding: .85rem; border: 1px solid var(--border-color); border-radius: .6rem; background: var(--bg-secondary); color: var(--text-secondary); }
.letter-step-number { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 1px solid var(--border-color); font-weight: 600; }
.letter-workflow-steps > .is-current { border-color: var(--primary-color); color: var(--text-primary); box-shadow: var(--shadow-sm); font-weight: 600; }
.letter-workflow-steps > .is-current .letter-step-number { background: var(--primary-color); color: var(--text-light); }
.letter-workflow-steps > .is-complete .letter-step-number { border-color: var(--primary-color); color: var(--text-primary); }
.letter-workflow-panel { border: 1px solid var(--border-color); border-radius: .75rem; padding: 1.25rem; background: var(--bg-primary); }
.letter-workflow-panel > h6 { margin-bottom: 1rem; }
.letter-workflow-navigation { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1rem; }
.letter-recipient-results { list-style: none; padding: 0; margin: 0 0 1rem; max-height: 25rem; overflow-y: auto; border: 1px solid var(--border-color); border-radius: .5rem; }
.letter-recipient-results > li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; background: var(--bg-primary); border-bottom: 1px solid var(--border-color); }
.letter-recipient-results > li:last-child { border-bottom: 0; }
.letter-recipient-results > li > div { min-width: 0; overflow-wrap: anywhere; }
.letter-recipient-results > li > button { flex-shrink: 0; }
.letter-selected-recipients { display: flex; flex-wrap: wrap; gap: .6rem; list-style: none; padding: 0; }
.letter-selected-recipients > li { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--border-color); border-radius: .5rem; padding: .4rem .6rem; background: var(--bg-tertiary); overflow-wrap: anywhere; }
.letter-document-preview { background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: .5rem; padding: 1rem; margin-block: 1rem; max-height: 48rem; overflow: auto; }
.letter-document-page { max-width: 51rem; margin: 0 auto 1rem; box-shadow: var(--shadow); background: var(--bg-primary); }
.letter-document-page img { display: block; width: 100%; height: auto; }
.letter-document-page figcaption { padding: .4rem; text-align: center; color: var(--text-secondary); background: var(--bg-primary); font-size: .8rem; }
@media (max-width: 640px) {
    .letter-workflow-header { flex-direction: column; }
    .letter-workflow-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .letter-workflow-steps > li { padding: .6rem; font-size: .875rem; }
    .letter-workflow-panel { padding: .8rem; }
    .letter-recipient-results > li { align-items: flex-start; flex-direction: column; gap: .5rem; }
    .letter-document-preview { padding: .5rem; }
}

/* ========================================
   Letters (Marketing) components moved out of their .razor.css files.
   Each rule is prefixed with its component's root class so it keeps the
   specificity the scoped [b-xxxx] attribute used to give it and cannot
   leak into other modules.
   ======================================== */

/* ========================================
   Letters Module Shell & Tab Bar (MarketingModule.razor)
   ======================================== */

.marketing-content-area {
    padding: 16px;
    min-width: 0;
    overflow: hidden;
}

.marketing-content-area .marketing-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    padding-left: 0;
    gap: 0;
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 0;
    margin-bottom: 1rem;
}

.marketing-content-area .marketing-tabs .marketing-tab-item {
    margin-bottom: 0;
}

.marketing-content-area .marketing-tabs .marketing-tab-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none !important;
    border-bottom: 3px solid transparent !important;
    border-radius: 0;
    color: var(--text-secondary) !important;
    background: transparent !important;
    padding: 0.55rem 1rem;
    margin: 0;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none !important;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.marketing-content-area .marketing-tabs .marketing-tab-button i {
    font-size: 1rem;
}

.marketing-content-area .marketing-tabs .marketing-tab-button:hover {
    color: var(--text-primary) !important;
    background-color: var(--bg-tertiary) !important;
    border-bottom-color: var(--text-secondary) !important;
}

.marketing-content-area .marketing-tabs .marketing-tab-button:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.2);
    outline: none;
}

.marketing-content-area .marketing-tabs .marketing-tab-button.active {
    color: var(--bs-primary) !important;
    background-color: var(--bs-body-bg) !important;
    border-bottom-color: var(--bs-primary) !important;
    font-weight: 600;
}

.marketing-content-area .marketing-tab-content {
    min-width: 0;
}

@media (max-width: 991.98px) {
    .marketing-content-area .marketing-tabs .marketing-tab-item {
        flex: 1 1 calc(50% - 0.5rem);
    }

    .marketing-content-area .marketing-tabs .marketing-tab-button {
        width: 100%;
        justify-content: center;
        padding-inline: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .marketing-content-area .marketing-tabs .marketing-tab-item {
        flex-basis: 100%;
    }
}

/* ========================================
   Templates Tab (TemplatesTab.razor)
   Toolbar layout lives in tables.css (.templates-tab .templates-toolbar).
   ======================================== */

.templates-tab .templates-description {
    max-width: 320px;
}

.templates-tab .templates-table th {
    white-space: nowrap;
}

/* ========================================
   List Tabs: One-Time Sends, Campaigns, Automations, Opt-Outs
   (BlastsTab / CampaignsTab / AutomationsTab / OptOutsTab.razor)
   Toolbar grid: count + filters | search | actions.
   ======================================== */

:is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar {
    display: grid;
    grid-template-columns: auto minmax(16rem, 28rem) auto;
    align-items: start;
    gap: 0.75rem 1rem;
}

:is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-left {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.6rem;
    min-width: 0;
}

:is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-center {
    align-self: center;
    justify-self: center;
    width: 100%;
}

:is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-right {
    display: inline-flex;
    align-items: center;
    align-self: center;
    justify-self: end;
    gap: 0.5rem;
    white-space: nowrap;
}

:is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .btn-theme-group {
    flex: 0 0 auto;
}

:is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .btn-theme-group > .btn-theme {
    min-height: 2.35rem;
    white-space: nowrap;
}

.blasts-tab .blasts-search,
.campaigns-tab .campaigns-search,
.automations-tab .automations-search,
.optouts-tab .optouts-search {
    width: min(100%, 28rem);
    max-width: 28rem;
    min-width: 0;
}

.blasts-tab .blasts-status-filter {
    flex: 0 0 auto;
    min-width: 9rem;
    max-width: 150px;
}

@media (max-width: 1199.98px) {
    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-center {
        grid-column: 1 / -1;
        justify-self: center;
        width: 100%;
    }

    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-left {
        flex-wrap: wrap;
    }
}

@media (max-width: 767.98px) {
    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar {
        grid-template-columns: 1fr;
    }

    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-center,
    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-right {
        justify-self: start;
        width: 100%;
    }

    :is(.blasts-tab, .campaigns-tab, .automations-tab, .optouts-tab) .grid-toolbar-right {
        flex-wrap: wrap;
    }

    .blasts-tab .blasts-search,
    .campaigns-tab .campaigns-search,
    .automations-tab .automations-search,
    .optouts-tab .optouts-search {
        width: 100%;
        max-width: none;
    }
}

.campaigns-tab .campaign-description,
.automations-tab .automation-description {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.optouts-tab .optout-reason {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.automations-tab .automation-disabled-row {
    opacity: 0.6;
}

/* Rows are double-clickable (opens performance), so avoid accidental text selection. */
.campaigns-tab .campaign-row,
.automations-tab .automation-row {
    user-select: none;
}

/* ========================================
   Cross Marketing Tab (CrossMarketingTab.razor)
   Resizable grid areas: drag the bottom-right handle to grow/shrink the list.
   ======================================== */

.cross-marketing-tab .data-grid-container {
    resize: vertical;
    overflow: auto;
    height: 50vh;
    min-height: 160px;
}

/* Keep column headers visible while scrolling inside the resized area. */
.cross-marketing-tab .data-grid thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--bs-body-bg);
}

/* ========================================
   Template Editor Dialog (TemplateEditDialog.razor)
   Resizable modal: the content is a fixed-height flex column the user can
   drag-resize, with the form on the left and the AI chat pane on the right.
   ======================================== */

.modal-dialog.template-edit-dialog {
    max-width: min(1140px, 96vw);
    transition: max-width 0.2s ease;
}

.modal-content.template-edit-content {
    resize: both;
    overflow: hidden;
    min-width: 640px;
    min-height: 480px;
    max-width: 96vw;
    max-height: 94vh;
    height: min(860px, 90vh);
    display: flex;
    flex-direction: column;
}

.template-edit-content .template-edit-layout {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}

.template-edit-content .template-form-pane {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
    max-height: none;
    display: flex;
    flex-direction: column;
}

/* Everything above the body editor keeps its natural height... */
.template-edit-content .template-form-pane > * {
    flex: 0 0 auto;
}

/* ...while the body editor grows to fill the pane all the way down to the footer. */
.template-edit-content .template-form-pane > .template-editor-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.template-edit-content .template-body-editor {
    min-height: 160px;
}

.template-edit-content .template-body-textarea {
    resize: vertical;
}

.template-edit-content .template-preview {
    min-height: 200px;
    max-height: 420px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.template-edit-content .template-editor-area .template-body-editor {
    flex: 1 1 auto;
    min-height: 160px;
    overflow-y: auto;
}

.template-edit-content .template-editor-area .template-body-textarea {
    flex: 1 1 auto;
    min-height: 140px;
    resize: none;
}

.template-edit-content .template-editor-area .template-preview {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
}

/* Toolbar buttons for signature and merge field insertion */
.template-edit-content .template-editor-area .d-flex.gap-2 {
    flex-wrap: wrap;
}

.template-edit-content .template-editor-area .d-flex.gap-2 button {
    white-space: nowrap;
}

/* Merge-field dropdown shared by the template editor and the compose dialog. */
:is(.template-edit-content, .blast-compose-content) .merge-field-menu {
    position: absolute;
    right: 0;
    left: auto;
    max-height: 320px;
    overflow-y: auto;
    min-width: 280px;
    z-index: 1070;
}

.template-edit-content .merge-field-menu .dropdown-header {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--bs-gray-700);
    padding: 0.5rem 1rem;
}

.template-edit-content .merge-field-menu .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9375rem;
}

.template-edit-content .merge-field-menu .dropdown-item:hover {
    background-color: var(--bs-light);
}

/* ========================================
   One-Time Send Compose Dialog (BlastComposeDialog.razor)
   Resizable wizard modal: step indicator, then the form pane on the left
   and the AI chat pane on the right.
   ======================================== */

.modal-dialog.blast-compose-dialog {
    max-width: min(1140px, 96vw);
    transition: max-width 0.2s ease;
}

.modal-content.blast-compose-content {
    resize: both;
    overflow: hidden;
    min-width: 640px;
    min-height: 480px;
    max-width: 96vw;
    max-height: 94vh;
    height: min(860px, 90vh);
    display: flex;
    flex-direction: column;
}

.blast-compose-content .compose-layout {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
}

.blast-compose-content .compose-form-pane {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Everything above the editor keeps its natural height... */
.blast-compose-content .compose-form-pane > * {
    flex: 0 0 auto;
}

/* ...while the message editor grows to fill the pane all the way down to the footer. */
.blast-compose-content .compose-form-pane > .compose-editor-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Step 2: the recipient grid grows to fill the pane down to the footer. */
.blast-compose-content .compose-form-pane > .recipient-list-container {
    flex: 1 1 auto;
    min-height: 0;
}

/* Step 3: the schedule/preview cards grow to fill the pane down to the footer. */
.blast-compose-content .compose-form-pane > .compose-review-row {
    flex: 1 1 auto;
    min-height: 0;
}

/* Wizard step indicator */
.blast-compose-content .compose-steps {
    display: flex;
    gap: 8px;
}

.blast-compose-content .compose-step {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
}

.blast-compose-content .compose-step:disabled {
    cursor: default;
    opacity: 0.65;
}

.blast-compose-content .compose-step.active {
    border-color: var(--primary-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
}

.blast-compose-content .compose-step.completed {
    color: var(--text-primary);
}

.blast-compose-content .compose-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.blast-compose-content .compose-step.active .compose-step-number,
.blast-compose-content .compose-step.completed .compose-step-number {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-light);
}

.blast-compose-content .compose-step-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blast-compose-content .marketing-quill-editor {
    min-height: 200px;
}

.blast-compose-content .compose-editor-area .marketing-quill-editor {
    flex: 1 1 auto;
    min-height: 200px;
    overflow-y: auto;
}

.blast-compose-content .compose-editor-area textarea {
    flex: 1 1 auto;
    min-height: 140px;
    resize: none;
}

.blast-compose-content .recipient-list-container {
    max-height: none;
    overflow-y: auto;
}

.blast-compose-content .recipient-list-container thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.blast-compose-content .preview-recipient-select {
    max-width: 220px;
}

.blast-compose-content .preview-body {
    max-height: 420px;
    overflow-y: auto;
}

.blast-compose-content .compose-review-row .preview-body {
    max-height: none;
    min-height: 0;
}

.blast-compose-content .preview-frame {
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    padding: 12px;
    background-color: var(--bg-primary);
}

.blast-compose-content .preview-sms {
    border: 1px solid var(--border-color);
    border-radius: var(--bs-border-radius);
    padding: 12px;
    background-color: var(--bg-tertiary);
    white-space: pre-wrap;
    max-width: 340px;
}

/* ========================================
   Recipient Picker Dialog (BlastRecipientPicker.razor)
   Resizable: drag the bottom-right corner to grow/shrink the dialog;
   the results list flexes to fill whatever height the user chooses.
   ======================================== */

.modal-content.recipient-picker-content {
    resize: both;
    overflow: hidden; /* header/tabs stay pinned; only the results list scrolls */
    display: flex;
    flex-direction: column;
    min-width: 560px;
    min-height: 420px;
    max-width: 95vw;
    max-height: 90vh;
}

.recipient-picker-content .modal-header,
.recipient-picker-content .modal-footer {
    flex-shrink: 0;
}

.recipient-picker-content .modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto; /* fallback scroll for non-list tabs (e.g. Enter Manually) */
    padding-top: 0.5rem; /* tabs sit close under the dialog header */
}

.recipient-picker-content .modal-body .nav-tabs {
    flex-shrink: 0;
}

.recipient-picker-content .recipient-results {
    flex: 1 1 auto;
    max-height: none;
    min-height: 120px;
    overflow-y: auto;
}

.recipient-picker-content .recipient-results thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.recipient-picker-content .recipient-row {
    cursor: pointer;
}

.recipient-picker-content .row-disabled {
    opacity: 0.55;
}

.recipient-picker-content .check-col {
    width: 42px;
    text-align: center;
}

.recipient-picker-content .manual-badge i {
    cursor: pointer;
}

/* ========================================
   One-Time Send Detail Dialog (BlastDetailDialog.razor)
   Summary strip: labeled facts laid out as tidy tiles.
   ======================================== */

.modal-dialog .blast-detail-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 2rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, var(--bs-border-color));
    border-radius: var(--bs-border-radius);
    background-color: var(--bg-tertiary, var(--bs-tertiary-bg));
}

.blast-detail-summary .blast-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 120px;
}

.blast-detail-summary .blast-detail-item-wide {
    flex: 1 1 100%;
}

.blast-detail-summary .blast-detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, var(--bs-secondary-color));
}

.blast-detail-summary .blast-detail-value {
    font-size: 0.9rem;
    color: var(--text-primary, var(--bs-body-color));
}

/* ========================================
   Campaign Editor Dialog (CampaignEditDialog.razor)
   Step list fields and the enrollment grid. The step card and
   send-condition panel styles are defined earlier in this file.
   ======================================== */

.campaign-steps {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 0.5rem;
}

.campaign-steps .campaign-step-day {
    flex-shrink: 0;
    min-width: 4.5rem;
    text-align: center;
    margin-top: 0.2rem;
}

.campaign-steps .campaign-step-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.campaign-steps .campaign-step-fields > div {
    min-width: 110px;
}

.campaign-steps .campaign-step-template {
    flex-grow: 1;
    min-width: 220px;
}

.campaign-steps .campaign-step-remove {
    min-width: auto !important;
}

.campaign-steps .campaign-step-readonly {
    align-items: center;
    gap: 0.75rem;
}

.campaign-steps .form-label-sm {
    font-size: 0.8rem;
}

.modal-dialog .enrollment-status-filter {
    max-width: 160px;
}

.modal-dialog .enrollment-search {
    max-width: 240px;
}

.modal-dialog .enrollment-expand-col {
    width: 42px;
}

.modal-dialog .enrollment-history-row > td {
    background-color: var(--bg-primary, var(--bs-body-bg));
}

.modal-dialog .enrollment-history-table {
    margin-left: 2.5rem;
    width: calc(100% - 2.5rem);
}

/* ========================================
   Automation Editor Dialog (AutomationEditDialog.razor)
   ======================================== */

.modal-dialog .automation-number-input {
    max-width: 160px;
}

.modal-dialog .automation-delay-unit {
    max-width: 120px;
    flex: 0 0 auto;
}
