/* Support Portal app styles. Values come from the shared AxisGeo theme tokens
   (_content/AGIControls.Blazor/agi-theme.css, linked before this sheet) so the
   app follows the product palette; see AGIControls.Blazor/STYLING.md. */

html, body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text);
    font-size: 14px;
}

h1 { font-family: var(--font-serif); font-size: 22px; margin: 0; }
h2 { font-family: var(--font-serif); font-size: 16px; margin: 0 0 10px; }
a { color: var(--accent); }
h1:focus { outline: none; }

.hint { color: var(--text-muted); font-size: 12px; }
.text-muted { color: var(--text-muted) !important; }

/* — Shell ————————————————————————————————— */

.page { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-size: 11px; letter-spacing: 0.06em; }
.brand-axis { font-weight: 800; color: var(--accent); }
.brand-geo { font-weight: 600; color: var(--brand-ink); }
.brand-subtitle { font-size: 10px; letter-spacing: 0.18em; color: var(--text-muted); font-weight: 600; }

.side-nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; }
.side-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
.side-nav-link i { width: 16px; text-align: center; color: var(--text-muted); }
.side-nav-link:hover { background: var(--bg-subtle); color: var(--text); }
.side-nav-link.active { background: var(--accent-soft); color: var(--accent-on-soft); }
.side-nav-link.active i { color: var(--accent-on-soft); }

.page-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.top-bar {
    display: flex; align-items: center; gap: 8px;
    height: 52px; padding: 0 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.page-spacer { flex: 1; }

/* Mobile drawer (CSS-only checkbox hack — the shell is static SSR). */
.nav-drawer-box { display: none; }
.nav-toggle {
    display: none;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    margin-left: -8px; margin-bottom: 0;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 17px;
    cursor: pointer;
}
.nav-toggle:hover { background: var(--bg-subtle); }
.nav-backdrop { display: none; }

.content {
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* — Buttons (override Bootstrap toward the theme) ———————— */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: var(--control-h);
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
}
.btn:hover { background: var(--bg-subtle); color: var(--text); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-primary, .btn-primary:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-primary:disabled { opacity: 0.5; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--bg-surface); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* — Forms (retheme the Bootstrap classes the pages use) ————— */

.form-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.form-control, .form-select {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    background-color: var(--bg-surface);
}
input.form-control, .form-select { height: var(--control-h); padding: 0 10px; }
textarea.form-control { padding: 8px 10px; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

.alert-danger {
    background: var(--danger-soft);
    border: 1px solid var(--danger-soft);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 13px;
    padding: 8px 12px;
}

/* — Page furniture ————————————————————————— */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-actions { display: flex; gap: 8px; }

/* Status filter chips */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-chip {
    display: inline-flex; align-items: center;
    height: 28px; padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 12px; font-weight: 500;
    text-decoration: none;
}
.filter-chip:hover { background: var(--bg-subtle); color: var(--text); }
.filter-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-on-soft); }

/* Data table (tickets list, agents list) */
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; margin: 0; }
.data-table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 8px 12px;
    white-space: nowrap;
}
.data-table td { padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover td { background: var(--bg-subtle); }
.data-table .row-subject { font-weight: 600; }
.data-table .row-subject a { color: var(--text); text-decoration: none; }
.data-table .row-subject a:hover { color: var(--accent); }
.data-table .col-num { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.data-table .col-date { color: var(--text-muted); white-space: nowrap; }

.empty { text-align: center; color: var(--text-muted); padding: 60px 20px; }

/* Status / priority pills */
.state-pill {
    display: inline-block;
    font-size: 11px; font-weight: 600;
    border-radius: var(--radius-pill);
    padding: 3px 9px;
    white-space: nowrap;
}
.state-pill.accent { background: var(--accent-soft); color: var(--accent-on-soft); }
.state-pill.ok { background: var(--success-soft); color: var(--success); }
.state-pill.warn { background: var(--warning-soft); color: var(--warning); }
.state-pill.err { background: var(--danger-soft); color: var(--danger); }
.state-pill.off { background: var(--bg-subtle); color: var(--text-faint); }
.state-pill.neutral { background: var(--bg-subtle); color: var(--text-muted); }

/* — Ticket thread ——————————————————————————— */

.ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 8px 0 2px; flex-wrap: wrap; }
.ticket-head h1 { margin: 0; }
.ticket-pills { display: flex; gap: 6px; align-items: center; }
.ticket-meta { color: var(--text-muted); font-size: 13px; margin: 2px 0 16px; }

/* — Workflow diagram + quick transitions ————————————— */

.wf-diagram {
    max-width: 680px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 10px 12px 4px;
    margin-bottom: 12px;
}
.wf-diagram svg { display: block; width: 100%; height: auto; }
.wf-edge { stroke: #616774; stroke-width: 1.5; }
.wf-edge.dim { stroke: #97a0ac; stroke-dasharray: 4 4; }
.wf-node rect { fill: var(--bg-subtle); stroke: var(--border-strong); stroke-width: 1; }
.wf-node text { fill: var(--text); font-size: 12px; font-weight: 500; font-family: var(--font-sans); }
.wf-node.current rect { fill: var(--accent); stroke: var(--accent); }
.wf-node.current text { fill: #fff; font-weight: 600; }

.wf-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px 16px; flex-wrap: wrap;
    max-width: 680px;
    margin-bottom: 18px;
}
.wf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wf-actions .btn i { color: var(--accent); font-size: 11px; }
.assign-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assign-form .form-select { height: 26px; padding: 0 6px; font-size: 12px; }

.chip-divider {
    align-self: stretch;
    width: 1px;
    margin: 2px 6px;
    background: var(--border-strong);
}
.data-table .col-unassigned { color: var(--text-faint); font-style: italic; }

/* — Clients admin ——————————————————————————— */

.pull-result {
    background: var(--success-soft);
    color: var(--success);
    border-radius: var(--radius-sm);
    font-size: 13px;
    padding: 8px 12px;
    margin-bottom: 12px;
}
.add-client-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.add-client-row > div { display: flex; flex-direction: column; }
.add-client-row .btn { margin-bottom: 1px; }

/* — Directory pages (users / clients) ————————————— */

.search-form { display: flex; gap: 6px; }
.search-form input[type="search"] { width: 220px; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; max-width: 100%; }

.detail-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 12px 16px;
    max-width: 560px;
    margin-bottom: 16px;
}
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--text-muted); font-size: 13px; }
.kv dd { margin: 0; }

.user-edit-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.user-edit-form > div { display: flex; flex-direction: column; min-width: 200px; }

.data-table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.candidate-card { max-width: 720px; }

.msg-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    overflow: hidden;
}
.msg-card.from-agent { border-left: 3px solid var(--accent); }
.msg-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 14px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.msg-author { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.msg-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.msg-body { padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-files { padding: 10px 14px; border-top: 1px solid var(--border); }
.msg-files img { border: 1px solid var(--border); border-radius: var(--radius-sm); max-width: 260px; max-height: 200px; }
.msg-files .file-row { font-size: 13px; }
.msg-files .file-size { color: var(--text-muted); }

.reply-box { max-width: 760px; }
.thread { max-width: 760px; }

/* — Attachment picker ————————————————————————— */

.attachment-dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--bg-surface);
    font-size: 13px;
}
.attachment-dropzone:hover, .attachment-dropzone:focus { border-color: var(--accent); color: var(--text); outline: none; }
/* attachments.js toggles Bootstrap's .border-primary while dragging — keep it on-theme. */
.attachment-dropzone.border-primary { border-color: var(--accent) !important; }
.attachment-dropzone .browse-link { text-decoration: underline; color: var(--accent); }
.attachment-picker .attachment-list { font-size: 12px; color: var(--text-muted); }

/* — Forms layout ——————————————————————————— */

.form-card { max-width: 640px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }

/* — Login / register (split brand panel, echoing the Apps Portal) —— */

.login-split {
    min-height: 100vh; min-height: 100dvh;
    display: flex;
    background: var(--bg-app);
}
.login-split *, .login-split *::before, .login-split *::after { box-sizing: border-box; }

.login-brand {
    position: relative;
    flex: 0 0 44%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(165deg, #123832 0%, var(--brand-ink, #0E2329) 78%);
}
.login-contours { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-contours path { fill: none; stroke: #FFFFFF; stroke-opacity: 0.05; stroke-width: 1.4; }
.login-contours path:nth-child(2n) { stroke: #1F7E72; stroke-opacity: 0.18; }
.login-watermark { position: absolute; top: -140px; right: -140px; width: 420px; height: 420px; }
.login-watermark polygon { fill: #FFFFFF; fill-opacity: 0.045; }

.login-brand-content {
    position: relative;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: 18px;
}
.login-mark { width: 84px; height: 84px; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35)); }
.login-wordmark { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.login-wordmark-axis { font-size: 27px; font-weight: 800; letter-spacing: 0.06em; color: #FFFFFF; }
.login-wordmark-geo { font-size: 27px; font-weight: 300; letter-spacing: 0.14em; color: #CDD4D2; }
.login-tagline {
    font-family: var(--font-mono);
    font-size: 11.5px; letter-spacing: 0.32em; text-transform: uppercase;
    color: rgba(205, 212, 210, 0.55);
}
.login-brand-foot {
    position: absolute; bottom: 26px; left: 0; right: 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
    color: rgba(205, 212, 210, 0.45);
}

.login-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form-box { width: 380px; max-width: 100%; }
.login-form-title { font-family: var(--font-serif); font-size: 24px; font-weight: 650; color: var(--text); margin: 0 0 4px; }
.login-form-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 26px; }

.login-form-box .form-control { width: 100%; }
.login-form-box .mb-3 { margin-bottom: 14px; }
.login-submit {
    width: 100%;
    justify-content: center;
    height: 40px;
    font-size: 14px;
    margin-top: 8px;
}
.login-portal-btn {
    width: 100%;
    justify-content: center;
    height: 40px;
    font-size: 14px;
    text-decoration: none;
}
.login-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.login-divider hr { flex: 1; border: none; border-top: 1px solid var(--border); margin: 0; }
.login-divider span { font-size: 12px; color: var(--text-faint); }
.login-alt-row { margin-top: 22px; font-size: 13px; color: var(--text-muted); display: flex; gap: 6px; }

@media (max-width: 860px) {
    .login-brand { display: none; }
}

/* — Mobile ———————————————————————————————— */

@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .nav-drawer-box:checked ~ .sidebar { transform: translateX(0); box-shadow: var(--shadow-md); }
    .nav-toggle { display: inline-flex; }
    .nav-drawer-box:checked ~ .nav-backdrop {
        display: block;
        position: fixed; inset: 0;
        z-index: 1090;
        background: rgba(14, 35, 41, 0.4);
        margin: 0;
    }

    .content { padding: 12px; }
    .top-bar { padding: 0 12px; }
    .btn-sm { height: 32px; padding: 0 10px; }
    .data-table { min-width: 640px; }
}

/* — Blazor plumbing ———————————————————————— */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--radius);
}
.blazor-error-boundary::after { content: "An error has occurred." }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: 12px; margin-top: 3px; }
