/* Layout for the App Builder's email screens (Email Layout + Email Templates).

   Both screens are the same shape as the Scripted APIs and Script Libraries screens: panes side by
   side, a grip between them, and an editor that fills whatever height is left. The split height is
   measured by js/oc-panes.js (shared with the script screens) because the chrome above it varies;
   CSS only sets the floor.
   The grips themselves — dots, hover, drag, keyboard — come from css/oc-split.css. */

.oc-mail-page {
    display: flex;
    flex-direction: column;
}

.oc-mail-head {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.oc-mail-spacer { flex: 1 1 auto; }

.oc-mail-split {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: 8px;
    /* Height is measured by oc-panes.js. A floor here would win over it and clip the bottom
       of the split once the window is shorter than the floor plus the chrome above it. */
    min-height: 0;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    overflow: hidden;
    background-color: var(--mud-palette-surface);
}

/* The list and the editor share the top row; validation is docked underneath it. */
.oc-mail-main {
    display: flex;
    align-items: stretch;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.oc-mail-list {
    flex: 0 0 var(--oc-mail-list-w, 240px);
    width: var(--oc-mail-list-w, 240px);
    min-width: 150px;
    max-width: 40%;
    overflow: auto;
}

/* In-flow flex item, not an absolutely positioned band: the panes size themselves.
   Sizing only — the grip, hover and drag states come from css/oc-split.css. */
.oc-mail-strip {
    flex: 0 0 9px;
    align-self: stretch;
}

.oc-mail-editor-pane,
.oc-mail-side-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.oc-mail-editor-pane { flex: 1 1 auto; }

.oc-mail-side-pane {
    flex: 0 0 var(--oc-mail-side-h, 280px);
    height: var(--oc-mail-side-h, 280px);
    min-width: 0;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.oc-mail-pane-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 8px;
    min-height: 34px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

/* The files this screen writes, inline on the action row. */
.oc-mail-filepath {
    min-width: 0;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: calc(0.72rem * var(--mudc-text-scale, 1));
    color: var(--mud-palette-text-secondary);
}

.oc-mail-type { max-width: 260px; }

.oc-mail-empty {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    text-align: center;
}

.oc-mail-monaco-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Only the HOST is sized. Monaco writes its own pixel height on .monaco-editor from this box;
   forcing that element to 100% desyncs the widget's internal scroll geometry, which is what made
   scrolling misbehave after a pane was resized. */
.oc-mail-monaco {
    height: 100% !important;
}

.oc-mail-selected { background-color: var(--mud-palette-action-default-hover); }

.oc-mail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    line-height: 1.2;
}

/* Dense rows: the list is a picker, so each entry stays two short lines, not a card. */
.oc-mail-list .mud-list-item {
    padding-top: 3px;
    padding-bottom: 3px;
    min-height: 38px;
}

.oc-mail-item .mud-typography-caption {
    font-size: calc(0.68rem * var(--mudc-text-scale, 1));
}

.oc-mail-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Editor tabs (Definition | Body) ───────────────────────────────────────
   MudBlazor renders panels into .mud-tabs-panels (position: relative), so the body is absolutely
   filled: that works without depending on the panel wrapper's class name, which varies between
   MudBlazor versions. Tab chrome itself is platform-wide (wwwroot/css/oc-tabs.css). */
.oc-mail-tabs {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.oc-mail-tabs .mud-tabs {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.oc-mail-tabs .mud-tabs-panels {
    flex: 1 1 auto;
    min-height: 0;
}

.oc-mail-tabs .mud-tabs-tabbar-wrapper {
    flex: 0 0 auto;
}

.oc-mail-tabs .mud-tabs-panels > * {
    height: 100%;
    min-height: 0;
}

.oc-mail-tab-body {
    position: absolute;
    inset: 0;
    overflow: auto;
    padding: 8px;
}

.oc-mail-tab-body.is-editor {
    display: flex;
    padding: 0;
    overflow: hidden;
}

/* The definition is a form: it scrolls on its own so the pane head never leaves the screen. */
.oc-mail-tab-body.is-form {
    padding: 12px;
}

/* ── Form conventions shared by the definition form and its editors ──────────
   A label sits ABOVE its field (never inside it) and any explanation lives behind an
   info icon, so the surface stays calm. Built once here so every email screen agrees. */
.oc-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 2px;
}

.oc-field-head {
    display: flex;
    align-items: center;
    gap: 6px;
}

.oc-field-head label {
    font-size: calc(0.8125rem * var(--mudc-text-scale, 1));
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

.oc-choice-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.oc-choice {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    padding: 5px 9px;
    cursor: pointer;
    background-color: var(--mud-palette-surface);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.oc-choice:hover {
    border-color: var(--mud-palette-primary);
    background-color: rgb(from var(--mud-palette-primary) r g b / 0.04);
}

.oc-choice.is-selected {
    border-color: var(--mud-palette-primary);
    background-color: rgb(from var(--mud-palette-primary) r g b / 0.1);
    box-shadow: inset 3px 0 0 0 var(--mud-palette-primary);
}

.oc-choice-title {
    font-size: calc(0.8125rem * var(--mudc-text-scale, 1));
    font-weight: 600;
}

.oc-choice-text {
    /* One line: the tile is a pick target, not a paragraph. The full text stays in its tooltip. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: calc(0.71rem * var(--mudc-text-scale, 1));
    color: var(--mud-palette-text-secondary);
    line-height: 1.35;
}

/* Tab chrome comes from css/oc-tabs.css — one standard for every page. Only the layout that
   makes the panels fill this pane lives here. */

/* ── Findings ──────────────────────────────────────────────────────────────── */
.oc-mail-findings {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.oc-mail-finding {
    border: 1px solid var(--mud-palette-lines-default);
    border-left-width: 3px;
    border-radius: var(--mud-default-borderradius);
    padding: 6px 8px;
}

.oc-mail-finding.is-error { border-left-color: var(--mud-palette-error); }
.oc-mail-finding.is-warning { border-left-color: var(--mud-palette-warning); }

.oc-mail-finding-path {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: calc(11px * var(--mudc-text-scale, 1));
    color: var(--mud-palette-text-secondary);
    word-break: break-all;
}

.oc-mail-finding-hint {
    margin-top: 2px;
    font-size: calc(12px * var(--mudc-text-scale, 1));
    color: var(--mud-palette-text-secondary);
}

.oc-mail-ok {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    text-align: center;
}

.oc-mail-banner { margin-top: 8px; }

/* Below the breakpoint the panes stack and the page scrolls. */
@media (max-width: 1100px) {
    /* Stacked: the row wrapper must not absorb the shrink — its fixed-height children are what the
       split scrolls, otherwise the editor's bottom gets clipped instead of reachable. */
    .oc-mail-main { flex-direction: column; flex: 0 0 auto; overflow: visible; }
    .oc-mail-list { flex: 0 0 auto; width: auto; max-width: none; max-height: 160px; border-bottom: 1px solid var(--mud-palette-lines-default); }
    .oc-mail-strip { display: none; }
    .oc-mail-editor-pane { flex: 0 0 460px; height: 460px; }
    .oc-mail-side-pane { flex: 0 0 320px; width: auto; max-width: none; height: 320px; border-left: none; border-top: 1px solid var(--mud-palette-lines-default); }
}
