@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

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

.brand-logo {
    display: block;
    height: 34px;
    width: auto;
}

.brand-logo-lg {
    height: 52px;
    margin: 0 auto 20px;
}

.brand-logo-invert {
    filter: brightness(0) invert(1);
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4N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Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* Shown only if a quiet reconnect is still running after 10s. */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(255, 255, 255, 0.92);
    text-align: center;
}

#components-reconnect-modal.components-reconnect-show {
    display: flex;
    opacity: 0;
    pointer-events: none;
    animation: ptron-reconnect-in 0.2s ease 10s forwards;
}

#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    animation: none;
}

#components-reconnect-modal .reconnect-failed {
    display: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-pending,
#components-reconnect-modal.components-reconnect-rejected .reconnect-pending {
    display: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-failed {
    display: block;
}

@keyframes ptron-reconnect-in {
    to {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Tipos: desktop keeps the table; phones (Samsung A55 portrait is ~360–412px) get a tappable list. */
.tipos-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tipos-add {
    margin-left: auto;
}

.tipos-phone {
    display: none;
}

.tipos-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 56px;
    padding: 4px 4px 4px 16px;
    border-bottom: 1px solid var(--mud-palette-table-lines);
}

.tipos-row:last-child {
    border-bottom: none;
}

.tipos-nome {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 1rem;
    line-height: 1.3;
}

.tipos-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

/* Insumos: same split as Tipos. The desktop table stays; phones get a card list. */
.insumos-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.insumos-add {
    margin-left: auto;
}

.insumos-phone {
    display: none;
}

.insumos-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 4px 10px 12px;
    border-bottom: 1px solid var(--mud-palette-table-lines);
}

.insumos-row:last-child {
    border-bottom: none;
}

.insumos-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.insumos-foto {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
}

.insumos-foto-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: var(--mud-palette-background-grey);
}

.insumos-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.insumos-nome {
    overflow-wrap: anywhere;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.3;
}

.insumos-meta {
    overflow-wrap: anywhere;
    font-size: 0.8125rem;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
}

.insumos-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

.insumos-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.insumos-pager-label {
    text-align: center;
    font-size: 0.875rem;
}

/* Equipamentos: same split as Insumos. Desktop keeps the table; phones get a card list. */
.equipamentos-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.equipamentos-add {
    margin-left: auto;
}

.equipamentos-phone,
.equipamentos-bom-phone {
    display: none;
}

.equipamentos-row,
.equipamentos-bom-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 4px 10px 12px;
    border-bottom: 1px solid var(--mud-palette-table-lines);
}

.equipamentos-row:last-child,
.equipamentos-bom-row:last-child {
    border-bottom: none;
}

.equipamentos-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.equipamentos-foto {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: var(--mud-palette-background-grey);
}

.equipamento-photo-preview {
    display: block;
    width: min(100%, 280px);
    max-height: 220px;
    height: auto;
    object-fit: contain;
    background: var(--mud-palette-background-grey);
}

.equipamentos-foto-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: var(--mud-palette-background-grey);
}

.equipamentos-text,
.equipamentos-bom-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.equipamentos-nome {
    overflow-wrap: anywhere;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.3;
}

.equipamentos-meta {
    overflow-wrap: anywhere;
    font-size: 0.8125rem;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
}

.equipamentos-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

/* The file input sits on top of the button so the tap is a real user gesture.
   Opening the picker after a server round-trip is blocked on phones. */
.equipamento-photo-trigger {
    position: relative;
    overflow: hidden;
}

.equipamento-photo-file {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

@media (max-width: 599.98px) {
    .tipos-page {
        margin-top: -1.5rem;
    }

    .tipos-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .tipos-add {
        margin-left: 0;
        width: 100%;
        min-height: 48px;
    }

    .tipos-phone {
        display: block;
    }

    .tipos-desktop {
        display: none;
    }

    .insumos-page {
        margin-top: -1.5rem;
    }

    .insumos-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .insumos-add {
        margin-left: 0;
        width: 100%;
        min-height: 48px;
    }

    .insumos-filters {
        padding: 12px !important;
    }

    .insumos-phone {
        display: block;
    }

    .insumos-desktop {
        display: none;
    }

    .equipamentos-page {
        margin-top: -1.5rem;
    }

    .equipamentos-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .equipamentos-add {
        margin-left: 0;
        width: 100%;
        min-height: 48px;
    }

    .equipamentos-phone,
    .equipamentos-bom-phone {
        display: block;
    }

    .equipamentos-desktop,
    .equipamentos-bom-desktop {
        display: none;
    }

    .mud-dialog-container:has(.tipo-flow-dialog),
    .mud-dialog-container:has(.insumo-flow-dialog),
    .mud-dialog-container:has(.equipamento-flow-dialog) {
        align-items: flex-start;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .mud-dialog:has(.tipo-flow-dialog),
    .mud-dialog:has(.insumo-flow-dialog),
    .mud-dialog:has(.equipamento-flow-dialog) {
        width: auto;
        max-width: none;
        align-self: stretch;
        margin: 12px;
    }

    /* Keep an open list inside the screen so it cannot grow the page and bounce. */
    .mud-popover.mud-popover-open {
        max-height: min(240px, calc(100dvh - 96px));
        overscroll-behavior: contain;
    }

    .mud-dialog:has(.tipo-flow-dialog) .mud-dialog-actions,
    .mud-dialog:has(.insumo-flow-dialog) .mud-dialog-actions,
    .mud-dialog:has(.equipamento-flow-dialog) .mud-dialog-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 8px;
        padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .mud-dialog:has(.tipo-flow-dialog) .mud-dialog-actions .mud-button-root,
    .mud-dialog:has(.insumo-flow-dialog) .mud-dialog-actions .mud-button-root,
    .mud-dialog:has(.equipamento-flow-dialog) .mud-dialog-actions .mud-button-root {
        margin: 0;
        margin-left: 0 !important;
        width: 100%;
        min-height: 48px;
    }

    .mud-dialog:has(.insumo-flow-dialog) .mud-dialog-actions .mud-spacer {
        display: none;
    }

    .mud-dialog:has(.insumo-flow-dialog) .insumo-photo-row {
        flex-wrap: wrap;
    }

    .mud-dialog:has(.insumo-flow-dialog) .insumo-photo-row .mud-file-upload,
    .mud-dialog:has(.insumo-flow-dialog) .insumo-photo-row .mud-button-root {
        width: 100%;
        min-height: 48px;
    }

    .mud-dialog:has(.insumo-flow-dialog) .insumo-photo-row .mud-icon-button {
        width: 48px;
        height: 48px;
    }

    .equipamentos-phone .equipamentos-foto {
        width: 72px;
        height: 72px;
    }

    .mud-dialog:has(.equipamento-flow-dialog) .equipamento-photo-preview {
        width: 100%;
        max-height: min(240px, 42dvh);
    }

    .mud-dialog:has(.equipamento-flow-dialog) .equipamento-photo-row {
        flex-wrap: wrap;
    }

    .mud-dialog:has(.equipamento-flow-dialog) .equipamento-photo-trigger,
    .mud-dialog:has(.equipamento-flow-dialog) .equipamento-add-insumo {
        width: 100%;
        min-height: 48px;
    }

    .mud-dialog:has(.equipamento-flow-dialog) .equipamento-photo-row .mud-icon-button {
        width: 48px;
        height: 48px;
    }
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    flex: 0 0 auto;
}

.brand-logo img {
    height: 100%;
    width: auto;
    display: block;
}

/* Official wordmark is navy, so keep it on a light chip in dark mode. */
.brand-logo-ondark {
    background: #ffffff;
    border-radius: 8px;
    padding: 4px 8px;
}
