/* The compare page: the view switch on its own row, a toolbar row per view, then the two editors. */

:root {
    /* The navigation arrows' signature colour. */
    --nav-arrow-color: #AAFF00;
}

.view-switch-row {
    padding: 0.25rem 0 0.5rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.view-switch .mud-toggle-item {
    min-width: 9rem;
    font-size: 1rem;
    font-weight: 600;
}

/* The active view: a dark to light blue fade, the page's own accent rather than a flat theme colour. */
.view-switch .mud-toggle-item.mud-toggle-item-selected {
    background: var(--brand-gradient);
    color: #fff;
}

.view {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Three columns with equal sides, so the middle (Compare, the arrows) sits between the two editors. */
.view-toolbar {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.toolbar-start,
.toolbar-middle,
.toolbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-start { grid-column: 1; justify-self: start; }
.toolbar-middle { grid-column: 2; position: relative; }
.toolbar-end { grid-column: 3; justify-self: end; gap: 0.25rem; }

@media (max-width: 599.98px) {
    .view-toolbar {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    /* Three views do not fit at 9rem each on a phone: share the width equally instead. */
    .view-switch {
        width: 100%;
    }

    .view-switch .mud-toggle-item {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* Small buttons, large icons: the icon fills the button instead of the button growing. MudIconButton has no icon
   size of its own (the text buttons use IconSize). */
.view-toolbar .mud-icon-button-size-small .mud-icon-root {
    font-size: 1.75rem;
}

.toolbar-menu {
    display: inline-flex;
    border-radius: 50%;
    position: relative;
}

/* Something in the menu is not at its default (the settings cog when a difference type is unticked). */
.toolbar-menu-dot::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px var(--mud-palette-surface);
    pointer-events: none;
}

.nav-buttons {
    display: inline-flex;
    align-items: center;
}

.nav-arrow:not(:disabled) {
    color: var(--nav-arrow-color);
}

.diff-count {
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* The counter hangs to the right of the arrows without taking space, so the arrows never move when it changes. */
.toolbar-middle .diff-count {
    position: absolute;
    left: 100%;
    margin-left: 0.5rem;
}

.toolbar-menu-panel {
    width: min(22rem, 85vw);
    padding: 0.75rem 1rem;
}

.toolbar-menu-panel-wide {
    width: min(28rem, calc(100vw - 32px));
}

/* The Log view: corrections made to broken input, per document. */
.repair-log {
    padding: 0.5rem 0;
    gap: 1.25rem;
}

.repair-log-list {
    margin: 0.5rem 0 0.75rem 1.5rem;
    font-family: var(--mud-typography-default-family);
}

.repair-log-list li {
    margin: 0.125rem 0;
}

.repair-log-none {
    color: var(--mud-palette-text-secondary);
}

/* The repair warning above the panes: the theme's warning yellow is too light for text on the light theme. */
.repair-warning .mud-alert-message,
.repair-warning .mud-alert-icon {
    color: #6b5000;
}

.theme-dark .repair-warning .mud-alert-message,
.theme-dark .repair-warning .mud-alert-icon {
    color: #ffd54f;
}

/* The difference types table in the settings cog. */
.difference-types-help {
    display: block;
    color: var(--mud-palette-text-secondary);
}

.difference-types-scroll {
    overflow-x: auto;
}

.difference-types-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.875rem;
}

.difference-types-table th {
    font-weight: 500;
    text-align: center;
    padding: 0.25rem;
}

.difference-types-table thead th {
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

.difference-types-table tbody th,
.difference-types-table thead th:first-child {
    text-align: left;
}

.difference-types-table td {
    text-align: center;
    padding: 0;
}

.difference-types-table td .mud-checkbox {
    margin: 0;
    justify-content: center;
}

.difference-types-table tbody tr + tr {
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* Editors: side by side from md up, stacked on phones. */
.editor-cell {
    height: max(20rem, calc(100vh - 14rem));
}

.editor-cell .CodeMirror {
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 6px;
}

.editor-cell .CodeMirror-focused {
    border-color: var(--mud-palette-primary);
}

@media (max-width: 959.98px) {
    .editor-cell {
        height: 55vh;
    }
}

/* CodeMirror in dark mode: its default theme is light. MainLayout puts .theme-dark on the layout. */
.theme-dark .CodeMirror {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.theme-dark .CodeMirror-gutters {
    background: var(--mud-palette-background-gray);
    border-right-color: var(--mud-palette-lines-default);
}

.theme-dark .CodeMirror-linenumber {
    color: #6f6e80;
}

.theme-dark .CodeMirror-cursor {
    border-left-color: var(--mud-palette-text-primary);
}

.theme-dark .CodeMirror-selected,
.theme-dark .CodeMirror-focused .CodeMirror-selected {
    background: #3a3a55;
}

.theme-dark .CodeMirror .cm-tag { color: #7fb3ff; }
.theme-dark .CodeMirror .cm-attribute { color: #9cdcfe; }
.theme-dark .CodeMirror .cm-qualifier,
.theme-dark .CodeMirror .cm-atom { color: #b5cea8; }
.theme-dark .CodeMirror .cm-string { color: #ce9178; }
.theme-dark .CodeMirror .cm-comment { color: #6a9955; }
.theme-dark .CodeMirror .cm-meta { color: #c586c0; }
.theme-dark .CodeMirror .cm-bracket { color: #9a9aa8; }

/* Highlights keep their colours; text on them stays dark so it remains readable. */
/* CodeMirror puts the highlight class on the same span as the token class, so these must beat .CodeMirror .cm-*. */
.theme-dark .CodeMirror span.highlight-major-added,
.theme-dark .CodeMirror span.highlight-major-missing,
.theme-dark .CodeMirror span.highlight-minor-added,
.theme-dark .CodeMirror span.highlight-minor-missing,
.theme-dark .CodeMirror span.blink-box {
    color: #111;
}

.theme-dark .highlight-major-added span,
.theme-dark .highlight-major-missing span,
.theme-dark .highlight-minor-added span,
.theme-dark .highlight-minor-missing span {
    color: #111;
}

/* Ignored differences in dark mode: a dim grey that stays behind the counted colours. */
.theme-dark {
    --code-mirror-difference-color-ignored: #3a3a48;
}

.theme-dark .CodeMirror span.highlight-ignored,
.theme-dark .highlight-ignored span {
    color: #9a9aa8;
}

/* Phones: the toolbar wraps and starts with the arrows, so the counter can follow them in the flow without moving
   them (instead of hanging over the icons). */
@media (max-width: 599.98px) {
    .toolbar-middle .diff-count {
        position: static;
        margin-left: 0;
    }
}

/* Reset at the start, Save at the end, under the rules in the settings cog. */
.settings-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

/* An editor that files are dragged over: dropping replaces its text (two files fill both editors). */
.editor-cell .CodeMirror.file-drop-target {
    outline: 2px dashed var(--mud-palette-primary);
    outline-offset: -2px;
}
