/* ========================================
   Everest Web Application - Base Styles
   MudBlazor-compatible CSS
   ======================================== */

/* Only essential global resets - do not override MudBlazor */
html, body {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
}


/* Blazor error boundary */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* Blazor error UI - minimal styling */
#blazor-error-ui {
    background: #ffcc00;
    bottom: 0;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Focus styles compatible with MudBlazor */
h1:focus {
    outline: none;
}

/* Validation styles - compatible with MudBlazor */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50990;
}

.validation-message {
    color: #ff4a4a;
}

/* Legacy styles - kept for backward compatibility but scoped */
/* Only applied to non-MudBlazor containers */
.legacy-container .login-wrapper {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.legacy-container .login-card {
    width: 480px;
    padding: 40px;
    border-radius: 12px;
    background: white;
}

.legacy-container .dashboard-wrapper {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
}

.legacy-container .dashboard-card {
    width: 100vh;
    padding: 40px;
    border-radius: 12px;
    background: white;
}

/* Login full-viewport gradient + centered card */
.login-shell {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #594AE2;
    background-size: cover;
    background-position: center;
}

.login-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.03);
    pointer-events: none;
}

.login-card {
    position: relative;
    z-index: 2;
    border-radius: 12px;
    background: var(--mud-palette-surface);
}

/* Table border normalization: avoid double outer borders across pages */
.mud-table-container {
    border: 0 !important;
}

.mud-table-root {
    border-collapse: collapse !important;
}


/* Release notes dialog (sanitized HTML from Download Setup) */
.release-notes-dialog .release-notes-html {
    max-height: min(60vh, 520px);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.release-notes-dialog .release-notes-html :first-child {
    margin-top: 0;
}

.release-notes-dialog .release-notes-html h1,
.release-notes-dialog .release-notes-html h2,
.release-notes-dialog .release-notes-html h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.release-notes-dialog .release-notes-html p,
.release-notes-dialog .release-notes-html li {
    margin-bottom: 0.5rem;
}

.release-notes-dialog .release-notes-html a {
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

.release-notes-dialog .release-notes-html pre,
.release-notes-dialog .release-notes-html code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
}

.release-notes-dialog .release-notes-html table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
}

.release-notes-dialog .release-notes-html th,
.release-notes-dialog .release-notes-html td {
    border: 1px solid var(--mud-palette-lines-default);
    padding: 0.35rem 0.5rem;
    text-align: left;
}

.release-notes-dialog .release-notes-plain {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Responsive MudTable cards for data-heavy admin/customer screens */
@media (max-width: 960px) {
    .mobile-card-table .mud-table-container {
        overflow: visible;
    }

    .mobile-card-table .mud-table-smalldevices-sortselect {
        margin: 0 0 0.85rem;
        padding: 0 0.25rem;
    }

    .mobile-card-table .mud-table-root .mud-table-body {
        display: grid;
        gap: 0.9rem;
    }

    .mobile-card-table .mud-table-root .mud-table-row {
        display: block;
        overflow: hidden;
        border: 1px solid rgba(15, 23, 42, 0.08);
        border-radius: 18px;
        background:
            linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(255, 255, 255, 1) 100%);
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    }

    .mobile-card-table .mud-table-root .mud-table-cell {
        display: grid;
        grid-template-columns: minmax(92px, 120px) minmax(0, 1fr);
        align-items: center;
        column-gap: 0.9rem;
        row-gap: 0.2rem;
        padding: 0.72rem 1rem !important;
        text-align: left !important;
        border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    }

    .mobile-card-table .mud-table-root .mud-table-cell:last-child {
        border-bottom: 0;
        padding-top: 0.9rem !important;
    }

    .mobile-card-table .mud-table-root .mud-table-cell .mud-table-cell-label {
        margin: 0;
        color: #64748b;
        font-size: 0.72rem;
        font-weight: 700;
        line-height: 1.2;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        align-self: start;
    }

    .mobile-card-table .mud-table-root .mud-table-cell .mud-typography-body2,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-typography-caption,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-chip,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-button-root {
        max-width: 100%;
    }

    .mobile-card-table .mud-table-root .mud-table-cell > :not(.mud-table-cell-label) {
        min-width: 0;
        max-width: 100%;
    }

    .mobile-card-table .mud-table-root .mud-table-cell .d-flex,
    .mobile-card-table .mud-table-root .mud-table-cell .d-inline-flex {
        min-width: 0;
        max-width: 100%;
        flex-wrap: wrap;
    }

    .mobile-card-table .mud-table-root .mud-table-cell .mud-typography,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-chip-content,
    .mobile-card-table .mud-table-root .mud-table-cell span,
    .mobile-card-table .mud-table-root .mud-table-cell div {
        max-width: 100%;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .mobile-card-table .mud-table-root .mud-table-cell .mud-avatar,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-icon-button-root,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-button-root,
    .mobile-card-table .mud-table-root .mud-table-cell .mud-chip {
        flex-shrink: 0;
    }

    .mobile-card-table .mud-table-root .mud-table-cell img,
    .mobile-card-table .mud-table-root .mud-table-cell svg {
        max-width: 100%;
    }

    .mobile-card-table .mud-table-root .mud-table-cell[data-label="Action"],
    .mobile-card-table .mud-table-root .mud-table-cell[data-label="Actions"] {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .mobile-card-table .mud-table-root .mud-table-cell[data-label="Action"] .mud-button-root,
    .mobile-card-table .mud-table-root .mud-table-cell[data-label="Actions"] .mud-button-root {
        justify-content: center;
    }

    .mobile-card-table .mobile-table-actions {
        width: 100%;
        justify-content: flex-start !important;
        align-items: center;
    }

    .mobile-card-table .mud-table-root .mud-table-cell[data-label="Action"] .mobile-table-actions .mud-button-root,
    .mobile-card-table .mud-table-root .mud-table-cell[data-label="Actions"] .mobile-table-actions .mud-button-root {
        flex: 1 1 120px;
    }

    .mobile-card-table .mud-table-root .mud-table-cell[data-label="License Key"] .mobile-table-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
    }

    .mobile-card-table .mud-table-pagination {
        justify-content: center;
        padding: 0.75rem 0.5rem 0;
        overflow: visible;
    }

    .mobile-card-table .mud-table-pagination .mud-table-pagination-toolbar,
    .mobile-card-table .mud-table-pagination .mud-toolbar {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.5rem 0.75rem;
        width: 100%;
        min-height: auto;
        padding-inline: 0;
    }

    .mobile-card-table .mud-table-pagination .mud-table-pagination-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .mobile-card-table .mud-table-pagination .mud-input-control {
        min-width: 84px;
    }

    .mobile-card-table .mud-table-pagination .mud-select,
    .mobile-card-table .mud-table-pagination .mud-input {
        max-width: 100%;
    }

    .mobile-card-table .mud-table-pagination .mud-table-pagination-caption,
    .mobile-card-table .mud-table-pagination .mud-typography {
        text-align: center;
        white-space: normal;
    }
}

@media (max-width: 600px) {
    .mobile-card-table .mud-table-root .mud-table-cell {
        grid-template-columns: minmax(76px, 98px) minmax(0, 1fr);
        column-gap: 0.7rem;
        padding: 0.68rem 0.85rem !important;
    }

    .mobile-card-table .mud-table-pagination {
        padding-inline: 0.25rem;
    }

    .mobile-card-table .mud-table-pagination .mud-table-pagination-toolbar,
    .mobile-card-table .mud-table-pagination .mud-toolbar {
        gap: 0.4rem 0.5rem;
    }

    .mobile-card-table .mud-table-pagination .mud-input-control {
        min-width: 72px;
    }
}
