/* Styles for the shared components in src/Pages/Shared and src/Pages/Console/Shared, grouped by component. */

/* SectionTile, AppIcon */
.sh-tile.mud-avatar {
    flex: none;
    color: var(--sh-on-tile);
}

.sh-tile-md.mud-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--sh-radius-sm);
}

.sh-tile-md.mud-avatar .mud-icon-root {
    font-size: 18px;
}

.sh-tile-lg.mud-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--sh-radius);
}

.sh-tile-lg.mud-avatar .mud-icon-root {
    font-size: 22px;
}

.sh-appicon {
    flex: none;
    border-radius: min(24%, var(--sh-radius-lg));
    overflow: hidden;
    background: var(--sh-raised);
    color: var(--mud-palette-text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sh-avatar {
    position: relative;
}

.sh-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sh-avatar-img.sh-loaded {
    background: var(--mud-palette-surface);
}

.sh-avatar-img.sh-failed {
    visibility: hidden;
}

/* ImageCropper */
.sh-crop-area {
    height: 320px;
    border-radius: var(--sh-radius);
    overflow: hidden;
    background: var(--sh-raised);
}

.sh-crop-area img {
    display: block;
    max-width: 100%;
}

.sh-crop .cropper-container {
    overflow: hidden;
}

.sh-crop .cropper-view-box {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: -2px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
}

.sh-crop-round .cropper-view-box,
.sh-crop-round .cropper-face {
    border-radius: 50%;
}

.sh-crop-rounded .cropper-view-box,
.sh-crop-rounded .cropper-face {
    border-radius: 22%;
}

/* PageHeader, SectionHeader, breadcrumbs */
.sh-page-header {
    margin-bottom: 12px;
}

.sh-page-title {
    flex: 1 1 280px;
    min-width: 0;
}

.sh-page-title h1 {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.sh-section-header {
    margin-bottom: 6px;
}

.sh-breadcrumbs.mud-breadcrumbs {
    padding: 0;
    margin-bottom: 8px;
    font-size: 13px;
}

/* QuickTile, SubpageShortcut */
.sh-quick-tile.mud-button-root {
    height: 100%;
    min-height: 56px;
    padding: 10px 12px;
    border-radius: var(--sh-radius-lg);
    background: var(--mud-palette-surface);
}

.sh-quick-tile.mud-button-root:hover {
    background: var(--sh-raised);
}

.sh-quick-tile .mud-button-label {
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
}

.sh-quick-tile-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sh-quick-tile-title.mud-typography {
    font-weight: 600;
}

.sh-quick-tile-arrow {
    color: var(--mud-palette-text-disabled);
}

.sh-shortcut.mud-button-root {
    min-width: 0;
    padding: 4px;
    border-radius: var(--sh-radius);
}

/* SearchField */
.sh-search.mud-input-control {
    width: 220px;
    margin: 0;
    flex: none;
}

.sh-search .mud-input.mud-input-outlined {
    background: var(--sh-raised);
    border-radius: var(--sh-radius-sm);
}

.sh-search .mud-input-outlined-border {
    border-color: transparent;
}

/* FilterMenu */
.sh-filter-menu {
    position: relative;
    display: inline-flex;
}

.sh-filter-popover.mud-popover {
    min-width: 220px;
}

.sh-click-away {
    position: fixed;
    inset: 0;
    z-index: 1100;
}

/* Lists with one link per row (Apps page) */
.sh-list .mud-table-cell {
    padding: 4px 6px;
}

.sh-list.mud-table-hover .mud-table-row:hover {
    background: transparent;
}

.sh-row-link.mud-button-root {
    flex: 1;
    min-width: 0;
    min-height: 36px;
    padding: 4px 8px;
    border-radius: var(--sh-radius);
}

.sh-row-link .mud-button-label {
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
}

.sh-row-title.mud-typography {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mud-table-row.sh-clickable-row {
    cursor: pointer;
}

/* IconLink */
.sh-icon-link {
    display: inline-flex;
    padding: 2px;
    border-radius: var(--sh-radius);
    color: var(--mud-palette-text-secondary);
}

.sh-icon-link:hover {
    color: var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent);
}

/* Main column of a table: takes the free width and cuts long text instead of pushing the other columns out. */
@media (min-width: 600px) {
    .mud-table .mud-table-cell.sh-cell-fill {
        width: 100%;
        max-width: 0;
    }
}

@media (max-width: 599px) {
    .mud-table .mud-table-cell.sh-cell-fill > * {
        flex: 1 1 0;
        width: 0;
        justify-content: flex-end;
        text-align: right;
    }
}

.sh-cell-fill .mud-typography {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* UserNameCell and other emphasised cells */
.sh-user-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.sh-user-cell > * {
    flex-shrink: 0;
}

.sh-user-cell .mud-icon-root {
    font-size: 16px;
}

.sh-user-cell-email.mud-typography {
    margin-left: 2px;
    flex: 0 1 auto;
    min-width: 0;
}

.sh-user-cell-name.mud-typography {
    font-weight: 600;
}

/* The email gives way first; the name is only cut when it does not fit on its own. */
.sh-user-cell > .sh-user-cell-name.mud-typography {
    max-width: 100%;
}

.sh-role-chips {
    flex-wrap: wrap;
}

/* Role chips stay on one line in tables; the rest is behind "+N more". */
.mud-table-cell .sh-role-chips {
    flex-wrap: nowrap;
}

/* PropertyList, PropertyRow */
.sh-prop-list.mud-paper {
    padding: 2px 14px;
}

.sh-prop-list-head {
    min-height: 40px;
    padding-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sh-prop-list-title.mud-typography {
    flex: 1;
}

/* A table inside a PropertyList uses the panel instead of its own. */
.sh-prop-list .mud-table {
    padding: 0;
    background: transparent;
}

.sh-prop-list-danger.mud-paper {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mud-palette-error) 40%, transparent);
}

.sh-prop-row {
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    border-bottom: 1px solid var(--sh-raised);
}

.sh-prop-row:last-child {
    border-bottom: 0;
}

.sh-prop-label {
    flex: 0 0 130px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sh-prop-label > .mud-typography-body2 {
    font-weight: 500;
}

.sh-prop-value {
    flex: 1 1 200px;
    min-width: 0;
}

.sh-secret.mud-typography {
    height: var(--sh-control-height);
    box-sizing: border-box;
    padding: 0 12px;
    border-radius: var(--sh-radius-sm);
    background: var(--mud-palette-background);
    color: var(--mud-palette-text-secondary);
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ImageEditFrame */
.sh-image-edit-button .mud-icon-root.mud-icon-size-medium {
    font-size: 16px;
}

.sh-image-edit {
    position: relative;
    flex: none;
    display: inline-flex;
}

.sh-image-edit-button.mud-button-root {
    position: absolute;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    padding: 4px;
    background: var(--sh-control);
    box-shadow: 0 0 0 4px var(--mud-palette-background);
}

/* CopyableText */
.sh-copyable {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--mud-palette-text-secondary);
}

/* StatusMessage (404, access denied) */
.sh-status.mud-container {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.sh-status-code.mud-typography {
    font-weight: 700;
    line-height: 1;
}

.sh-status-icon.mud-avatar {
    width: 72px;
    height: 72px;
    border-radius: var(--sh-radius-lg);
    margin-bottom: 8px;
    background: color-mix(in srgb, var(--mud-palette-warning) 16%, transparent);
    color: var(--mud-palette-warning);
}

.sh-status-icon.mud-avatar .mud-icon-root {
    font-size: 40px;
}

/* SelectionBar */
.sh-selection-bar.mud-paper {
    min-height: 40px;
    margin-bottom: 8px;
    padding: 0 8px 0 4px;
    border-radius: var(--sh-radius);
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* FilterChips */
.sh-filter-chips {
    margin-bottom: 8px;
}

/* DetailLayout, DetailPanel */
.sh-detail-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.sh-detail-main {
    flex: 999 1 520px;
    min-width: 0;
}

.sh-detail-side {
    flex: 0 0 340px;
    min-width: 0;
    position: sticky;
    top: 16px;
}

.sh-detail-empty.mud-paper {
    min-height: 160px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: var(--mud-palette-text-disabled);
}

@media (max-width: 899px) {
    .sh-detail-side {
        flex-basis: 100%;
    }

    .sh-detail-side:has(.sh-detail-empty) {
        display: none;
    }
}

.sh-detail-panel.mud-paper {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sh-detail-title.mud-typography,
.sh-detail-subtitle.mud-typography {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sh-detail-title.mud-typography {
    font-weight: 600;
}

.sh-detail-actions {
    padding-top: 4px;
}

.mud-table-row.sh-row-open {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

/* PropertyList inside side panels */
.sh-prop-list-compact.mud-paper {
    padding: 0 12px;
    background: var(--sh-raised);
}

.sh-prop-list-compact .sh-prop-row {
    min-height: 32px;
    flex-wrap: nowrap;
    border-bottom-color: var(--mud-palette-surface);
}

.sh-prop-list-compact .sh-prop-label {
    flex-basis: 88px;
}

.sh-prop-list-compact .sh-prop-value {
    flex-basis: 0;
}

/* StatTile */
.sh-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 6px;
}

.sh-stat-tile-root {
    display: block;
}

.sh-stat-tile {
    height: 30px;
    padding: 0 8px;
    border-radius: var(--sh-radius-sm);
    background: var(--sh-raised);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sh-stat-tile .sh-stat-icon {
    font-size: 16px;
    color: var(--mud-palette-text-secondary);
}

.sh-stat-value {
    font-size: 14px;
    font-weight: 600;
}

/* MetaItem */
.sh-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    min-width: 0;
}

.sh-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
    color: var(--mud-palette-text-secondary);
}

.sh-meta-item .mud-icon-root {
    font-size: 15px;
}

.sh-meta .mud-chip {
    margin: 0;
}

/* Fixed columns so the meta lines up from row to row. */
.sh-row-link .sh-meta {
    flex: none;
    display: grid;
    grid-template-columns: 76px 48px 92px;
    justify-items: start;
}

/* UploadQueuePanel */
.sh-upload-panel.mud-paper {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1200;
    width: min(340px, calc(100vw - 32px));
    padding: 8px 6px 8px 12px;
    border-radius: var(--sh-radius-lg);
    background: var(--sh-raised);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.sh-upload-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sh-upload-list {
    max-height: 280px;
    overflow-y: auto;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sh-upload-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 6px;
}

.sh-upload-info {
    flex: 1;
    min-width: 0;
}

.sh-upload-name.mud-typography {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sh-upload-bar.mud-progress-linear {
    margin-top: 4px;
}

/* Drop-anywhere overlay on the content page, shown while files are dragged over the window. */
body.sh-dragging-files::after {
    content: "Drop files to upload";
    position: fixed;
    inset: 12px;
    z-index: 1300;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--mud-palette-primary);
    border-radius: var(--sh-radius-lg);
    background: color-mix(in srgb, var(--mud-palette-background) 80%, transparent);
    color: var(--mud-palette-primary);
    font-size: 18px;
    font-weight: 600;
    pointer-events: none;
}
