/* =====================================================================
   Authenticated app shell — Syncfusion-styled.
   Used by Components/Layout/MainLayout.razor + NavMenu.razor.
   ===================================================================== */

:root {
    --shell-bg: #f7f9fc;
    --shell-surface: #ffffff;
    --shell-border: #e2e8f0;
    --shell-text: #0f172a;
    --shell-muted: #64748b;
    --shell-primary: #2563eb;
    --shell-primary-soft: rgba(37, 99, 235, 0.08);
    --shell-success: #10b981;
    --shell-warning: #f59e0b;
    --shell-danger: #ef4444;
    --shell-nav-w: 240px;
    --shell-nav-w-collapsed: 64px;
    --shell-bar-h: 56px;
}

/* Reset body padding from Bootstrap so the shell takes the full viewport */
body.warmup-app-body {
    margin: 0;
    background: var(--shell-bg);
    color: var(--shell-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--shell-nav-w) 1fr;
    grid-template-rows: var(--shell-bar-h) 1fr;
    grid-template-areas:
        "nav bar"
        "nav main";
    min-height: 100vh;
    background: var(--shell-bg);
    transition: grid-template-columns 0.18s ease;
}

.app-shell.nav-collapsed {
    grid-template-columns: var(--shell-nav-w-collapsed) 1fr;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */

.app-bar {
    grid-area: bar;
    background: var(--shell-surface);
    border-bottom: 1px solid var(--shell-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-bar .menu-toggle {
    background: transparent;
    border: none;
    color: var(--shell-text);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

.app-bar .menu-toggle:hover {
    background: var(--shell-primary-soft);
    color: var(--shell-primary);
}

.app-bar .breadcrumb {
    font-size: 14px;
    color: var(--shell-muted);
    flex: 1;
}

.app-bar .breadcrumb strong {
    color: var(--shell-text);
}

.app-bar .bar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-bar .bar-actions .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--shell-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.15s, color 0.15s;
}

.app-bar .bar-actions .icon-btn:hover {
    background: var(--shell-primary-soft);
    color: var(--shell-primary);
}

.app-bar .user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--shell-border);
    background: var(--shell-surface);
    color: var(--shell-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.app-bar .user-pill:hover {
    background: var(--shell-bg);
}

.app-bar .user-pill .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.app-bar .sign-in-link {
    text-decoration: none;
    color: var(--shell-primary);
    font-weight: 600;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--shell-primary-soft);
}

.app-bar .sign-in-link:hover {
    background: rgba(37, 99, 235, 0.16);
}

/* ── Side nav ────────────────────────────────────────────────────────── */

.app-nav {
    grid-area: nav;
    background: var(--shell-surface);
    border-right: 1px solid var(--shell-border);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-nav .nav-brand {
    height: var(--shell-bar-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--shell-border);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--shell-text);
    gap: 10px;
    white-space: nowrap;
}

.app-nav .nav-brand .mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.app-nav .nav-section {
    padding: 12px 12px 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-nav .nav-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--shell-muted);
    padding: 16px 12px 6px 12px;
}

.app-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--shell-text);
    font-size: 14px;
    text-decoration: none;
    transition: background-color 0.12s, color 0.12s;
    white-space: nowrap;
}

.app-nav .nav-link .material-icons {
    font-size: 20px;
    color: var(--shell-muted);
    flex-shrink: 0;
    width: 20px;
    line-height: 1;
}

.app-nav .nav-link:hover {
    background: var(--shell-primary-soft);
    color: var(--shell-primary);
}

.app-nav .nav-link:hover .material-icons {
    color: var(--shell-primary);
}

.app-nav .nav-link.active {
    background: var(--shell-primary);
    color: #fff;
}

.app-nav .nav-link.active .material-icons {
    color: #fff;
}

.app-nav .nav-link.disabled {
    color: var(--shell-muted);
    cursor: default;
}

.app-nav .nav-link.disabled:hover {
    background: transparent;
    color: var(--shell-muted);
}

.app-nav .nav-link.disabled .material-icons {
    color: var(--shell-muted);
}

.app-nav .nav-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
}

.app-nav .nav-divider {
    border-top: 1px solid var(--shell-border);
    margin: 12px 12px;
}

.app-nav .nav-spacer {
    flex: 1;
}

/* Collapsed nav: hide labels, keep icons centered */
.nav-collapsed .app-nav .nav-link span:not(.material-icons):not(.nav-badge) {
    display: none;
}

.nav-collapsed .app-nav .nav-link {
    justify-content: center;
}

.nav-collapsed .app-nav .nav-section-label,
.nav-collapsed .app-nav .nav-brand .brand-word,
.nav-collapsed .app-nav .nav-badge {
    display: none;
}

/* ── Main content ────────────────────────────────────────────────────── */

.app-main {
    grid-area: main;
    padding: 24px 28px;
    overflow-x: hidden;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--shell-text);
}

.page-subtitle {
    font-size: 14px;
    color: var(--shell-muted);
    margin: 4px 0 0 0;
}

.page-card {
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.page-empty {
    background: var(--shell-surface);
    border: 1px dashed var(--shell-border);
    border-radius: 12px;
    padding: 56px 24px;
    text-align: center;
}

.page-empty .empty-icon {
    font-size: 48px;
    color: var(--shell-muted);
    opacity: 0.6;
    margin-bottom: 16px;
}

.page-empty h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--shell-text);
}

.page-empty p {
    color: var(--shell-muted);
    margin: 0 0 24px 0;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Status pills used inside Syncfusion grid templates ──────────────── */

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.status-pill.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-pill.status-paused {
    background: #fef3c7;
    color: #92400e;
}

.status-pill.status-quarantined,
.status-pill.status-disconnected {
    background: #fee2e2;
    color: #991b1b;
}

.status-pill.status-pendingverification {
    background: #dbeafe;
    color: #1e40af;
}

.status-pill.status-archived {
    background: #f1f5f9;
    color: #475569;
}

/* Tenant lifecycle pills used in MainLayout's top bar. Suspended/Cancelled lean red/grey
   so the user spots them at a glance even when the workspace banner is scrolled out. */
.status-pill.status-suspended {
    background: #fee2e2;
    color: #b91c1c;
}

.status-pill.status-cancelling {
    background: #fef3c7;
    color: #b45309;
}

.status-pill.status-cancelled {
    background: #e5e7eb;
    color: #374151;
}

/* Role pills (Workspace settings → Members tab). Reuse the .status-pill base. */

.status-pill.role-owner {
    background: #ede9fe;
    color: #5b21b6;
}

.status-pill.role-admin {
    background: #dbeafe;
    color: #1e40af;
}

.status-pill.role-operator {
    background: #d1fae5;
    color: #065f46;
}

.status-pill.role-billing {
    background: #fef3c7;
    color: #92400e;
}

.status-pill.role-viewer {
    background: #f1f5f9;
    color: #475569;
}

/* ── Two-column key/value rows (mailbox detail) ───────────────────── */

.kv-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    font-size: 14px;
}

.kv-row .kv-label {
    color: var(--shell-muted);
    flex: 0 0 160px;
}

.kv-row .kv-value {
    color: var(--shell-text);
    word-break: break-word;
}

/* ── Stat tiles + content cards ───────────────────────────────────── */

.stat-tile {
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stat-tile .stat-label {
    font-size: 13px;
    color: var(--shell-muted);
    margin: 0;
}

.stat-tile .stat-value {
    font-size: 30px;
    font-weight: 700;
    margin: 4px 0;
    color: var(--shell-text);
    letter-spacing: -0.02em;
}

.stat-tile .stat-hint {
    font-size: 12px;
    color: var(--shell-muted);
    margin: 0;
}

.section-card {
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.section-card h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--shell-muted);
    margin: 0 0 12px 0;
}

.provider-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
    border-radius: 14px;
    padding: 32px 24px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.provider-card:hover {
    border-color: var(--shell-primary);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.12);
    transform: translateY(-2px);
}

.provider-card .provider-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--shell-primary-soft);
    color: var(--shell-primary);
    font-size: 32px;
    margin-bottom: 16px;
}

.provider-card h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--shell-text);
}

.provider-card p {
    font-size: 13px;
    color: var(--shell-muted);
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.onboarding-shell {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 16px;
}

.onboarding-shell .step-meta {
    font-size: 13px;
    color: var(--shell-muted);
    margin-bottom: 8px;
}

.onboarding-shell h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 8px 0 8px 0;
    color: var(--shell-text);
}

.onboarding-shell .step-lede {
    font-size: 15px;
    color: var(--shell-muted);
    margin: 0 0 28px 0;
}

.onboarding-shell .form-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.onboarding-shell .footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* ── Detection hint (Connect page MX classifier) ──────────────────── */

.detect-hint {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--shell-surface-2);
    border-left: 3px solid var(--shell-border);
}

.detect-hint i.material-icons {
    font-size: 24px;
    color: var(--shell-muted);
}

.detect-hint strong { font-size: 13px; }
.detect-hint p {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--shell-muted);
}
.detect-hint code {
    background: var(--shell-surface);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.detect-hint.detect-gmail { border-left-color: #ea4335; }
.detect-hint.detect-microsoft { border-left-color: #0078d4; }
.detect-hint.detect-other { border-left-color: #6b7280; }
.detect-hint.detect-unknown { border-left-color: #f59e0b; }

.provider-card-suggested {
    border: 2px solid var(--shell-accent, #1f6feb);
    box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.12);
}

/* ── Recommendation rows (Deliverability tab) ─────────────────────── */

.rec-row {
    border-left: 3px solid var(--shell-border);
    padding: 10px 12px;
    background: var(--shell-surface-2);
    border-radius: 4px;
}

.rec-row .rec-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.rec-row .rec-pill {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rec-row .rec-detail {
    margin: 6px 0 0 0;
    padding: 0;
    font-size: 12px;
    color: var(--shell-muted);
    background: transparent;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
}

.rec-row.rec-critical { border-left-color: #b91c1c; }
.rec-row.rec-critical .rec-pill { background: #fee2e2; color: #991b1b; }

.rec-row.rec-high { border-left-color: #c2410c; }
.rec-row.rec-high .rec-pill { background: #ffedd5; color: #9a3412; }

.rec-row.rec-medium { border-left-color: #b45309; }
.rec-row.rec-medium .rec-pill { background: #fef3c7; color: #92400e; }

.rec-row.rec-low { border-left-color: #2563eb; }
.rec-row.rec-low .rec-pill { background: #dbeafe; color: #1e40af; }

/* Mobile collapse: nav becomes overlay drawer */
@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 0 1fr;
    }

    .app-shell.nav-open {
        grid-template-columns: var(--shell-nav-w) 1fr;
    }

    .app-nav {
        position: fixed;
        z-index: 200;
    }
}

/* Compact field label used on Mailbox detail / persona panel inputs */
.field-label {
    display: block;
    font-size: 12px;
    color: var(--shell-muted, #6b7280);
    margin-bottom: 4px;
}

/* Dashboard mailbox-status breakdown list */
.status-breakdown {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-breakdown li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--shell-border, #e5e7eb);
}

.status-breakdown li:last-child {
    border-bottom: none;
}

.status-breakdown .status-count {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--shell-fg, #111827);
}

/* Dashboard recent-activity feed */
.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.activity-list li {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid var(--shell-border, #e5e7eb);
    font-size: 13px;
}

.activity-list li:last-child { border-bottom: none; }

.activity-list .activity-action {
    font-family: var(--shell-mono);
    color: var(--shell-fg, #111827);
}

.activity-list .activity-resource {
    color: var(--shell-muted, #6b7280);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.activity-list .activity-time {
    color: var(--shell-muted, #6b7280);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
}

.card-action-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--shell-link, #2563eb);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.card-action-link:hover { text-decoration: underline; }

/* Workspace lifecycle banner — sits at the top of every /app/* main area when the tenant is
   not Active. Three styles: Suspended (red), Cancelling (amber), Cancelled (grey). */
.workspace-banner {
    margin: 0 0 16px 0;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid;
    font-size: 13px;
    line-height: 1.45;
}

.workspace-banner-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.workspace-banner-inner .material-icons {
    font-size: 20px;
    margin-top: 1px;
    flex: 0 0 auto;
}

.workspace-banner-inner strong {
    display: inline-block;
    margin-right: 6px;
}

.workspace-banner-inner a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.workspace-banner-suspended {
    background: #fef2f2;
    color: #7f1d1d;
    border-color: #b91c1c;
}

.workspace-banner-cancelling {
    background: #fffbeb;
    color: #78350f;
    border-color: #d97706;
}

.workspace-banner-cancelled {
    background: #f3f4f6;
    color: #374151;
    border-color: #6b7280;
}

/* Cookie consent banner — fixed bottom, dismissable, GDPR-friendly disclosure */
.cookie-banner {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 9000;
    background: var(--shell-card-bg, #ffffff);
    color: var(--shell-fg, #111827);
    border: 1px solid var(--shell-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 14px 16px;
}

.cookie-banner-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
    font-size: 0.92rem;
    line-height: 1.4;
}

.cookie-banner-inner > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.cookie-banner-inner strong {
    display: block;
    margin-bottom: 2px;
}

.cookie-banner-inner a {
    color: var(--shell-link, #2563eb);
    text-decoration: underline;
}

.cookie-banner-dismiss {
    flex: 0 0 auto;
    background: var(--shell-accent, #111827);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 120ms ease;
}

.cookie-banner-dismiss:hover {
    opacity: 0.85;
}

.cookie-banner-dismiss:focus-visible {
    outline: 2px solid var(--shell-link, #2563eb);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .cookie-banner {
        bottom: 8px;
        left: 8px;
        right: 8px;
        padding: 12px;
    }

    .cookie-banner-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .cookie-banner-dismiss {
        width: 100%;
    }
}

/* Per-page ErrorBoundary fallback. Sized to fit inside .app-main without ballooning
   the layout — operator can reload the affected route while sidebar/header stay live. */
.page-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 20px;
    margin: 16px 0;
    color: #7f1d1d;
}
.page-error h2 {
    font-size: 18px;
    margin: 0 0 8px 0;
}
.page-error-detail {
    font-family: ui-monospace, SFMono-Regular, "Courier New", monospace;
    font-size: 12px;
    background: rgba(127, 29, 29, 0.06);
    padding: 8px 10px;
    border-radius: 4px;
    margin: 8px 0;
    word-break: break-word;
}
.page-error-hint {
    font-size: 13px;
    color: #991b1b;
    margin: 8px 0 12px 0;
}
.page-error-reload {
    background: #b91c1c;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}
.page-error-reload:hover {
    background: #991b1b;
}
