/* AiPortal — workspace layout (tree resize, full-height editor, font scale) */

.aiportal-page {
    /* --aiportal-font-scale set inline on AiPortalPage.razor */
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--medico-topbar-h, 48px) - 3rem);
    min-height: 32rem;
    margin: -0.5rem -0.25rem 0;
}

.aiportal-page .aiportal-toolbar {
    flex-shrink: 0;
}

.aiportal-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
    align-items: stretch;
}

.aiportal-tree-pane {
    flex: 0 0 auto;
    width: 22rem;
    min-width: 14rem;
    max-width: 48vw;
    resize: horizontal;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.aiportal-tree-pane .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.aiportal-tree-pane .card-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    max-height: none !important;
    font-size: calc(0.875rem * var(--aiportal-font-scale));
}

.aiportal-tree-pane .aiportal-chart-tree {
    font-size: calc(0.875rem * var(--aiportal-font-scale));
}

.aiportal-chart-tree .e-list-text,
.aiportal-chart-tree .e-fullrow {
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.35;
}

.aiportal-editor-pane {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.aiportal-editor-pane .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.aiportal-editor-pane .card-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    max-height: none !important;
    font-size: calc(0.9rem * var(--aiportal-font-scale));
}

.aiportal-editor-pane .dynamic-ai-form,
.aiportal-editor-pane .auto-form-renderer,
.aiportal-editor-pane .e-richtexteditor,
.aiportal-editor-pane textarea.form-control,
.aiportal-editor-pane .portal-quill-host {
    min-height: 100%;
}

.portal-quill-editor .portal-quill-host {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
}

.portal-quill-editor .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem 0.25rem 0 0;
}

.portal-quill-editor .ql-container.ql-snow {
    border: none;
    font-size: calc(0.9rem * var(--aiportal-font-scale));
    min-height: 14rem;
}

.portal-readable-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.35rem 0 0.75rem;
    font-size: 0.9em;
}

.portal-readable-table th,
.portal-readable-table td {
    border: 1px solid var(--bs-border-color, #dee2e6);
    padding: 0.25rem 0.5rem;
    vertical-align: top;
    text-align: left;
}

.portal-readable-table th {
    width: 30%;
    background: var(--bs-tertiary-bg, #f8f9fa);
    font-weight: 600;
}

.portal-readable-card {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bs-body-bg, #fff);
}

.portal-readable-badge {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--bs-secondary-color, #6c757d);
}

.portal-readable-block h5 {
    margin: 0.5rem 0 0.25rem;
    font-size: 0.95em;
}

.aiportal-html-tree {
    font-size: calc(0.875rem * var(--aiportal-font-scale));
}

.aiportal-html-tree .aiportal-html-tree {
    margin-left: 0.75rem;
}

.aiportal-html-tree-leaf {
    width: 100%;
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
    cursor: pointer;
}

.aiportal-html-tree .aiportal-node-filled  { color: #198754; font-weight: 600; }
.aiportal-html-tree .aiportal-node-empty   { color: #dc3545; opacity: 0.85; }
.aiportal-html-tree .aiportal-node-partial { color: #d97706; font-weight: 600; }
.aiportal-html-tree .aiportal-node-historical-abnormal { color: #b45309; font-weight: 700; }

.aiportal-side-pane {
    flex: 0 0 18rem;
    min-width: 14rem;
    max-width: 28vw;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.aiportal-side-pane .card-body {
    max-height: none !important;
}

.aiportal-font-controls .btn {
    min-width: 2rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

/* Tree-node traffic lights — data completeness cues (green=all, amber=partial, red=none).
   Class is applied via SfTreeView HtmlAttributes to the <li> element.
   Amber (#d97706) replaces Bootstrap warning (#ffc107) which is invisible on white. */
.aiportal-chart-tree .aiportal-node-filled  .e-list-text { color: #198754; font-weight: 600; }
.aiportal-chart-tree .aiportal-node-empty   .e-list-text { color: #dc3545; opacity: 0.8; }
.aiportal-chart-tree .aiportal-node-partial .e-list-text { color: #d97706; }
.aiportal-chart-tree .aiportal-node-historical-abnormal .e-list-text { color: #b45309; font-weight: 700; }

/* Collapsed app sidebar (portal default) */
.medico-shell-sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    border: none;
}

.medico-shell-sidebar-toggle {
    border: 1px solid #d0d7e2;
    background: #fff;
    color: #1a4a8a;
    border-radius: 0.25rem;
    padding: 0.2rem 0.55rem;
    line-height: 1.2;
    font-size: 0.85rem;
}

.medico-shell-sidebar-toggle:hover {
    background: #e8f1fb;
}

.portal-html-editor-surface {
    min-height: 12rem;
}

.portal-html-editor-body {
    min-height: 11rem;
    outline: none;
    line-height: 1.45;
}

.portal-html-editor-body ul.portal-html-bullet-editor,
.portal-html-editor-body ul {
    margin: 0.35em 0 0.6em 1.1rem;
    padding-left: 1rem;
}

.portal-html-editor-body li {
    margin: 0.25em 0;
}

.portal-html-readonly {
    background: #f8f9fa;
}

.portal-json-probe-body {
    max-height: 14rem;
    overflow: auto;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.5rem;
    white-space: pre-wrap;
}
