/*
 * Django port only: CSS for the parts MudBlazor did in JS (popovers, tooltips, dialogs, snackbar),
 * plus the cookie banner styles (copied from CookieBanner.razor.css, which was CSS-isolated).
 */

[hidden] {
    display: none !important;
}

/* Popovers are placed by CSS below their anchor, which needs position: relative */
.cornea-popover-anchor {
    position: relative;
}

.mud-popover.mud-popover-open.cornea-popover-below-left {
    top: 100%;
    left: 0;
}

.mud-popover.mud-popover-open.cornea-popover-below-center {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
}

/* MudTooltip: text in data-tooltip, shown above (default) or below (data-placement="bottom") */
.cornea-tooltip {
    position: relative;
}

.cornea-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 300px;
    padding: 8px 12px;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.4em;
    text-align: center;
    border-radius: var(--mud-default-borderradius);
    color: var(--mud-palette-dark-text);
    background-color: var(--mud-palette-gray-darker);
    z-index: var(--mud-zindex-tooltip);
    pointer-events: none;
    animation: cornea-fade-in var(--cornea-hover-transition);
}

.cornea-tooltip:not([data-placement="bottom"]):hover::after {
    bottom: calc(100% + 8px);
}

.cornea-tooltip[data-placement="bottom"]:hover::after {
    top: calc(100% + 8px);
}

/* MudCheckBox: both icons are rendered, the checked state picks one */
.mud-checkbox-input:not(:checked) ~ .cornea-checkbox-checked,
.mud-checkbox-input:checked ~ .cornea-checkbox-unchecked {
    display: none;
}

/* Tooltips in the last table column open towards the left: centered over the rightmost button they would stick out of
   MudBlazor's table container (overflow-x: auto), which then shows a horizontal scrollbar */
.mud-table-cell:last-child .cornea-tooltip:hover::after {
    left: auto;
    right: 0;
    transform: none;
}

/* Scans dialog (belts_scans.html): long file names wrap and the action buttons wrap onto a second line, so the table
   fits the dialog and the table container never shows a horizontal scrollbar; the container does not clip at all, so
   the tooltips can stick out above the first row (the dialog scrolls vertically) */
.cornea-scans-table .mud-table-container {
    overflow: visible;
}

.cornea-scans-table .mud-table-cell:first-child {
    overflow-wrap: anywhere;
}

/* MudSelect as a native <select>: the arrow is drawn by the adornment. MudBlazor's and app.css's rules
   for the value slot only match div/input, so they are repeated here, with vertical padding for the height */
.cornea-native-select {
    appearance: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: block;
    box-sizing: content-box;
    width: 100%;
    min-width: 0;
    height: 1lh;
    margin: 0;
    padding: 16px 2rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: transparent;
    border: 0;
    outline: 0;
}

.cornea-native-select option {
    color: var(--mud-palette-text-primary);
    background-color: #1a1d26;
}

/* The arrow lies over the right end of the <select> (the room is its 2rem padding) instead of next to it as a flex
   sibling: a click on the arrow then reaches the <select>, which opens its list */
.cornea-select-arrow {
    pointer-events: none;
    position: absolute;
    top: 0;
    bottom: 0;
    right: 14px;
    height: auto;
    max-height: none;
    margin-top: 0;
}

/* Where the browser allows styling the option list (customizable select), it looks like MudSelect's
   popover; elsewhere the native list stays */
@supports (appearance: base-select) {
    .cornea-native-select,
    .cornea-native-select::picker(select) {
        appearance: base-select;
    }

    .cornea-native-select::picker-icon,
    .cornea-native-select option::checkmark {
        display: none;
    }

    .cornea-native-select::picker(select) {
        margin-top: 4px;
        padding: 8px 0;
        border: 0;
        border-radius: 15px;
        background-color: #1a1d26;
        box-shadow: var(--mud-elevation-8);
    }

    .cornea-native-select option {
        padding: 8px 16px 8px 2rem;
        color: #735a86;
    }

    .cornea-native-select option:hover,
    .cornea-native-select option:focus-visible {
        background-color: var(--cornea-row-tint);
    }

    .cornea-native-select option:checked {
        color: #d9cdff;
    }
}

/* MudExpansionPanel as <details> */
summary.mud-expand-panel-header {
    list-style: none;
}

summary.mud-expand-panel-header::-webkit-details-marker {
    display: none;
}

/* Menu items can be links or form buttons */
a.mud-menu-item,
button.mud-menu-item {
    width: 100%;
    color: inherit;
    font: inherit;
    text-align: start;
    text-decoration: none;
    background: none;
    border: 0;
}

.mud-snackbar {
    transition: opacity 0.5s;
}

.mud-snackbar.cornea-snackbar-hiding {
    opacity: 0;
}

.consent-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1200;
    padding: 24px;
    transform: translateY(calc(100% + 32px));
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s ease-in-out;
}

.consent-notice.slide-in {
    transform: translateY(0);
    opacity: 1;
}

.consent-notice-content {
    max-width: 1200px;
    margin: 0 auto;
    border: 2px solid var(--mud-palette-primary);
    border-radius: 12px;
    box-shadow: 0px 8px 24px rgba(104, 48, 186, 0.3);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .consent-notice {
        padding: 12px;
    }

    .consent-notice-content {
        border-radius: 8px;
    }

    /* Force vertical stacking on mobile */
    .consent-notice .mud-stack {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Full width button on mobile */
    .consent-notice .mud-button-root {
        width: 100%;
        margin-top: 8px;
    }

    /* Adjust icon size on mobile */
    .consent-notice .mud-icon-root {
        font-size: 1.75rem;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .consent-notice-content {
        max-width: 95%;
    }

    .consent-notice {
        padding: 20px;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    .consent-notice {
        padding: 24px;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .consent-notice {
        transition: opacity 0.2s ease-in-out;
    }

    .consent-notice.slide-in {
        transform: translateY(0);
    }
}

/* Interaction states, the one place for them (MudBlazor's 6% tints and app.css's hover rules are overridden or gone).
   Hovering changes colour, background or border, never size or position; a click is a stronger tint; keyboard focus
   looks like hover plus an outline; everything fades over the same 150ms. Three tiers: the big rounded buttons keep
   their solid fill; every other action (text buttons, chips that open a menu, panel headers, the switch, the select,
   the burger) gets the tint of --cornea-hover-color (the primary, change it here), icon buttons the white tint of
   --cornea-icon-hover-color (the primary was too weak behind a small icon); menu items, the team switcher, select
   options and clickable table rows get the neutral row tint. Pages with their own styling (report.css, belt.css) are
   not touched. */
:root {
    --cornea-hover-color: var(--mud-palette-primary);
    --cornea-hover-tint: color-mix(in srgb, var(--cornea-hover-color) 18%, transparent);
    --cornea-active-tint: color-mix(in srgb, var(--cornea-hover-color) 32%, transparent);
    --cornea-icon-hover-color: white;
    --cornea-icon-hover-tint: color-mix(in srgb, var(--cornea-icon-hover-color) 18%, transparent);
    --cornea-icon-active-tint: color-mix(in srgb, var(--cornea-icon-hover-color) 32%, transparent);
    --cornea-row-tint: #3a3747;
    --cornea-hover-transition: 150ms ease;
}

@keyframes cornea-fade-in {
    from {
        opacity: 0;
    }
}

.mud-button-root,
.mud-link,
.mud-menu-item,
.mud-list-item-clickable,
.mud-nav-item,
.mud-menu-activator .mud-chip,
summary.mud-expand-panel-header,
.mud-switch-base,
.cornea-select div.mud-input,
.cornea-native-select option,
.menu-button svg,
.mud-table-hover .mud-table-row {
    transition: background-color var(--cornea-hover-transition), color var(--cornea-hover-transition),
        border-color var(--cornea-hover-transition), box-shadow var(--cornea-hover-transition);
}

/* Tier 2: the tint */
.mud-button-text:hover,
.mud-button-text:focus-visible,
summary.mud-expand-panel-header:hover,
summary.mud-expand-panel-header:focus-visible,
.mud-switch-base:hover,
.cornea-select div.mud-input:hover,
.cornea-select div.mud-input:focus-within,
.menu-button svg:hover {
    background-color: var(--cornea-hover-tint);
}

.mud-button-text:active,
.menu-button svg:active {
    background-color: var(--cornea-active-tint);
}

.mud-icon-button:hover,
.mud-icon-button:focus-visible {
    background-color: var(--cornea-icon-hover-tint);
}

.mud-icon-button:active {
    background-color: var(--cornea-icon-active-tint);
}

/* The chip that opens the role menu is already grey, so it takes the stronger tint (the activator itself is display: contents) */
.mud-menu-activator:hover .mud-chip,
.mud-menu-activator:focus-visible .mud-chip {
    background-color: var(--cornea-active-tint);
}

.mud-menu-activator:active .mud-chip {
    background-color: var(--cornea-hover-color);
}

.mud-menu-activator {
    cursor: pointer;
}

.menu-glass-button:disabled:hover {
    background-color: #FFFFFF20;
}

/* Tier 1: the solid fill of the big buttons */
.rounded-button:hover,
.rounded-button:focus-visible {
    color: var(--mud-palette-text-primary);
    background-color: var(--mud-palette-primary);
}

.rounded-button:active {
    background-color: var(--mud-palette-primary-darken);
}

.warning-button:hover,
.warning-button:focus-visible {
    color: var(--mud-palette-text-primary);
    background-color: var(--mud-palette-error);
}

.warning-button:active {
    background-color: var(--mud-palette-error-darken);
}

.filled-button:hover,
.filled-button:focus-visible,
.filled-button:active {
    color: var(--mud-palette-text-secondary);
    background-color: var(--mud-palette-secondary-darken);
}

.mud-fab-primary:hover,
.mud-fab-primary:focus-visible {
    background-color: var(--mud-palette-primary-darken);
}

/* Tier 3: rows and list items */
.mud-menu-item:hover,
.mud-menu-item:focus-visible,
.mud-list-item-clickable:hover,
.mud-list-item-clickable:focus-visible,
.team-switcher-item:hover,
.team-switcher-item:focus-visible,
.mud-nav-item:hover,
.mud-nav-item:focus-within,
.mud-table-hover .mud-table-container .mud-table-root .mud-table-body .mud-table-row:hover {
    background-color: var(--cornea-row-tint);
}

/* Links: underline (MudBlazor) and a lighter colour */
.mud-link.mud-primary-text:hover,
.mud-link.mud-primary-text:focus-visible {
    color: var(--mud-palette-primary-lighten) !important;
}

/* Keyboard focus */
.mud-button-root:focus-visible,
.mud-link:focus-visible,
.mud-menu-item:focus-visible,
.mud-menu-activator:focus-visible,
summary.mud-expand-panel-header:focus-visible,
.cornea-native-select:focus-visible {
    outline: 2px solid var(--cornea-hover-color);
    outline-offset: 2px;
}

/* Arabic: the layout stays left-to-right, but every text orders itself by its own script, so that Arabic sentences
   keep their punctuation and numbers at the right end (the same rule is in belt.css and report.css). */
html[lang="ar"] body * {
    unicode-bidi: plaintext;
}

/* The scans page (pages/scans.html): one link per scan with thumbnail, belt and team, uploader and company, date */
.scan-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scan-row {
    display: grid;
    grid-template-columns: 128px 1fr 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 8px 16px 8px 8px;
    border-radius: 12px;
    background-color: #1a1d26;
    color: inherit;
    text-decoration: none;
}

.scan-row:hover,
.scan-row:focus-visible {
    background-color: #FFFFFF20;
}

.scan-row-thumbnail {
    width: 128px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    background-color: #FFFFFF10;
}

.scan-row-texts {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-wrap: anywhere;
}

@media only screen and (max-width: 767px) {
    .scan-row {
        grid-template-columns: 128px 1fr;
    }

    .scan-row-thumbnail {
        grid-row: 1 / span 3;
        align-self: start;
    }

    .scan-row > :not(.scan-row-thumbnail) {
        grid-column: 2;
    }
}

/* the fifth menu button (the scans page) is centered below the two columns */
.menu-glass-button:nth-child(5) {
    grid-column: 1 / -1;
    justify-self: center;
    animation-delay: 0.4s;
}
