/* ---------- DESIGN TOKENS ----------
   Every component stylesheet uses these, so shapes, colors and shadows stay the same everywhere.
   The diagram (NpmJS/src/CodeGraphView.js) reads the --kind-*, --edge-* and --accent colors. */
:root {
    /* Shape: controls are --radius, surfaces (dialogs, popovers, banners, drop zones) --radius-lg. */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.18);

    /* Neutrals */
    --text: #1f2328;
    --text-muted: #57606a;
    --text-subtle: #6b7480;
    --border: #d8dee4;
    --border-strong: #9aa4ae;
    --divider: #eef1f4;
    --surface: #ffffff;
    --surface-muted: #f6f8fa;
    --surface-sunken: #f0f2f5;
    --hover: #eef1f4;
    --hover-strong: #e3e7ec;
    --pane-header: var(--surface-muted);

    /* Brand (header, selection in the diagram), the interactive orange, and the main action.
       --primary is a deeper orange than --cta, so text in it stays readable on --primary-soft. */
    --accent: #f25958;
    --primary: #b8480a;
    --primary-hover: #9a3c08;
    --primary-soft: #fdeee3;
    --primary-faint: #fff8f2;
    --primary-border: #f3b48a;
    --cta: #d9590a;
    --cta-hover: #bf4e08;
    --focus-ring: 0 0 0 0.2rem rgba(217, 89, 10, 0.3);

    --font-mono: Consolas, "Cascadia Mono", Menlo, monospace;

    --icon-folder: #c08a1e;
    --icon-file: #6b8fbf;

    /* Diagram: classes (the most common kind) and calls take the app's orange;
       the other kinds keep hues of their own, well away from orange, so they stay easy to tell apart. */
    --kind-class: #c4560c;
    --kind-class-fill: #fdf0e6;
    --kind-interface: #23855a;
    --kind-interface-fill: #e9f6ef;
    --kind-struct: #6f7a0f;
    --kind-struct-fill: #f3f5df;
    --kind-record: #7c4dbd;
    --kind-record-fill: #f3edfb;
    --kind-enum: #be185d;
    --kind-enum-fill: #fce8f1;
    --kind-delegate: #0e7490;
    --kind-delegate-fill: #e6f5f8;
    --kind-module: #a16207;
    --kind-module-fill: #fdf6dc;
    --kind-external: #8c939b;
    --kind-external-fill: #f4f5f6;
    --kind-namespace: #57606a;
    --kind-namespace-fill: #f6f7f9;

    --edge-inherits: #2f3337;
    --edge-implements: #23855a;
    --edge-uses: #8c939b;
    --edge-calls: #d9590a;
    --edge-renders: #7c4dbd;

    /* Bootstrap follows the same shapes and colors. */
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: var(--radius);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-border-radius-pill: var(--radius-pill);
    --bs-border-color: var(--border);
    --bs-body-color: var(--text);
    --bs-primary: var(--primary);
    --bs-primary-rgb: 184, 72, 10;
    --bs-link-color-rgb: 184, 72, 10;
    --bs-link-hover-color-rgb: 154, 60, 8;
}

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    overflow-x: hidden;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--primary);
}

    a:hover, .btn-link:hover {
        color: var(--primary-hover);
    }

/* ---------- BUTTONS ---------- */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
}

/* The main action (Generate). */
.btn-cta {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--cta);
    --bs-btn-border-color: var(--cta);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--cta-hover);
    --bs-btn-hover-border-color: var(--cta-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--cta-hover);
    --bs-btn-active-border-color: var(--cta-hover);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--cta);
    --bs-btn-disabled-border-color: var(--cta);
    --bs-btn-focus-shadow-rgb: 217, 89, 10;
    font-weight: 600;
}

/* A button that is just an icon: close, hide a pane, dismiss. */
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    flex: 0 0 auto;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: none;
    color: var(--text-muted);
}

    .icon-button:hover {
        background-color: var(--hover-strong);
        color: var(--text);
    }

/* ---------- MENUS ----------
   The list that drops down from a toolbar button: the download formats (Layout/Main.razor)
   and the dropdowns (Components/DropdownSelect.razor). Each one positions itself. */

/* Catches clicks outside a menu to close it. */
.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
}

.menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 20;
    min-width: 15rem;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    box-shadow: var(--shadow-lg);
}

    .menu button {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        width: 100%;
        padding: 0.45rem 0.6rem;
        border: none;
        border-radius: var(--radius);
        background: none;
        color: var(--text);
        text-align: left;
    }

        .menu button + button {
            margin-top: 2px;
        }

        .menu button:hover {
            background-color: var(--hover);
        }

        .menu button .icon {
            color: var(--text-muted);
        }

        /* The current choice in a dropdown. */
        .menu button.selected {
            background-color: var(--primary-soft);
            color: var(--primary);
        }

            .menu button.selected .icon {
                color: var(--primary);
            }

.menu-label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

    .menu-label small {
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: normal;
    }

.menu-check {
    margin-left: auto;
}

/* Inline SVG icons (Components/Icon.razor) sit on the text baseline and never shrink in flex rows. */
.icon {
    flex-shrink: 0;
    vertical-align: -0.15em;
}

/* ---------- FORMS ---------- */
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--primary-border);
}

/* One focus ring for every control: Bootstrap's and the app's own. */
.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.icon-button:focus-visible,
.chip:focus-visible,
.activity-button:focus-visible,
.zoom-controls button:focus-visible,
.tree-toggle:focus-visible,
.about-button:focus-visible,
.toggle:focus-visible,
.menu-button:focus-visible,
.dropdown-button:focus-visible,
.menu button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Line briefly highlighted after jumping to it from the diagram (MonacoInterop.js). */
.monaco-reveal-highlight {
    background: rgba(242, 89, 88, 0.18);
}

.page {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ---------- UNHANDLED ERROR (index.html) ---------- */
#blazor-error-ui {
    color-scheme: light only;
    position: fixed;
    left: 50%;
    bottom: 1rem;
    z-index: 1100;
    display: none; /* Blazor sets display: block when there is an error */
    width: min(36rem, calc(100vw - 2rem));
    padding: 0.65rem 0.6rem 0.65rem 1rem;
    border: 1px solid #f1aeb5;
    border-left: 4px solid #d1242f;
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 0.9rem;
    transform: translateX(-50%);
}

    #blazor-error-ui .error-ui-content {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    #blazor-error-ui .error-ui-icon {
        flex-shrink: 0;
        color: #d1242f;
    }

    #blazor-error-ui .error-ui-text {
        flex: 1 1 auto;
    }

    #blazor-error-ui .reload {
        font-weight: 600;
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
    }

/* ---------- LOADING SCREEN (index.html) ---------- */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--divider);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--accent);
            stroke-linecap: round;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }
