/* WhatsApp Campaign Manager - minimal, calm interface on top of Bootstrap 5 */
:root {
    --wcm-bg: #f6f7f9;
    --wcm-surface: #ffffff;
    --wcm-border: #e3e6ea;
    --wcm-text: #1f2328;
    --wcm-muted: #667085;
    --wcm-accent: #12805c;
    --wcm-sidebar-width: 232px;
}

body {
    background: var(--wcm-bg);
    color: var(--wcm-text);
    font-size: 0.925rem;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--wcm-sidebar-width);
    flex-shrink: 0;
    background: var(--wcm-surface);
    border-right: 1px solid var(--wcm-border);
    display: flex;
    flex-direction: column;
    padding: 1rem 0.75rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; padding: 0.25rem 0.5rem 1.25rem; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--wcm-accent); color: #fff; font-weight: 700;
}
.brand-mark-lg { width: 44px; height: 44px; font-size: 1.25rem; border-radius: 12px; }
.sidebar .nav-link { color: var(--wcm-text); border-radius: 6px; padding: 0.45rem 0.75rem; margin-bottom: 2px; }
.sidebar .nav-link:hover { background: #f0f2f4; }
.sidebar .nav-link.active { background: #e8f3ee; color: var(--wcm-accent); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 0.75rem 0.5rem 0; border-top: 1px solid var(--wcm-border); }

.main { flex: 1; min-width: 0; }
.content { padding: 1.5rem 2rem 3rem; max-width: 1400px; }
.topbar { display: flex; gap: 1rem; align-items: center; padding: 0.75rem 1rem; background: var(--wcm-surface); border-bottom: 1px solid var(--wcm-border); }

.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.35rem; margin: 0; font-weight: 600; }
.page-header .subtitle { color: var(--wcm-muted); margin: 0.15rem 0 0; }

.card { border-color: var(--wcm-border); box-shadow: none; }
.card-header { background: var(--wcm-surface); font-weight: 600; border-color: var(--wcm-border); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.metric { background: var(--wcm-surface); border: 1px solid var(--wcm-border); border-radius: 8px; padding: 0.85rem 1rem; }
.metric .label { color: var(--wcm-muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.metric .value { font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
.metric .hint { color: var(--wcm-muted); font-size: 0.75rem; margin-top: 0.2rem; }
.metric.metric-good .value { color: #157347; }
.metric.metric-bad .value { color: #b42318; }
.metric.metric-warn .value { color: #b54708; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 0.55rem 0.75rem; }
.table thead th { color: var(--wcm-muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; border-bottom-color: var(--wcm-border); white-space: nowrap; }
.table-card { background: var(--wcm-surface); border: 1px solid var(--wcm-border); border-radius: 8px; overflow: hidden; }
.table-card .table-responsive { margin: 0; }
.table-card-footer { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.75rem; border-top: 1px solid var(--wcm-border); color: var(--wcm-muted); font-size: 0.85rem; flex-wrap: wrap; gap: 0.5rem; }

.status-badge { font-weight: 500; font-size: 0.75rem; }
.text-bg-light { border: 1px solid var(--wcm-border); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
.nowrap { white-space: nowrap; }

.filters { background: var(--wcm-surface); border: 1px solid var(--wcm-border); border-radius: 8px; padding: 0.75rem; margin-bottom: 1rem; }

.dropzone {
    border: 2px dashed #c6ccd3; border-radius: 10px; padding: 2.5rem 1rem; text-align: center;
    background: #fbfcfd; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--wcm-accent); background: #eef7f2; }
.dropzone .file-name { font-weight: 600; margin-top: 0.5rem; }

.preview-bubble {
    background: #e7fbe5; border: 1px solid #c9ecc6; border-radius: 10px 10px 10px 2px;
    padding: 0.75rem 0.9rem; white-space: pre-wrap; max-width: 520px;
}
.progress { height: 10px; background: #edf0f3; }
.summary-list { list-style: none; padding: 0; margin: 0; }
.summary-list li { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid #f0f2f4; }
.summary-list li:last-child { border-bottom: 0; }
.summary-list .count { font-weight: 600; }

.variable-row { background: #fafbfc; border: 1px solid var(--wcm-border); border-radius: 8px; padding: 0.6rem; margin-bottom: 0.5rem; }
.danger-zone { border-color: #f1c2be; }
.narrow-page { max-width: 640px; }
.mapping-table td, .mapping-table th { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.guest-card { width: 100%; max-width: 380px; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; z-index: 1040; left: 0; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 0 30px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 1rem; }
}

/* ---- Users page ---------------------------------------------------------------------- */
.user-password-input { width: 9.5rem; }

/* ---- Customer-care inbox ------------------------------------------------------------- */
.inbox-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.inbox-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 1rem; background: var(--wcm-surface); border-bottom: 1px solid var(--wcm-border); flex-shrink: 0; }
.inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 360px) 1fr; }
.inbox-list { display: flex; flex-direction: column; min-height: 0; background: var(--wcm-surface); border-right: 1px solid var(--wcm-border); }
.inbox-list-head { padding: 0.75rem; border-bottom: 1px solid var(--wcm-border); }
.inbox-filters { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.5rem; }
.inbox-filter { border: 1px solid var(--wcm-border); background: #fff; border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.8rem; color: var(--wcm-text); }
.inbox-filter.active { background: #e8f3ee; border-color: #b7dcc9; color: var(--wcm-accent); font-weight: 600; }
.inbox-filter .count:not(:empty)::before { content: "· "; }
.inbox-list-status { padding: 0.75rem; color: var(--wcm-muted); }
.inbox-list-status[hidden] { display: none; }
.inbox-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.inbox-item { border-bottom: 1px solid #f0f2f4; }
.inbox-item-btn { font: inherit; display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 0.6rem 0.85rem; color: inherit; }
.inbox-item-btn:hover { background: #f6f8f7; }
.inbox-item.active .inbox-item-btn { background: #e8f3ee; }
.inbox-item.lead .inbox-item-btn { box-shadow: inset 3px 0 0 #f0ad00; }
.item-top, .item-bottom { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.item-name { font-size: 0.92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item.unread .item-name, .inbox-item.unread .item-preview { font-weight: 700; color: var(--wcm-text); }
.item-time { color: var(--wcm-muted); font-size: 0.75rem; flex-shrink: 0; }
.item-phone { color: var(--wcm-muted); font-size: 0.75rem; }
.item-preview { color: var(--wcm-muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-tags { display: flex; gap: 0.25rem; margin-top: 0.3rem; }
.item-tags .badge, .thread-badges .badge { font-weight: 500; font-size: 0.7rem; }

.inbox-thread, .inbox-empty { min-height: 0; display: flex; flex-direction: column; background: #efeae2; }
.inbox-thread[hidden], .inbox-empty[hidden] { display: none; }
.inbox-empty { align-items: center; justify-content: center; }
.thread-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; padding: 0.6rem 1rem; background: var(--wcm-surface); border-bottom: 1px solid var(--wcm-border); }
.thread-title { min-width: 0; margin-right: auto; }
.thread-badges { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.thread-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.thread-actions [hidden] { display: none; }
.thread-details { background: var(--wcm-surface); border-bottom: 1px solid var(--wcm-border); padding: 0.75rem 1rem; }
.thread-details[hidden] { display: none; }
.details-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin-bottom: 0.6rem; }
.details-grid dt { color: var(--wcm-muted); font-weight: 400; }
.details-grid dd { margin: 0; }
.thread-messages { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
.thread-loading { text-align: center; padding: 2rem 0; }
.thread-error[hidden] { display: none; }
.day-divider { align-self: center; background: rgba(255, 255, 255, 0.85); color: var(--wcm-muted); font-size: 0.72rem; border-radius: 6px; padding: 0.1rem 0.6rem; margin: 0.5rem 0; }
.msg { display: flex; }
.msg-in { justify-content: flex-start; }
.msg-out { justify-content: flex-end; }
.msg-bubble { max-width: min(75%, 560px); padding: 0.4rem 0.65rem 0.3rem; border-radius: 8px; background: #fff; box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.12); }
.msg-out .msg-bubble { background: #d9fdd3; }
.msg-intent-lead .msg-bubble { box-shadow: 0 0 0 2px #f0ad00; }
.msg-failed .msg-bubble { background: #fde8e8; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-button { font-size: 0.8rem; color: var(--wcm-accent); font-weight: 600; margin-bottom: 0.15rem; }
.msg-media { display: block; font-size: 0.82rem; }
.msg-tag { font-size: 0.65rem; font-weight: 500; margin-top: 0.2rem; }
.msg-meta { display: flex; justify-content: flex-end; gap: 0.5rem; font-size: 0.68rem; color: var(--wcm-muted); margin-top: 0.15rem; }
.msg-status.status-read { color: #027eb5; }
.msg-status.status-failed, .msg-status.status-undelivered, .msg-status.status-rejected { color: #b42318; font-weight: 600; }
.msg-status.status-uncertain { color: #b54708; font-weight: 600; }
.msg-error { font-size: 0.72rem; color: #b42318; margin-top: 0.15rem; }
.thread-compose { background: #f0f2f5; padding: 0.6rem 1rem 0.5rem; border-top: 1px solid var(--wcm-border); }
.compose-window[hidden] { display: none; }
.compose-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.compose-row textarea { resize: none; max-height: 9rem; }
.compose-meta { margin-top: 0.2rem; }

@media (max-width: 767.98px) {
    .inbox { grid-template-columns: 1fr; }
    .inbox.show-thread .inbox-list { display: none; }
    .inbox:not(.show-thread) .inbox-thread, .inbox:not(.show-thread) .inbox-empty { display: none; }
    .msg-bubble { max-width: 88%; }
}
