/*
 * Shared route-level admin experience.
 * Page-local isolated CSS owns domain layout; this file owns the visual system
 * that must remain consistent across every routed surface.
 */

.admin-page {
    display: grid;
    gap: var(--ops-space-6);
    min-width: 0;
}

.admin-page--wide {
    width: 100%;
}

.admin-page-stack {
    display: grid;
    gap: var(--ops-space-4);
    min-width: 0;
}

.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--ops-space-3);
}

.admin-surface,
.ops-panel,
.tool-catalog-toolbar,
.tool-catalog-row,
.channel-create,
.channel-list,
.mailbox-state,
.mailbox-message,
.workflow-library,
.workflow-workspace,
.workflow-builder,
.workflow-json-panel,
.workflow-history-grid > div,
.workflow-runs {
    border: 1px solid var(--ops-border);
    border-radius: var(--ops-radius-card);
    background: var(--ops-card);
    box-shadow: var(--ops-shadow);
}

.ops-content :where(
    button,
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    textarea,
    select,
    summary,
    a
):focus-visible {
    outline: 3px solid var(--ops-focus);
    outline-offset: 2px;
}

.ops-content :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
    textarea,
    select
) {
    min-height: var(--ops-control-height);
    border: 1px solid var(--ops-control-border);
    border-radius: var(--ops-radius-control);
    color: var(--ops-text);
    background: #fff;
    box-shadow: var(--ops-field-shadow);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.ops-content :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
    textarea,
    select
):focus {
    border-color: var(--ops-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.13);
    outline: none;
}

.ops-content :where(input, textarea, select):disabled {
    cursor: not-allowed;
    opacity: 0.56;
}

.ops-admin-shell .ops-content select:not([multiple]):is(:not([size]), [size="1"]) {
    appearance: none;
    padding-inline-end: calc(2 * var(--ops-space-3) + var(--ops-space-4));
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23252b35' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--ops-space-3) center;
    background-size: var(--ops-space-4);
}

@media (forced-colors: active) {
    .ops-admin-shell .ops-content select:not([multiple]):is(:not([size]), [size="1"]) {
        appearance: auto;
        background-image: none;
    }
}

.ops-button:is(:disabled, [aria-disabled="true"], .is-disabled),
:root .ops-admin-shell .ops-content :is(button:disabled, .ops-button[aria-disabled="true"], .ops-button.is-disabled) {
    border-color: var(--ops-border);
    color: var(--ops-text);
    background: var(--ops-sidebar-selected);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 1;
}

.ops-content input[type="file"] {
    width: 100%;
    min-width: 0;
    padding: 6px;
    border: 1px dashed var(--ops-control-border);
    border-radius: var(--ops-radius-control);
    color: var(--ops-muted);
    background: var(--ops-surface-raised);
}

.ops-content input[type="file"]::file-selector-button {
    min-height: 34px;
    margin-inline-end: 10px;
    padding: 0 12px;
    border: 1px solid var(--ops-border-strong);
    border-radius: 8px;
    color: var(--ops-text);
    background: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.ops-content :where(button, a) {
    -webkit-tap-highlight-color: transparent;
}

.ops-content :where(
    .agent-create-link,
    .tool-catalog-agents-link,
    .studio-export,
    .workflow-export,
    .ops-link-button
) {
    min-height: var(--ops-control-height);
    border-radius: var(--ops-radius-control);
}

.ops-content .orleans-dashboard-link {
    color: var(--ops-accent-text);
}

.ops-content :where(
    .agent-create-link,
    .workflow-primary-action
) {
    color: #fff;
    border-color: var(--ops-accent-strong);
    background: var(--ops-accent-strong);
}

.ops-content :where(code, pre, textarea[spellcheck="false"]) {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

.ops-content :where(.ops-eyebrow) {
    color: var(--ops-accent-text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.ops-content :where(.ops-loading-card) {
    min-height: min(360px, 48vh);
    border: 1px solid var(--ops-border);
    border-radius: var(--ops-radius-card);
    background: rgba(255, 255, 255, 0.72);
}

.ops-content .agent-lab .admin-page-header .agent-lab-status {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 12px;
    border-color: rgba(0, 99, 204, 0.12);
    border-radius: 999px;
    background: var(--ops-accent-soft);
    box-shadow: none;
}

.ops-content .agent-lab .admin-page-header .agent-lab-status strong {
    color: var(--ops-accent-text);
    font-size: 16px;
}

@media (max-width: 620px) {
    .ops-content .agent-row .agent-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ops-content .agent-lab .agent-lab-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ops-content #evaluation .evaluation-grid {
        display: flex;
        gap: 10px;
        margin-inline: calc(var(--ops-page-padding) * -1);
        padding-inline: var(--ops-page-padding);
        overflow-x: auto;
        scroll-padding-inline: var(--ops-page-padding);
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
    }

    .ops-content #evaluation .evaluation-grid > * {
        flex: 0 0 min(82vw, 310px);
        min-height: 176px;
        scroll-snap-align: start;
    }

    .ops-content .studio-page .definition-actions {
        position: static;
        padding: 12px;
        backdrop-filter: none;
    }

    .ops-content .studio-page {
        padding-bottom: 0;
    }

    .ops-content .observability-page .admin-task-tabs {
        gap: 4px;
        padding: 4px;
        overflow: visible;
    }

    .ops-content .observability-page .admin-task-tab {
        flex: 1 1 0;
        min-width: 0;
        padding-inline: 7px;
    }

    .ops-content .observability-page .admin-task-tab > span {
        overflow: hidden;
        font-size: 11px;
        text-overflow: ellipsis;
    }

    .ops-content .observability-page .admin-task-tab > small {
        display: none;
    }
}

@media (min-width: 1400px) {
    .ops-main:has(.workflow-studio, .agent-workflow-studio) {
        --ops-content-max: none;
        --ops-page-padding: clamp(28px, 2vw, 56px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
