/* Migration module (iSolveMigration, integrated into TeamiSolveHub.WebApp). Scoped to .app-* classes
   only - deliberately does NOT bring over the original app.css's global .rz-button/.rz-card/.rz-data-grid
   overrides, since those would silently restyle every OTHER module's Radzen controls too.
   Layout rules tied to the standalone app's own <main class="container-fluid"> wrapper are dropped as
   well (this host has no such element) - .app-migrations-page/.app-scripts-page carry their own
   padding directly instead, so they don't depend on a parent wrapper this app doesn't have.
   The --app-* custom properties ARE brought over (unlike the rule above) - several Razor files
   reference them directly in inline Style/IconColor attributes, which a fallback inside this file's
   OWN rules can't help with. The distinct "--app-" prefix makes collision with anything else in this
   app very unlikely. */

/* NOT Migration-specific, but the fix lives here since this is where the bug first surfaced: the
   sticky header (MainLayout) is `z-index:1040`, and Radzen's dialog wrapper
   renders with a lower z-index by default (set inline at runtime, not via a CSS class this app
   already overrides) - so ANY RadzenDialog in this app opens visually BEHIND the header instead of
   on top of it, with its own left portion painted over. !important is required to beat Radzen's
   inline z-index. Confirmed via Radzen.Blazor.dll's own string table (7.0.5): .rz-dialog-wrapper is
   the real class Radzen renders - .rz-dialog-mask (guessed from material-base.css's own selector
   list) does not actually exist in this version, so it never matched anything. */
.rz-dialog-wrapper {
    z-index: 2000 !important;
}
:root {
    --app-bg: #f4f6f9;
    --app-surface: #ffffff;
    --app-surface-muted: #f6f8fb;
    --app-border: #cfd8e5;
    --app-text: #172033;
    --app-text-muted: #667085;
    --app-primary: #2d5f9a;
    --app-primary-dark: #244f80;
    --app-primary-soft: #edf3fb;
    --app-shadow: 0 8px 20px rgba(31, 41, 55, 0.09);
}

.material-symbols-outlined {
    vertical-align: middle;
    font-size: 1.25rem;
    line-height: 1;
}

.app-migrations-page {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem 1rem;
}

.app-migrations-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--app-border, #cfd8e5);
    border-radius: 0.45rem;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.06);
}

.app-migrations-grid-shell {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--app-border, #cfd8e5);
    border-radius: 0.45rem;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.06);
}

.app-migrations-grid-shell .rz-data-grid td {
    line-height: 1.3;
}

.app-migrations-grid-shell .rz-data-grid td .small {
    font-size: 0.78rem;
}

.app-migrations-grid-shell .rz-data-grid {
    width: 100%;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none;
}

.app-scripts-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.75rem;
    min-height: 0;
    padding: 0.75rem 1rem 1rem;
    overflow-y: auto;
}

.app-scripts-page.is-loading,
.app-script-preview.is-loading {
    opacity: 0.42;
    pointer-events: none;
}

.app-scripts-toolbar {
    display: grid;
    grid-template-columns: minmax(18rem, 0.9fr) 12rem minmax(24rem, 1.5fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0.65rem;
    border: 1px solid var(--app-border, #cfd8e5);
    border-radius: 0.45rem;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.06);
}

.app-scripts-filter,
.app-scripts-upload {
    min-width: 0;
}

.app-scripts-upload {
    align-self: stretch;
}

.app-scripts-note {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 1rem;
    margin-top: 0.18rem;
    color: var(--app-text-muted, #667085);
    font-size: 0.72rem;
    font-weight: 600;
}

.app-scripts-note .material-symbols-outlined {
    color: var(--app-primary, #2d5f9a);
    font-size: 0.95rem;
}

.app-scripts-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(23rem, 0.42fr);
    gap: 0.75rem;
    align-items: stretch;
    min-height: 0;
    height: calc(100vh - 14rem);
    overflow: hidden;
    transition: grid-template-columns 220ms ease, gap 220ms ease;
}

.app-scripts-workspace.is-preview-collapsed {
    grid-template-columns: minmax(0, 1fr) 0fr;
    gap: 0;
}

.app-script-list {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.7rem;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.app-list-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.45rem;
    height: 100%;
    padding-top: 0;
}

.app-list-actions .rz-button {
    width: 2.25rem;
    height: 2.25rem;
}

.app-grid-shell {
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    border: 1px solid var(--app-border, #cfd8e5);
    border-radius: 0.45rem;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.06);
}

.app-grid-shell .rz-data-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none;
}

.app-grid-shell .rz-data-grid-table {
    width: 100% !important;
    min-width: 0 !important;
}

.app-grid-shell .rz-button {
    width: 1.85rem;
    height: 1.85rem;
    min-width: 1.85rem;
    padding: 0 !important;
}

.app-script-preview {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    border: 1px solid var(--app-border, #cfd8e5);
    border-radius: 0.45rem;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.06);
    opacity: 1;
    transform: translateX(0);
    transition: opacity 180ms ease, transform 220ms ease, border-color 180ms ease;
    will-change: opacity, transform;
}

.app-scripts-workspace.is-preview-collapsed .app-script-preview {
    min-width: 0;
    border-color: transparent;
    opacity: 0;
    pointer-events: none;
    transform: translateX(0.75rem);
}

.app-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 3.2rem;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--app-border, #cfd8e5);
    background: #f8fafc;
}

.app-preview-actions {
    display: inline-flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.app-preview-title {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #1f2937;
    font-size: 0.92rem;
    font-weight: 800;
}

.app-preview-title span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-preview-body {
    min-height: 0;
    height: 100%;
    max-height: calc(100vh - 14rem);
    overflow: auto;
    background: #ffffff;
}

.app-preview-body pre[class*="language-"] {
    height: max-content;
    min-height: 100%;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.app-preview-empty {
    min-height: 0;
    height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.7rem;
    padding: 2rem;
    color: var(--app-text-muted, #667085);
    text-align: center;
    background: linear-gradient(180deg, #f8fafc, #ffffff);
}

.app-preview-empty .material-symbols-outlined {
    font-size: 2.6rem;
    color: rgba(21, 91, 213, 0.42);
}

.app-preview-empty p {
    margin: 0;
    font-weight: 700;
}

.app-status-links {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    vertical-align: middle;
}

.app-status-links > span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--rz-border-radius, 4px);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease;
}

.app-status-links > span.app-status-danger {
    color: var(--rz-danger, #f44336);
}

.app-status-links > span.app-status-danger:hover {
    background-color: var(--rz-danger-lighter);
}

.app-status-links > span.app-status-warning {
    color: var(--rz-warning, #ff9800);
}

.app-status-links > span.app-status-warning:hover {
    background-color: var(--rz-warning-lighter);
}

.app-status-links .material-symbols-outlined {
    font-size: 0.95rem;
}

.app-install-fieldset .rz-form-field .material-symbols-outlined {
    color: var(--app-text-muted, #667085);
}

/* Scoped segmented-control look for the Databases status filter (RadzenSelectBar) - matches the
   connected/no-inner-radius look without touching TeamiSolveHub's own site-wide button radius rule. */
.app-migrations-filters .rz-selectbar .rz-button {
    border-radius: 0 !important;
}

.app-migrations-filters .rz-selectbar.rz-selectbar-horizontal .rz-button:first-child {
    border-start-start-radius: 0.45rem !important;
    border-end-start-radius: 0.45rem !important;
}

.app-migrations-filters .rz-selectbar.rz-selectbar-horizontal .rz-button:last-child {
    border-start-end-radius: 0.45rem !important;
    border-end-end-radius: 0.45rem !important;
}

@media (max-width: 1199.98px) {
    .app-scripts-toolbar,
    .app-scripts-workspace {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .app-script-preview {
        min-height: 22rem;
    }
}

@media (max-width: 767.98px) {
    .app-scripts-toolbar {
        padding: 0.75rem;
    }

    .app-script-list {
        grid-template-columns: 1fr;
    }

    .app-list-actions {
        flex-direction: row;
    }

    .app-preview-body {
        max-height: 70vh;
    }
}
