/* ============================================================
   console.css — Console-specific components
   Requires: moonshot.css (design system base)
   ============================================================ */


/* ── Console Shell (body layout — sidebar + main) ────────────── */

.console-shell {
	display: flex;
	height: 100vh;
	overflow: hidden;
}
.console-shell > main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.console-shell > main > .content-body {
	flex: 1;
	overflow-y: auto;
}

/* ── Service Rail (vertical icon strip — console 2-column sidebar) ── */

.service-rail__item {
	width: 100%; height: 50px;
	display: flex; align-items: center; justify-content: center;
	border-radius: 0; color: var(--text-muted);
	text-decoration: none; position: relative;
	transition: background 150ms, color 150ms;
	border-left: 3px solid transparent;
	border-bottom: 1px solid var(--border);
}
.service-rail__item:hover { background: var(--surface-hover); color: var(--text); }
.service-rail__item--active {
	color: var(--service-color, var(--accent));
	background: color-mix(in srgb, var(--service-color, var(--accent)) 12%, transparent);
	border-left-color: var(--service-color, var(--accent));
}
.service-rail__icon { width: 22px; height: 22px; }
.service-rail__tooltip {
	display: none; position: absolute;
	left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
	background: var(--text); color: var(--bg);
	padding: 4px 8px; border-radius: var(--radius-sm);
	font-size: 0.6875rem; white-space: nowrap;
	z-index: var(--z-modal); pointer-events: none;
}
.service-rail__item:hover .service-rail__tooltip { display: block; }

/* ── Sidebar (console: 2-col — icon rail + nav) ───────────── */

.sidebar {
	width: calc(56px + 244px); flex-shrink: 0;
	background: var(--surface); border-right: 1px solid var(--border);
	display: flex; flex-direction: column;
	position: sticky; top: 0; height: 100vh;
	overflow: hidden; z-index: var(--z-sidebar);
}
.sidebar__logo {
	display: inline-flex; align-items: center; justify-content: center;
	text-decoration: none; margin-top: 4px;
}
.sidebar__logo img { height: 48px; width: auto; max-width: none; }
.sidebar__body { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.sidebar__body > aside {
	width: 56px; flex-shrink: 0; overflow-y: auto;
	border-right: 1px solid var(--border);
	display: flex; flex-direction: column; align-items: stretch;
	gap: 0; margin: 0; padding: 0;
}
.sidebar__body > nav {
	flex: 1; display: flex; flex-direction: column;
	overflow-y: auto; min-width: 0; margin: 0; padding: 0;
}
.sidebar > .sidebar__footer {
	flex-shrink: 0; padding: 12px;
	border-top: 1px solid var(--border);
	display: flex; flex-direction: column; gap: 8px;
}

/* Reset list styling inside sidebar */
.sidebar nav ul { margin: 0; padding: 0; list-style: none; }
.sidebar nav li { display: flex; padding: 0; margin: 0; }
.sidebar nav a { padding: 0; margin: 0; }
#nav-content { flex: 1; overflow-y: auto; min-height: 0; }
.sidebar .nav__brand a { display: inline-flex; align-items: center; text-decoration: none; }
.sidebar .nav__brand img { height: 24px; width: auto; }

/* Service header inside nav */
.sidebar .nav__service-header {
	display: flex; align-items: center; gap: 8px;
	height: 50px; padding: 0 16px;
	border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar .nav__service-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sidebar .nav__service-name { font-weight: 600; font-size: 0.8125rem; color: var(--text); }

/* Nav menu items */
.sidebar .nav__menu {
	list-style: none; padding: 0 8px; margin: 0;
	flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 4px;
}
.sidebar .nav__item { margin: 0; width: 100%; }
.sidebar .nav__section-label {
	display: block; width: 100%; text-align: left;
	font-size: 10px; font-weight: 600; text-transform: uppercase;
	letter-spacing: 0.06em; color: var(--text-muted);
	padding: 16px 10px 6px; list-style: none;
}
.sidebar .nav__link {
	display: flex; flex: 1; align-items: center; gap: 10px;
	padding: 10px; font-size: 0.8125rem; color: var(--nav-text);
	text-decoration: none; border-radius: var(--radius);
	transition: background 150ms, color 150ms;
}
.sidebar .nav__link:hover { background: var(--nav-hover-bg); color: var(--nav-text-hover); }
.sidebar .nav__link--active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 600; }
.sidebar .nav__icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Mobile service rail inside nav overlay */
.sidebar .nav__rail-mobile { display: none; }

/* ── Content Header (Org & Cost Center selectors) ──────────── */

.content-header {
	height: 50px; background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky; top: 0; z-index: var(--z-sticky);
}
.content-header__inner {
	display: flex; align-items: center; justify-content: flex-end;
	gap: 1.5rem; padding: 0 2rem; height: 100%; font-size: 0.8125rem;
}
.content-header__group {
	display: flex; align-items: center; gap: 0.375rem; margin: 0;
}
.content-header__group label {
	font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
	letter-spacing: 0.04em; color: var(--text-muted); margin: 0; white-space: nowrap;
}
.content-header__group select {
	padding: 0.25rem 2rem 0.25rem 0.5rem;
	font-size: 0.8125rem; font-weight: 500; margin: 0;
	border: 1px solid var(--border); border-radius: var(--radius);
	color: var(--text); cursor: pointer; line-height: 1.4;
}
.content-header__group span { font-weight: 500; color: var(--text); opacity: 0.85; }

/* ── Preferences Menu (gear dropdown) ─────────────────────── */

.preferences-menu { position: relative; margin-left: auto; }
.preferences-menu__trigger {
	display: flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; padding: 0; margin: 0;
	background: transparent; border: 1px solid transparent;
	border-radius: var(--radius); color: var(--text-muted);
	cursor: pointer; transition: color 150ms, border-color 150ms;
}
.preferences-menu__trigger:hover { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.preferences-menu--open .preferences-menu__trigger {
	color: var(--text); border-color: var(--border); background: var(--surface-2);
}
.preferences-menu__dropdown {
	display: none; position: absolute; top: calc(100% + 6px); right: 0;
	min-width: 200px; padding: 12px;
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.12);
	z-index: var(--z-overlay);
}
.preferences-menu--open .preferences-menu__dropdown { display: block; }
.preferences-menu__section { margin-bottom: 10px; }
.preferences-menu__section:last-child { margin-bottom: 0; }
.preferences-menu__divider { height: 1px; background: var(--border); margin: 10px -12px; }
.preferences-menu__logout {
	display: flex; align-items: center; gap: 6px;
	width: 100%; padding: 6px 8px; margin: 0;
	background: none; border: 1px solid transparent;
	border-radius: var(--radius); color: var(--text-muted);
	font-size: 0.75rem; font-weight: 500; cursor: pointer;
	transition: color 150ms, background 150ms;
}
.preferences-menu__logout:hover { color: var(--error); background: var(--error-bg); }
.preferences-menu__label {
	display: block; font-size: 0.625rem; font-weight: 600;
	text-transform: uppercase; letter-spacing: 0.05em;
	color: var(--text-muted); margin-bottom: 6px;
}

/* ── Auth Page Preferences (lang + theme toggles) ────────── */

.auth-prefs { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.auth-prefs__group {
	display: flex; gap: 2px; background: var(--surface-2);
	border-radius: var(--radius); padding: 2px;
}
.auth-prefs__btn {
	display: flex; align-items: center; justify-content: center; gap: 4px;
	padding: 5px 10px; font-size: 0.6875rem; text-decoration: none;
	color: var(--text-muted); border-radius: calc(var(--radius) - 2px);
	transition: background 150ms;
}
.auth-prefs__btn:hover { background: var(--surface-hover); }
.auth-prefs__btn--active { background: var(--surface); color: var(--text); font-weight: 500; }
.auth-prefs__icon { width: 14px; height: 14px; }

/* ── Content Body ─────────────────────────────────────────── */

.content-body { padding: 1.5rem 2rem; width: 100%; max-width: 1480px; margin: 0 auto; }

/* ── Toast Notifications ──────────────────────────────────── */

.toast {
	position: fixed; bottom: 20px; right: 20px;
	padding: 12px 20px; border-radius: var(--radius);
	font-size: 0.8125rem; font-weight: 500; color: #fff; background: #333;
	z-index: var(--z-toast); opacity: 0; transform: translateY(10px);
	transition: opacity 300ms, transform 300ms; max-width: 400px;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--success { background: #16a34a; }
.toast--error { background: #dc2626; }
.toast--info { background: #2563eb; }

/* ── Status Badges (campaign states) ──────────────────────── */

.status-badge {
	display: inline-flex; align-items: center;
	padding: 2px 10px; border-radius: var(--radius-full);
	font-size: 0.75rem; font-weight: 600;
	letter-spacing: 0.03em; text-transform: uppercase;
}
.status-badge--draft { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.status-badge--sending { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.status-badge--sent, .status-badge--completed { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.status-badge--failed { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.status-badge--scheduled { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.status-badge--cancelled { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); text-decoration: line-through; }
.status-badge--empty { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Trace Timeline ───────────────────────────────────────── */

.trace-timeline { position: relative; padding: 0; }
.trace-timeline__item { position: relative; display: flex; gap: 16px; padding-bottom: 0; min-height: 56px; }
.trace-timeline__item:last-child { min-height: auto; }
.trace-timeline__rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 32px; }
.trace-timeline__dot {
	width: 12px; height: 12px; border-radius: 50%;
	border: 2px solid var(--border); background: var(--surface);
	flex-shrink: 0; margin-top: 4px; z-index: 1;
}
.trace-timeline__line { flex: 1; width: 2px; background: var(--border); margin-top: 4px; }
.trace-timeline__item:last-child .trace-timeline__line { display: none; }
.trace-timeline__dot--scheduled { background: var(--info); border-color: var(--info); }
.trace-timeline__dot--queued { background: var(--border); }
.trace-timeline__dot--accepted { background: var(--success-bg); border-color: var(--success); }
.trace-timeline__dot--delivered { background: var(--success); border-color: var(--success); }
.trace-timeline__dot--opened,
.trace-timeline__dot--clicked { background: var(--accent); border-color: var(--accent); }
.trace-timeline__dot--failed { background: var(--error); border-color: var(--error); }
.trace-timeline__content { flex: 1; padding-bottom: 20px; min-width: 0; }
.trace-timeline__item:last-child .trace-timeline__content { padding-bottom: 0; }
.trace-timeline__header { display: flex; align-items: center; gap: 10px; }
.trace-timeline__time { font-size: 0.75rem; color: var(--text-muted); }
.trace-timeline__error {
	margin: 6px 0 0; padding: 8px 12px; font-size: 0.8125rem;
	color: var(--error); background: var(--error-bg);
	border-radius: var(--radius); border-left: 3px solid var(--error);
}

/* ── Trace Detail Card ────────────────────────────────────── */

.trace-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; padding: 16px 20px; }
.trace-detail__item small {
	display: block; font-size: 0.6875rem; font-weight: 600;
	text-transform: uppercase; letter-spacing: 0.04em;
	color: var(--text-muted); margin-bottom: 4px;
}
.trace-detail__item div { font-size: 0.875rem; font-weight: 500; }

/* ── Empty State ──────────────────────────────────────────── */

.empty-state {
	display: flex; flex-direction: column; align-items: center;
	justify-content: center; padding: 72px 24px; text-align: center; gap: 16px;
}
.empty-state svg { width: 64px; height: 64px; color: var(--text-subtle); opacity: 0.5; }
.empty-state p { font-size: 0.875rem; color: var(--text-muted); margin: 0; }
.empty-state--sm { padding: 32px 24px; }

/* ── Campaign Stats Grid ──────────────────────────────────── */

.campaign-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 1px; padding: 16px; }
.campaign-stats__item { text-align: center; padding: 12px 8px; }
.campaign-stats__value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.campaign-stats__value--success { color: var(--success); }
.campaign-stats__value--warning { color: var(--warning); }
.campaign-stats__value--danger { color: var(--error); }
.campaign-stats__value--info, .campaign-stats__value--accent { color: var(--accent); }
.campaign-stats__label {
	font-size: 0.6875rem; font-weight: 500; color: var(--text-muted);
	text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px;
}

/* ── Detail List (dl grid) ────────────────────────────────── */

dl.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 0.8125rem; margin: 0; }
dl.detail-list dt { color: var(--text-muted); font-weight: 500; }
dl.detail-list dd { margin: 0; overflow-wrap: break-word; min-width: 0; }
dialog .detail-list { margin: 0; font-size: 0.8125rem; }
dialog .detail-list dt { font-weight: 500; color: var(--text-muted); font-size: 0.75rem; }
dialog .detail-list dd { margin: 0 0 8px; }

/* ── Code Pill / Block ────────────────────────────────────── */

.code-pill {
	display: inline-block; padding: 2px 8px;
	background: var(--surface-2); border: 1px solid var(--border);
	border-radius: var(--radius); font-family: var(--font-mono);
	font-size: 0.6875rem; color: var(--accent); word-break: break-all;
}
.code-block {
	background: var(--surface-2); border: 1px solid var(--border);
	border-radius: var(--radius); padding: 12px 16px; margin: 0;
	overflow-x: auto; font-size: 0.75rem; line-height: 1.5;
}
.code-block code { background: none; border: none; padding: 0; font-size: inherit; color: var(--text); }

/* ── HTML Preview (iframe) ────────────────────────────────── */

.html-preview { background: #fff; border-radius: var(--radius); min-height: 120px; overflow: hidden; }
.html-preview iframe { width: 100%; min-height: 500px; border: none; display: block; background: #fff; }

/* ── File Upload Zone ─────────────────────────────────────── */

.file-upload-zone {
	position: relative; border: 2px dashed var(--border);
	border-radius: var(--radius); padding: 32px 24px;
	text-align: center; cursor: pointer;
	transition: border-color 150ms, background 150ms;
}
.file-upload-zone:hover, .file-upload-zone--dragover { border-color: var(--accent); background: var(--accent-muted); }
.file-upload-zone--success { border: none !important; padding: 0 !important; cursor: default !important; background: transparent !important; }
.file-upload-label { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; }
.file-upload-icon { width: 40px; height: 40px; color: var(--text-muted); }
.file-upload-zone:hover .file-upload-icon { color: var(--accent); }
.file-upload-cta { font-size: 0.875rem; font-weight: 600; }
.file-upload-sub { font-size: 0.75rem; color: var(--text-muted); }
.file-upload-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-status { margin-top: 12px; padding: 8px 14px; border-radius: var(--radius); font-size: 0.8125rem; font-weight: 500; }

/* ── Progress Bar ─────────────────────────────────────────── */

.progress-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.progress-row__label { flex: 0 0 100px; font-size: 0.8125rem; color: var(--text-muted); }
.progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar__fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.progress-bar__fill--primary { background: var(--accent); }
.progress-bar__fill--success { background: var(--success); }
.progress-bar__fill--info { background: var(--info); }
.progress-bar__fill--danger { background: var(--error); }
.progress-row__pct { flex: 0 0 40px; text-align: right; font-size: 0.8125rem; font-weight: 500; }

/* ── Wizard Progress (stepper) ────────────────────────────── */

.wizard-progress {
	display: flex; align-items: center; justify-content: center; gap: 0;
	margin-bottom: 2rem; padding: 0; counter-reset: step;
}
.wizard-progress__step {
	display: flex; align-items: center; gap: 8px;
	padding: 12px 24px; font-size: 0.8125rem; font-weight: 500;
	color: var(--text-muted); text-decoration: none;
	border-bottom: 2px solid var(--border);
	transition: color 150ms, border-color 150ms;
}
.wizard-progress__step--active { color: var(--accent); border-bottom-color: var(--accent); }
.wizard-progress__step--done { color: var(--success); border-bottom-color: var(--success); }
.wizard-progress__number {
	width: 24px; height: 24px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	font-size: 0.75rem; font-weight: 600;
	background: var(--surface-2); border: 1px solid var(--border);
}
.wizard-progress__step--active .wizard-progress__number { background: var(--accent-muted); border-color: var(--accent); color: var(--accent); }
.wizard-progress__step--done .wizard-progress__number { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.wizard-progress__check { width: 14px; height: 14px; }
.wizard-progress__label { white-space: nowrap; }

/* ── Filter Bar ───────────────────────────────────────────── */

.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; margin-bottom: 1rem; }
.filter-bar select,
.filter-bar input,
.filter-bar button,
.filter-bar [role="button"] {
	width: auto; margin-bottom: 0;
	height: 2.125rem; padding: 0 12px;
	font-size: 0.8125rem; line-height: 2.125rem; box-sizing: border-box;
}
.filter-bar select { min-width: 140px; padding-right: 32px; }
.filter-bar input[type="date"] { min-width: 130px; }
.filter-bar .count { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.filter-bar__field { display: flex; flex-direction: column; gap: 2px; margin-bottom: 0; }
.filter-bar__field span {
	font-size: 0.6875rem; font-weight: 500; text-transform: uppercase;
	letter-spacing: 0.04em; color: var(--text-muted);
}
.filter-bar__field input { margin-bottom: 0; }

/* ── Table Cards (figure wrapper) ─────────────────────────── */

main figure {
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); overflow: hidden; margin: 0 0 1.5rem; padding: 6px;
}
main figure table { margin-bottom: 0; border-collapse: separate; border-spacing: 0; }
main figure table thead th {
	background: var(--surface-2); border-bottom: 2px solid var(--border);
	font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
	letter-spacing: 0.04em; color: var(--text-muted);
}
main figure table td a { text-decoration: none; color: var(--text); font-weight: 500; }
main figure table td a:hover { color: var(--accent); }
main figure table tbody tr:last-child td { border-bottom: none; }

/* ── Access Panel ─────────────────────────────────────────── */

.access-panel {
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); overflow: hidden; margin-top: 1.5rem;
}
.access-panel__header {
	display: flex; justify-content: space-between; align-items: center;
	padding: 12px 16px; background: var(--surface-2);
	border-bottom: 1px solid var(--border);
}
.access-panel__title { font-weight: 600; font-size: 1rem; margin: 0; }
.access-panel__subtitle { font-size: 0.75rem; color: var(--text-muted); margin: 0; }
.access-panel table { margin: 0; }
.access-panel table thead th {
	background: color-mix(in srgb, var(--surface-2) 50%, transparent);
	border-bottom-width: 1px; font-size: 0.6875rem; font-weight: 500; color: var(--text-muted);
}
.access-panel table td { font-size: 0.8125rem; }
.access-panel table td a { text-decoration: none; color: var(--text); font-weight: 500; }
.access-panel table td a:hover { color: var(--accent); }
.access-panel table tbody tr:last-child td { border-bottom: none; }
.access-panel__empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 0.8125rem; }
.access-panel .pagination {
	margin: 0; padding: 10px 16px;
	border-top: 1px solid var(--border);
	background: color-mix(in srgb, var(--surface-2) 50%, transparent);
	font-size: 0.75rem;
}
.access-panel .filter-bar { padding: 12px 16px; margin-bottom: 0; border-bottom: 1px solid var(--border); }
.access-panel table td form { display: inline; margin: 0; }
.access-panel table td button,
.access-panel table td [role="button"] { vertical-align: middle; }
.access-panel form button[type="submit"],
.access-panel form .btn { width: auto; }

/* ── Form Helpers ─────────────────────────────────────────── */

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.5rem; }
.form-actions button,
.form-actions [role="button"] { width: auto; min-width: 140px; text-align: center; margin-bottom: 0; }

.form-group { display: flex; flex-direction: column; gap: 0; }
.form-group label { font-size: 0.8125rem; font-weight: 500; margin-bottom: 6px; }
.form-group label span { font-weight: 400; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea { margin-bottom: 4px; }
.form-group small { display: block; font-size: 0.75rem; line-height: 1.4; color: var(--text-muted); margin: 0; }

/* Button margin reset in panels/tables */
.access-panel button, .access-panel [role="button"],
.page-header button, .page-header [role="button"],
td button, td [role="button"] { margin-bottom: 0; }

/* ── Dashboard Extensions (beyond moonshot.css base) ──────── */

.dash-kpi__sub { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.dash-kpi .text-ok { color: var(--success); }
.dash-kpi .text-danger { color: var(--error); }

.dash-volume { margin-bottom: 1.5rem; }
.dash-volume summary { font-weight: 600; margin-bottom: 0.75rem; }
.dash-stats-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.5rem; text-align: center; }
.dash-stats-row > div {
	padding: 0.75rem 0.25rem; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius);
}
.dash-stats-row__val { display: block; font-size: 1.125rem; font-weight: 600; line-height: 1.2; }
.dash-stats-row__label {
	display: block; font-size: 0.7rem; color: var(--text-muted);
	margin-top: 0.125rem; text-transform: uppercase; letter-spacing: 0.03em;
}

.dash-activity header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.dash-activity__totals { display: flex; gap: 16px; align-items: center; }
.dash-activity__totals span { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dash-activity__totals small { font-size: 0.65rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.04em; }
.dash-activity__totals strong { font-size: 0.9rem; }

/* ── Wizard Step 3: Attachments ──────────────────────────── */

.attachment-row {
	display: flex; flex-direction: column; gap: var(--sp-3);
	padding: var(--sp-4); margin-bottom: var(--sp-3);
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); position: relative;
}
.attachment-row__fields {
	display: flex; gap: var(--sp-3); flex-wrap: wrap;
}
.attachment-row__fields .form-group { min-width: 200px; }
.attachment-row__fields .form-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }
.attachment-row__remove {
	position: absolute; top: var(--sp-3); right: var(--sp-3);
	width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
	border-radius: var(--radius); font-size: 0.75rem; cursor: pointer;
	background: transparent; color: var(--text-muted); border: 1px solid var(--border);
	transition: background 150ms, color 150ms, border-color 150ms;
}
.attachment-row__remove:hover {
	background: var(--error); color: #fff; border-color: var(--error);
}
.attachment-row--file {
	flex-direction: row; align-items: center; gap: var(--sp-3);
	padding: var(--sp-3) var(--sp-4);
}
.attachment-row__name {
	font-weight: 500; font-size: 0.875rem; flex: 1;
}
.attachment-row__type {
	font-size: 0.75rem; color: var(--text-muted);
	background: var(--surface-2); padding: 2px 8px; border-radius: var(--radius);
}
.attachment-list { margin-top: var(--sp-3); }
.wiz-pdf-vars {
	margin-top: var(--sp-3); padding-top: var(--sp-3);
	border-top: 1px solid var(--border);
}
.wiz-pdf-vars .variable-mapping-row { margin-bottom: var(--sp-2); }

/* Gap between the two article sections in step 3 */
#wizard-attachments-form article + article { margin-top: var(--sp-5); }

/* QA-3: KPI cards collapse to 2x2 on tablets so the four metrics
   (delivery / open / click / bounce) stay aligned instead of leaving
   "bounce rate" stranded on its own row. */
@media (max-width: 1024px) {
	.dash-kpi { grid-template-columns: repeat(2, 1fr); }
}

/* QA-4: the 8-column delivery-volume strip is unreadable on phones.
   Stack to 2 columns on small screens so each value has breathing room. */
@media (max-width: 768px) {
	.dash-stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
	.dash-stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.375rem; }
	.dash-stats-row__val { font-size: 1rem; }
	.dash-stats-row__label { font-size: 0.625rem; }
}

/* ── Wizard Layout (form + preview) ───────────────────────── */

.wizard-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.wizard-card {
	border: 1px solid var(--border); border-radius: var(--radius);
	background: var(--surface); overflow: hidden;
}
.wizard-card__header {
	padding: 12px 16px; background: var(--surface-2);
	border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.875rem;
}
.wizard-card__body { padding: 20px 16px; }
.wizard-card__body label { font-size: 0.8125rem; }
.wizard-card__body fieldset { margin-bottom: 0; }
.wizard-layout__preview { position: sticky; top: 1.5rem; }

.wizard-actions {
	display: flex; gap: 8px; justify-content: space-between; align-items: center;
	margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.wizard-actions button, .wizard-actions [role="button"] { width: auto; margin: 0; }
.wizard-actions__end { display: flex; gap: 8px; align-items: center; }

/* ── Template Preview (email) ─────────────────────────────── */

.template-preview {
	border: 1px solid var(--border); border-radius: var(--radius);
	overflow: hidden; background: var(--surface);
}
.wizard-card .template-preview { border: 0; border-radius: 0; }
.template-preview__header {
	padding: 12px 16px; background: var(--surface-2);
	border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.875rem;
}
.template-preview__subject {
	padding: 10px 14px; font-size: 0.8125rem;
	border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.template-preview__vars { padding: 8px 14px; display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); }
.template-preview__frame { width: 100%; min-height: 300px; border: 0; background: #fff; display: block; }
.template-preview__empty { padding: 3rem 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.8125rem; }
.variable-pill {
	display: inline-block; padding: 2px 8px;
	background: var(--accent-muted); color: var(--accent);
	border-radius: var(--radius); font-family: var(--font-mono); font-size: 0.6875rem;
}
.variable-mapping-list.grid {
	display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3);
}
.variable-mapping-row {
	display: flex !important; flex-direction: row !important;
	align-items: center; gap: var(--sp-3);
	margin-bottom: 0; padding: 8px 12px;
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius);
}
.variable-mapping-row__var {
	font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600;
	color: var(--accent); white-space: nowrap;
	background: var(--accent-muted); padding: 4px 10px; border-radius: var(--radius);
}
.variable-mapping-row__arrow {
	color: var(--text-muted); font-size: 1rem; flex-shrink: 0;
}
.variable-mapping-row__select {
	flex: 1; margin: 0;
}
@media (max-width: 768px) {
	.variable-mapping-list.grid { grid-template-columns: 1fr; }
}

/* ── Campaign Preview Card ────────────────────────────────── */

.preview-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.preview-card__subject { padding: 10px 14px; font-size: 0.8125rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.preview-card__frame { width: 100%; min-height: 400px; border: 0; background: #fff; display: block; }
.preview-card__empty { padding: 3rem 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.8125rem; }

/* ── WhatsApp Bubble Preview ──────────────────────────────── */

.wa-bubble {
	max-width: 360px; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius);
	border-left: 4px solid #25d366; padding: 12px; margin: 1rem auto;
}
.wa-bubble__header { font-weight: 600; font-size: 0.875rem; margin-bottom: 8px; }
.wa-bubble__body { font-size: 0.8125rem; line-height: 1.5; white-space: pre-wrap; }
.wa-bubble__footer { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }
.wa-bubble__buttons {
	display: flex; flex-direction: column; gap: 4px;
	margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px;
}
.wa-bubble__btn {
	text-align: center; padding: 8px; font-size: 0.8125rem;
	color: #0095f6; font-weight: 500;
	border: 1px solid var(--border); border-radius: var(--radius);
}
.wa-bubble__var {
	background: color-mix(in srgb, var(--accent) 15%, transparent);
	border-radius: 4px; padding: 0 4px; font-weight: 600; color: var(--accent);
}

/* ── Quick Test (WhatsApp test message) ───────────────────── */

.quick-test { max-width: 560px; margin: 0 auto; }
.quick-test__config { display: flex; gap: 1rem; border-bottom: 1px solid var(--border); }
.quick-test__config .quick-test__field { flex: 1; }
.quick-test__tabs {
	display: flex; gap: 0; background: var(--surface-2);
	border-bottom: 1px solid var(--border);
}
.quick-test__tab {
	flex: 1; display: flex; align-items: center; justify-content: center;
	gap: 6px; padding: 12px 16px; color: var(--text-muted);
	font-size: 0.8125rem; font-weight: 500; cursor: pointer;
	border-bottom: 2px solid transparent; margin-bottom: -1px;
	transition: color 150ms, border-color 150ms;
}
.quick-test__tab:hover { color: var(--text); }
.quick-test__tab--active { color: var(--accent); border-bottom-color: var(--accent); }
.quick-test__tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.quick-test__result { padding: 10px 14px; border-radius: var(--radius); font-size: 0.8125rem; font-weight: 500; margin-bottom: 1rem; }
.quick-test__result--success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.quick-test__result--error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.quick-test__form { display: flex; flex-direction: column; gap: 0; }
.quick-test__field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 1rem; }
.quick-test__field label { font-size: 0.8125rem; font-weight: 500; margin-bottom: 0; }
.quick-test__field small { font-size: 0.6875rem; color: var(--text-muted); margin-top: -2px; }
.quick-test__field input,
.quick-test__field select,
.quick-test__field textarea { margin-bottom: 0; }
.quick-test__textarea { min-height: 100px; resize: vertical; }
.quick-test__actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.quick-test__actions button { width: auto; margin: 0; display: flex; align-items: center; gap: 6px; }
.quick-test__tip {
	display: flex; align-items: flex-start; gap: 8px;
	margin-top: 1rem; padding: 12px 16px; border-radius: var(--radius);
	background: var(--surface-2); border: 1px solid var(--border);
	color: var(--text-muted); font-size: 0.8125rem; line-height: 1.5;
}
.quick-test__tip svg { flex-shrink: 0; margin-top: 1px; }
.quick-test__preview {
	background: var(--surface-2); padding: 12px 16px;
	border-radius: var(--radius); font-size: 0.8125rem;
	margin-bottom: 1rem; white-space: pre-wrap;
	color: var(--text-muted); line-height: 1.5; border-left: 3px solid var(--accent);
}

/* ── WhatsApp Conversations ───────────────────────────────── */

.conv-detail-row td { padding: 0 !important; }
.conv-log { display: flex; flex-direction: column; gap: 3px; padding: 12px 16px; background-color: #efeae2; }
[data-theme="dark"] .conv-log { background-color: #0b141a; }

.chat-msg {
	max-width: 70%; padding: 6px 10px 8px; border-radius: 8px;
	font-size: 0.8125rem; line-height: 1.4; word-break: break-word;
	position: relative; box-shadow: 0 1px 0.5px rgba(0,0,0,0.1);
}
.chat-msg p { margin: 0; }
.chat-msg--received { align-self: flex-start; background: #fff; color: #303030; border-top-left-radius: 0; }
[data-theme="dark"] .chat-msg--received { background: #1f2c34; color: #e9edef; }
.chat-msg--sent { align-self: flex-end; background: #d9fdd3; color: #303030; border-top-right-radius: 0; }
[data-theme="dark"] .chat-msg--sent { background: #005c4b; color: #e9edef; }

.chat-msg__meta {
	display: flex; align-items: center; justify-content: flex-end;
	gap: 3px; font-size: 0.6875rem; margin-top: 2px; opacity: 0.55; color: #667781;
}
.chat-msg__status { font-size: 0.8125rem; font-weight: 600; letter-spacing: -2px; }
.chat-msg__status--sent, .chat-msg__status--delivered { color: #667781; }
.chat-msg__status--read { color: #53bdeb; }
.chat-msg__status--failed { color: #e53935; letter-spacing: 0; }

.chat-msg--failed { opacity: 0.85; border: 1px solid #e53935; }
.chat-msg__error {
	font-size: 0.6875rem; color: #e53935; margin-top: 4px;
	background: rgba(229, 57, 53, 0.08); padding: 3px 6px; border-radius: 4px;
}

.chat-msg__media { margin-bottom: 4px; }
.chat-msg__media-placeholder {
	display: flex; align-items: center; gap: 6px;
	padding: 8px 12px; border-radius: 6px; font-size: 0.8125rem;
}
.chat-msg__media-placeholder--image { background: rgba(76,175,80,0.12); }
.chat-msg__media-placeholder--video { background: rgba(33,150,243,0.12); }
.chat-msg__media-placeholder--audio { background: rgba(156,39,176,0.12); }
.chat-msg__media-placeholder--doc   { background: rgba(255,152,0,0.12); }

/* ── Tab Bar ──────────────────────────────────────────────── */

.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--border); }
.tab-bar__tab {
	padding: 8px 20px; font-size: 0.875rem; font-weight: 500;
	color: var(--text-muted); text-decoration: none;
	border-bottom: 2px solid transparent; margin-bottom: -2px;
	transition: color 0.15s, border-color 0.15s;
}
.tab-bar__tab:hover { color: var(--text); }
.tab-bar__tab--active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Text Utilities ───────────────────────────────────────── */

.text--success { color: var(--success); }
.text--danger  { color: var(--error); }

/* ── HTMX Loading State ───────────────────────────────────── */

.htmx-request .spinner { display: inline-block; }
.htmx-request [data-loading-text] { display: none; }

/* ── Mobile Responsive ────────────────────────────────────── */

@media (max-width: 768px) {
	.console-shell {
		flex-direction: column;
		height: auto;
		overflow: visible;
	}
	.console-shell > main {
		overflow: visible;
	}
	.console-shell > main > .content-body {
		overflow-y: visible;
	}

	.sidebar {
		position: fixed; top: 0; left: 0; height: 100vh; width: 280px;
		transform: translateX(-100%); transition: transform 200ms ease;
		z-index: var(--z-sidebar);
	}
	.sidebar.nav--open { transform: translateX(0); }
	.sidebar__body { flex-direction: column; }
	.sidebar__body .service-rail { display: none; }
	.sidebar .nav__rail-mobile {
		display: flex; gap: 4px; padding: 8px 12px;
		border-bottom: 1px solid var(--border); overflow-x: auto;
	}
	.sidebar .nav__rail-mobile .service-rail__item {
		width: 36px; height: 36px; border-left: none;
		border-bottom: 2px solid transparent;
	}
	.sidebar .nav__rail-mobile .service-rail__item--active {
		border-bottom-color: var(--service-color, var(--accent));
	}
	.sidebar .nav__rail-mobile .service-rail__tooltip { display: none !important; }

	.content-body { padding: 1rem; }
	.content-header__inner { padding: 0.5rem 1rem; }

	.wizard-progress { flex-wrap: wrap; justify-content: center; }
	.wizard-progress__step { padding: 8px 12px; font-size: 0.75rem; }
	.wizard-progress__label { display: none; }
	.wizard-progress__number, .wizard-progress__check { width: 28px; height: 28px; }

	.wizard-layout { grid-template-columns: 1fr; }
	.wizard-layout__preview { position: static; }

	.filter-bar { flex-direction: column; }
	.filter-bar select, .filter-bar input[type="date"],
	.filter-bar input[type="text"], .filter-bar__field { width: 100%; }
	.filter-bar--collapsible { display: none; }
	.filter-bar--collapsible.filter-bar--open { display: flex; }
	.filter-bar__mobile-toggle {
		display: flex; align-items: center; gap: 6px;
		font-size: 0.8125rem; font-weight: 500; color: var(--accent);
		cursor: pointer; margin-bottom: 0.75rem;
	}
	.filter-bar__mobile-toggle svg { width: 16px; height: 16px; stroke: var(--accent); }

	.dash-stats-row { grid-template-columns: repeat(4, 1fr); }
	.dash-charts { grid-template-columns: 1fr; }
	.dash-charts article { overflow: hidden; min-width: 0; }
	.dash-activity header { flex-direction: column; align-items: flex-start; }

	.quick-test__config { flex-direction: column; gap: 0; }
	.quick-test__tab { padding: 10px 12px; font-size: 0.75rem; }

	.chat-msg { max-width: 85%; }
}
@media (min-width: 769px) {
	.filter-bar__mobile-toggle { display: none; }
}
