/* Email channel console — page-specific components.
 * Built on the shared tokens in theme.css / console.css (indigo + slate, Inter).
 * Everything is prefixed `ef-` so nothing leaks into the other consoles.
 */

/* ---- Layout ------------------------------------------------------------ */
.ef-stack { display: flex; flex-direction: column; gap: 20px; }
.ef-narrow { max-width: 880px; }
.ef-section-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--surface-900); }
.ef-section-sub { margin: 4px 0 0; font-size: 13px; color: var(--surface-500); }
.ef-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.ef-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- Surfaces ------------------------------------------------------------ */
.ef-card {
    background: #fff;
    border: 1px solid var(--surface-200);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-soft);
}
.ef-card-body { padding: 20px 22px; }
.ef-card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 22px; border-bottom: 1px solid var(--surface-100);
}
.ef-card-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--surface-900); display: flex; align-items: center; gap: 8px; }
.ef-card-title .icon { color: var(--surface-400); }
.ef-card-desc { margin: 3px 0 0; font-size: 13.5px; color: var(--surface-500); }
.ef-card-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 22px; border-top: 1px solid var(--surface-100); background: var(--surface-50);
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

/* ---- Mode selector (radio cards) ---------------------------------------- */
.ef-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ef-mode {
    position: relative; text-align: left; cursor: pointer; font: inherit;
    display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch;
    background: #fff; border: 1.5px solid var(--surface-200); border-radius: var(--card-radius);
    padding: 16px 18px 16px 50px; box-shadow: var(--shadow-soft);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.ef-mode:hover { border-color: var(--primary-300); }
.ef-mode:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.ef-mode[aria-checked="true"] {
    border-color: var(--primary-500); background: var(--primary-50);
    box-shadow: 0 0 0 3px rgb(99 102 241 / .12);
}
.ef-mode::before {                       /* radio dot */
    content: ""; position: absolute; left: 18px; top: 18px; width: 18px; height: 18px;
    border-radius: 50%; border: 1.5px solid var(--surface-300); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.ef-mode[aria-checked="true"]::before { border-color: var(--primary-600); box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 9px var(--primary-600); }
.ef-mode-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ef-mode-name { font-size: 14px; font-weight: 600; color: var(--surface-900); }
.ef-mode-desc { margin-top: 6px; font-size: 12.5px; line-height: 1.5; color: var(--surface-600); }
.ef-badge {
    font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.ef-badge.rec { background: var(--kpi-emerald-bg); color: var(--kpi-emerald-fg); }
.ef-badge.adv { background: var(--surface-100); color: var(--surface-600); }
.ef-badge.live { background: var(--primary-100); color: var(--primary-700); }

/* ---- Form ---------------------------------------------------------------- */
.ef-form { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 16px 16px; }
.ef-form .span-2 { grid-column: 1 / -1; }
.ef-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ef-label { font-size: 12.5px; font-weight: 600; color: var(--surface-700); }
.ef-help { font-size: 12px; color: var(--surface-500); line-height: 1.45; }
.ef-help a { color: var(--primary-600); font-weight: 500; }
.ef-field input.inp, .ef-field select.inp { width: 100%; box-sizing: border-box; }
.ef-field input.inp[aria-invalid="true"] { border-color: var(--erp-error); box-shadow: 0 0 0 3px rgb(220 38 38 / .12); }
.ef-error { font-size: 12px; color: var(--erp-error); }
.ef-secret-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--surface-500); }
.ef-secret-state .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-300); }
.ef-secret-state.on .dot { background: var(--erp-synced); }
.ef-input-group { position: relative; }
.ef-input-group input.inp { padding-right: 64px; }
.ef-input-btn {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: none; background: none; cursor: pointer; padding: 6px 8px; border-radius: 6px;
    font: inherit; font-size: 12px; font-weight: 600; color: var(--primary-600);
}
.ef-input-btn:hover { background: var(--primary-50); }
.ef-divider { grid-column: 1 / -1; height: 1px; background: var(--surface-100); margin: 4px 0; }

/* Segmented control (provider + sign-in method) */
.ef-segmented {
    display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-100);
    border: 1px solid var(--surface-200); border-radius: 10px; flex-wrap: wrap;
}
.ef-segmented button {
    border: none; background: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
    color: var(--surface-600); padding: 7px 14px; border-radius: 8px; transition: background .15s, color .15s;
}
.ef-segmented button:hover { color: var(--surface-900); }
.ef-segmented button[aria-pressed="true"] { background: #fff; color: var(--primary-700); font-weight: 600; box-shadow: var(--shadow-soft); }

/* Toggle switch */
.ef-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.ef-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ef-switch .track {
    flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-300);
    position: relative; transition: background .15s; margin-top: 1px;
}
.ef-switch .track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .15s;
}
.ef-switch input:checked + .track { background: var(--primary-600); }
.ef-switch input:checked + .track::after { transform: translateX(16px); }
.ef-switch input:focus-visible + .track { box-shadow: var(--shadow-glow); }
.ef-switch-text strong { display: block; font-size: 13.5px; color: var(--surface-900); font-weight: 600; }
.ef-switch-text span { font-size: 12.5px; color: var(--surface-500); }

/* Inbound address display */
.ef-address {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border: 1px dashed var(--primary-300); border-radius: 10px; background: var(--primary-50);
}
.ef-address code { font-family: var(--font-mono); font-size: 14px; color: var(--primary-800); word-break: break-all; }

/* Status + test results */
.ef-status-line { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--surface-600); }
.ef-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-300); flex: none; }
.ef-status-dot.ok { background: var(--erp-synced); box-shadow: 0 0 0 3px rgb(5 150 105 / .15); }
.ef-status-dot.warn { background: var(--erp-pending); box-shadow: 0 0 0 3px rgb(217 119 6 / .15); }
.ef-status-dot.err { background: var(--erp-error); box-shadow: 0 0 0 3px rgb(220 38 38 / .15); }
.ef-tests { display: grid; gap: 8px; margin-top: 16px; }
.ef-test {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 8px;
    font-size: 13px; border: 1px solid var(--surface-200); background: var(--surface-50);
}
.ef-test.ok { border-color: #a7f3d0; background: #ecfdf5; }
.ef-test.fail { border-color: #fecaca; background: #fef2f2; }
.ef-test b { min-width: 44px; color: var(--surface-900); }
.ef-test .res { font-weight: 600; }
.ef-test.ok .res { color: var(--st-approved-fg); }
.ef-test.fail .res { color: var(--st-rejected-fg); }

/* Callout (neutral / info / warning) */
.ef-callout {
    display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 12.5px; line-height: 1.5;
    background: var(--surface-50); border: 1px solid var(--surface-200); color: var(--surface-700);
}
.ef-callout.info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-900); }
.ef-callout.warn { background: var(--st-needs-review-bg); border-color: #fde68a; color: var(--st-needs-review-fg); }
.ef-callout.err { background: var(--st-rejected-bg); border-color: #fecaca; color: var(--st-rejected-fg); }
.ef-callout .icon { flex: none; margin-top: 1px; }
.ef-callout code { font-family: var(--font-mono); font-size: 11.5px; }

/* Save bar */
.ef-savebar {
    position: sticky; bottom: 16px; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; border-radius: 12px; background: var(--surface-900); color: #fff;
    box-shadow: var(--shadow-soft-xl); animation: fade-in 150ms ease-out;
}
.ef-savebar[hidden] { display: none; }
.ef-savebar span { font-size: 13px; }
.ef-savebar .btn.secondary { background: transparent; color: #fff; border-color: rgb(255 255 255 / .25); }
.ef-savebar .btn.secondary:hover { background: rgb(255 255 255 / .08); }

/* ---- Overview ---------------------------------------------------------- */
.ef-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ef-kpi { padding: 20px 22px; }
.ef-kpi .k { font-size: 13.5px; font-weight: 500; color: var(--surface-600); }
.ef-kpi .v { margin-top: 10px; font-size: 15px; font-weight: 600; color: var(--surface-900); word-break: break-word; }
.ef-kpi .v.big { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ef-table-wrap { overflow-x: auto; }
.ef-table-wrap table.data { min-width: 720px; }
.ef-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--surface-100); font-size: 12.5px; color: var(--surface-500); }
.ef-cell-sub { font-size: 12px; color: var(--surface-500); }
.ef-cell-strong { font-weight: 600; color: var(--surface-900); }
.ef-assign { display: flex; gap: 8px; align-items: center; }
.ef-assign select.inp { min-width: 170px; }
.ef-detail { margin-top: 14px; }

/* Entities */
.ef-entity { padding: 16px 18px; }
.ef-entity + .ef-entity { border-top: 1px solid var(--surface-100); }
.ef-entity-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ef-entity-name { font-size: 14px; font-weight: 600; color: var(--surface-900); }
.ef-rules { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ef-rule {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px; border: 1px solid var(--surface-200); border-radius: 8px; font-size: 13px; background: var(--surface-50);
}
.ef-rule code { font-family: var(--font-mono); font-size: 12px; background: #fff; border: 1px solid var(--surface-200); padding: 1px 6px; border-radius: 4px; }
.ef-inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ef-inline-form input.inp { flex: 1 1 180px; min-width: 0; }
.btn.ghost { background: none; color: var(--surface-600); box-shadow: none; min-height: 32px; padding: 6px 10px; }
.btn.ghost:hover { background: var(--surface-100); color: var(--surface-900); }
.btn.ghost.danger-text { color: var(--erp-error); }
.btn.ghost.danger-text:hover { background: #fef2f2; color: #b91c1c; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 900px) {
    .ef-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .ef-modes { grid-template-columns: 1fr; }
    .ef-form { grid-template-columns: 1fr; }
    .ef-kpis { grid-template-columns: 1fr; }
    .ef-card-body, .ef-card-head, .ef-card-foot { padding-left: 16px; padding-right: 16px; }
}

/* ---- Shared tweaks ------------------------------------------------------ */
.btn.sm { min-height: 32px; padding: 6px 12px; font-size: 12.5px; }
.ef-card table.data { border: none; box-shadow: none; border-radius: 0; }
.ef-card table.data td { vertical-align: middle; }
.ef-empty { padding: 36px 20px; text-align: center; color: var(--surface-500); font-size: 13px; }
.ef-empty strong { display: block; color: var(--surface-800); font-size: 14px; margin-bottom: 4px; }
.ef-tabbar-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
    margin-left: 6px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 700;
    background: var(--st-needs-review-bg); color: var(--st-needs-review-fg);
}
.ef-tabbar-count[hidden] { display: none; }
/* The `hidden` attribute must win over component display rules (.btn etc.). */
[hidden] { display: none !important; }
.ef-form.entity { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
.ef-alerts { display: flex; flex-direction: column; gap: 10px; }
.ef-alerts:empty { display: none; }
.ef-section-title .icon { vertical-align: -2px; margin-right: 6px; color: var(--primary-500); }
@media (max-width: 640px) { .ef-form.entity { grid-template-columns: 1fr; } }
.ef-segmented { align-self: flex-start; }
