/**
 * Broadcasts Page Styling
 * Three-column layout for broadcast messaging
 * Complements global app.css
 */

/* ==========================================================================
   BROADCAST LAYOUT
   ========================================================================== */
/* Height comes from the hub flex column in app.css. */
#broadcast-hub-content {
    display: flex;
    flex-direction: column;
}

.broadcast-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
}

/* ==========================================================================
   GUEST SELECTION PANEL (LEFT)
   ========================================================================== */
/* Guest selection panel (left) */
.guest-selection-panel {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
    background: white;
    border-right: 1px solid var(--hub-border);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* --------------------------------------------------------------------------
   STEP 1 — AUDIENCE PICKER (design 1b)
   Stage dropdown + date-range button, then search. The old wrapping chip rows
   took three lines and pushed the list below the fold.
   -------------------------------------------------------------------------- */
.audience-picker {
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--hub-border-soft);
    background: white;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.audience-controls {
    display: flex;
    gap: 0.5rem;
    position: relative;
}

.audience-pill-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.375rem;
    border: 1px solid var(--hub-line);
    border-radius: var(--hub-radius);
    background: #fff;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audience-pill-btn:focus-visible {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--hub-tint);
}

.audience-pill-label {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audience-pill-btn > .bi-chevron-down {
    font-size: 0.625rem;
    color: var(--hub-faint);
    flex: none;
}

.audience-pill-btn.filtered,
.audience-pill-btn.open {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--hub-tint);
}

.audience-pill-btn.filtered > .bi-chevron-down,
.audience-pill-btn.open > .bi-chevron-down {
    color: var(--primary-color);
}

/* Stage picker — multi-select, the same OR semantics the chip row had */
.audience-stage-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 6px;
    padding: 0.4375rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    text-align: left;
}

.audience-stage-all:hover {
    background: var(--hub-fill);
}

.audience-stage-all.active {
    background: var(--hub-tint);
    color: var(--primary-color);
    font-weight: 600;
}

.audience-stage-list {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--hub-border-soft);
}

.audience-stage-opt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 6px;
    padding: 0.4375rem 0.5rem;
    margin: 0;
    font-size: 0.8125rem;
    color: #374151;
    cursor: pointer;
}

.audience-stage-opt:hover {
    background: var(--hub-fill);
}

.audience-stage-opt .form-check-input {
    margin: 0;
    width: 15px;
    height: 15px;
    flex: none;
}

.audience-stage-opt > span:first-of-type {
    flex: 1;
    min-width: 0;
}

.audience-stage-opt .group-count {
    background: rgba(13, 110, 253, 0.12);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.71875rem;
}

/* Still hidden before the first count arrives — an empty span means "not
   loaded yet", where a zero means "nobody is in this stage". */
.audience-stage-opt .group-count:empty {
    display: none;
}

.audience-stage-opt .group-count.is-zero {
    background: transparent;
    color: var(--hub-faint);
    font-weight: 500;
}

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

.audience-dates-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--hub-muted);
}

.audience-summary {
    font-size: 0.6875rem;
    color: var(--hub-muted);
}

.audience-summary:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   GUEST LIST
   -------------------------------------------------------------------------- */
.guest-list-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--hub-border-soft);
    font-size: 0.75rem;
}

.guest-list-selectall {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
    cursor: pointer;
}

.guest-list-selectall .form-check-input {
    margin: 0;
    width: 15px;
    height: 15px;
}

.guest-list-clear {
    border: 0;
    background: transparent;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0;
}

.guest-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.guest-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6875rem;
    padding: 0.6875rem 1rem;
    border-bottom: 1px solid #f6f7f8;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.guest-item:hover {
    background-color: #f8f9fa;
}

.guest-item.selected {
    background-color: var(--hub-row-active);
}

.guest-item-body {
    min-width: 0;
    flex: 1;
}

.guest-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.guest-item-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--hub-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.guest-item-top .stage-pill {
    flex: none;
}

.guest-item-meta {
    font-size: 0.75rem;
    color: var(--hub-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.0625rem;
}

.guest-checkbox {
    width: 15px;
    height: 15px;
    margin-top: 0.125rem;
    flex: none;
    cursor: pointer;
}

/* ==========================================================================
   MESSAGE COMPOSER PANEL (CENTER)
   ========================================================================== */
/* Message composer panel (center) */
.message-composer-panel {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Step 2 header: "Send · To: [chips]" (design 1b) */
.recipients-preview {
    padding: 0.75rem 1.25rem;
    background: white;
    border: none !important;
    border-bottom: 1px solid var(--hub-border) !important;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 52px;
}

.recipients-to {
    font-size: 0.75rem;
    color: var(--hub-muted);
    margin-left: 0.25rem;
}

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

.recipients-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    min-width: 0;
}

.recipients-more {
    border: 0;
    background: transparent;
    color: var(--primary-color);
    font-size: 0.71875rem;
    font-weight: 600;
    padding: 0;
}

.broadcast-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    /* Light grey background to match messages area */
    background-color: var(--hub-canvas);
    border: none !important;
    outline: none !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* When broadcasts exist, align to top */
.broadcast-history:has(.broadcast-bubble) {
    justify-content: flex-start;
}

.broadcast-bubble {
    max-width: 70%;
    margin-bottom: 15px;
    padding: 14px 18px;
    border-radius: 18px;
    background: #0d6efd;
    color: white;
    margin-left: auto;
    word-wrap: break-word;
    transition: all 0.2s ease;
}

/* Clickable broadcast bubbles */
.broadcast-bubble.clickable {
    cursor: pointer;
}

.broadcast-bubble.clickable:hover {
    background: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.broadcast-bubble.clickable:active {
    transform: translateY(0);
}

/* Broadcast message content */
.broadcast-message {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

/* Broadcast footer with time and recipients */
.broadcast-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    opacity: 0.9;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.broadcast-time {
    display: flex;
    align-items: center;
}

.broadcast-recipients {
    display: flex;
    align-items: center;
    font-weight: 500;
}

/* Legacy broadcast-meta for backward compatibility */
.broadcast-meta {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 5px;
}

/* Composer: one bordered box, hint + counter + Send in its own footer bar */
.message-compose-area {
    padding: 0.875rem 1.25rem 1rem;
    border: none !important;
    border-top: 1px solid var(--hub-border) !important;
    margin-top: 0;
    background: white;
}

.message-input-wrapper {
    border: 1px solid var(--hub-line);
    border-radius: 0.625rem;
    overflow: hidden;
}

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

.message-input {
    display: block;
    width: 100%;
    min-height: 52px;
    max-height: 140px;
    padding: 0.75rem 0.875rem;
    border: 0;
    border-radius: 0;
    resize: none;
    overflow-y: auto;
    font-size: 0.8125rem;
}

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

.message-compose-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-top: 1px solid var(--hub-border-soft);
}

.message-compose-hint {
    font-size: 0.71875rem;
    color: var(--hub-faint);
}

.send-broadcast-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-radius: var(--hub-radius);
    font-weight: 600;
    font-size: 0.78125rem;
    white-space: nowrap;
}

/* ==========================================================================
   BROADCAST INFO PANEL (RIGHT) - REMOVED FOR CLEANER UI
   ========================================================================== */

/* ==========================================================================
   SELECTION COUNTER & EMPTY STATE
   ========================================================================== */
/* Selection footer (design 1b) — sits under the list, not above it */
.selection-counter {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--hub-border);
    background: #fff;
    font-size: 0.75rem;
    color: var(--hub-muted);
}

.selection-counter.has-selection #selection-counter-text {
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--primary-color);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    /* Override global dashed border from app.css */
    border: none !important;
    background: transparent !important;
    margin: 0 !important;
}

.empty-state i {
    font-size: 4rem;  /* Increased for better visibility */
    opacity: 0.3;     /* More subtle appearance */
    color: #6c757d;
}

.empty-state h5 {
    color: #6c757d;
}

.empty-state p {
    color: #6c757d;
    opacity: 0.8;
}

/* ==========================================================================
   DATE SEPARATORS
   ========================================================================== */
/* Date separator styling (matching messages.css) */
.date-separator {
    position: relative;
    margin: 20px 0;
    text-align: center;
}

.date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #dee2e6;
    z-index: 0;
}

.date-separator .badge {
    position: relative;
    z-index: 1;
    background: #e9ecef;
    color: #495057;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 8px 20px;
}
