/* Login/change-password pages are static SSR (see Login.razor's HttpContext comment), so their
   fields stay plain Blazor InputText/InputCheckbox - MudTextField's @bind-Value can't reach the
   server without an active circuit. This gives those inputs a MudBlazor-consistent floating-label
   look, reusing MudBlazor's own theme CSS variables (set by MudThemeProvider). The label's
   floated/resting state is driven by the .focused/.filled classes toggled in site.js. */

body {
    margin: 0;
    background: var(--mud-palette-background, #f5f5f5);
    font-family: var(--mud-typography-default-family, sans-serif);
}

.gb-navbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--mud-palette-surface, #fff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 10;
}

.gb-navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mud-palette-text-primary, #424242);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .01em;
    margin-right: 16px;
    white-space: nowrap;
}

.gb-navbar-brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--mud-palette-primary, #594ae2);
    flex-shrink: 0;
}

.gb-navbar-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.gb-navbar-link {
    color: var(--mud-palette-text-secondary, #757575);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: var(--mud-default-borderradius, 4px);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.gb-navbar-link:hover {
    color: var(--mud-palette-primary, #594ae2);
    background: rgba(89, 74, 226, 0.08);
}

.gb-navbar-link.active {
    color: var(--mud-palette-primary, #594ae2);
    background: rgba(89, 74, 226, 0.1);
}

/* <details>/<summary> dropdown for a nav group (e.g. "Privati" -> "Da gestire"/"Gestite") - native
   disclosure widget, no JS: click toggles [open], full-page navigation (this app is static SSR)
   closes it again for free. */
.gb-navbar-dropdown {
    position: relative;
}

.gb-navbar-dropdown > summary {
    cursor: pointer;
    list-style: none;
}

.gb-navbar-dropdown > summary::-webkit-details-marker {
    display: none;
}

.gb-navbar-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    display: flex;
    flex-direction: column;
    min-width: 160px;
    padding: 6px;
    background: var(--mud-palette-surface, #fff);
    border-radius: var(--mud-default-borderradius, 4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 20;
}

.gb-navbar-dropdown-menu .gb-navbar-link {
    padding: 8px 12px;
}

.gb-navbar-profile {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary, #757575);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.gb-navbar-profile-icon {
    flex-shrink: 0;
}

.gb-navbar-logout {
    color: var(--mud-palette-text-secondary, #757575);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--mud-default-borderradius, 4px);
    border: 1px solid var(--mud-palette-lines-inputs, #c4c4c4);
    margin-left: 16px;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.gb-navbar-logout:hover {
    color: var(--mud-palette-error, #f44336);
    border-color: var(--mud-palette-error, #f44336);
    background: rgba(244, 67, 54, 0.06);
}

.gb-password-value {
    background: rgba(0, 0, 0, 0.06);
    border-radius: var(--mud-default-borderradius, 4px);
    padding: 2px 6px;
    margin: 0 4px;
    font-family: var(--mud-typography-caption-family, monospace);
}

.gb-copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: var(--mud-default-borderradius, 4px);
    background: transparent;
    color: inherit;
    cursor: pointer;
    vertical-align: middle;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.gb-copy-button:hover {
    background: rgba(0, 0, 0, 0.08);
}

.gb-copy-button.copied {
    color: var(--mud-palette-success, #4caf50);
}

.gb-copy-button.copy-failed {
    color: var(--mud-palette-error, #f44336);
}

.form-field {
    position: relative;
    margin-top: 20px;
}

.form-field input {
    box-sizing: border-box;
    width: 100%;
    padding: 18px 12px 6px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--mud-palette-text-primary, #424242);
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--mud-palette-lines-inputs, #c4c4c4);
    border-radius: var(--mud-default-borderradius, 4px);
    outline: none;
    transition: border-color 0.15s ease, border-width 0.15s ease;
}

.form-field input:focus {
    border-color: var(--mud-palette-primary, #594ae2);
    border-width: 2px;
    padding: 17px 11px 5px;
}

.form-field label {
    position: absolute;
    left: 12px;
    top: 18px;
    color: var(--mud-palette-text-secondary, #757575);
    font-size: 1rem;
    pointer-events: none;
    transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease;
}

.form-field.focused label,
.form-field.filled label {
    top: 2px;
    font-size: 0.75rem;
}

.form-field.focused label {
    color: var(--mud-palette-primary, #594ae2);
}

.form-field .validation-message {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--mud-palette-error, #f44336);
}

/* Browser autofill (e.g. a saved login/password) sets an input's value without firing input/change
   events, so site.js's own listeners never see it and the label stays overlapping the autofilled
   text. WebKit/Blink fire this no-op animation on autofilled inputs specifically so JS can hook
   into it (there's no other reliable cross-browser signal) - see site.js's animationstart listener. */
@keyframes form-field-autofill-start {
    from {}
    to {}
}

.form-field input:-webkit-autofill {
    animation-name: form-field-autofill-start;
}

/* Admin console (Admin.razor) - same "native controls styled by hand" approach as the form-field
   inputs above, extended to selects/tables since MudSelect/MudTable also need an interactive
   circuit that this static SSR page doesn't have. */

.admin-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.admin-select {
    box-sizing: border-box;
    min-width: 200px;
    height: 42px;
    padding: 8px 12px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--mud-palette-text-primary, #424242);
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--mud-palette-lines-inputs, #c4c4c4);
    border-radius: var(--mud-default-borderradius, 4px);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #e0e0e0);
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.admin-actions form {
    display: inline-flex;
}

/* Create/edit "modal" for Admin.razor - plain fixed-position overlay + centered card, no JS and
   no MudDialog/IDialogService (both need an interactive circuit this static SSR page doesn't
   have). Open/close state comes entirely from the URL (?new=true / ?editXxxId=), same as every
   other piece of state on this page - Cancel is just a link back without that query parameter. */

.admin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
    overflow-y: auto;
    z-index: 1300;
}

.admin-modal {
    width: 100%;
    max-width: 640px;
    height: fit-content;
    animation: dg-modal-in .15s ease-out;
}

.admin-readonly-field {
    display: flex;
    align-items: center;
    min-width: 200px;
    color: var(--mud-palette-text-secondary, #757575);
}

.admin-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-plugin-pages {
    color: var(--mud-palette-text-secondary, #66788a);
    font-size: 0.8125rem;
    margin-left: 4px;
}

/* Dynamic Grid demo (DynamicGridDemoPage.razor) - same "native controls styled by hand" approach
   as the admin-table/form-field rules above; this page is static SSR too (GET postback, see its
   own top-of-file comment), so there's no MudTable/MudSelect circuit to lean on here either.
   Header row, filter row and data rows are one <table> (not two, as before) so columns always
   line up regardless of how many are filterable. */

.dg-page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 32px 24px;
}

.dg-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.dg-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dg-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--mud-palette-text-primary, #424242);
    margin: 0;
}

.dg-subtitle {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary, #757575);
    margin: 4px 0 0;
    max-width: 640px;
}

.dg-count-badge {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary, #757575);
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--mud-palette-lines-default, #e0e0e0);
    border-radius: var(--mud-default-borderradius, 4px);
    padding: 6px 12px;
    white-space: nowrap;
}

.dg-card {
    background: var(--mud-palette-surface, #fff);
    border-radius: var(--mud-default-borderradius, 4px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    margin-top: 20px;
    overflow: hidden;
}

/* Scrolls horizontally instead of clipping when the table (driven by however many columns a grid
   has) is wider than the card - wraps only the <table>, not the whole .dg-card, so a future sticky
   toolbar/footer inside the card would stay put while just the columns scroll. */
.dg-table-wrap {
    overflow-x: auto;
}

.dg-table {
    /* min-width wins over width whenever the natural (unconstrained) content width is larger, which
       is exactly what lets a many-column table grow past 100% and trigger .dg-table-wrap's scroll -
       width: 100% still fills the card when columns are few. */
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
}

.dg-table th,
.dg-table td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #f0f0f0);
    font-size: 0.875rem;
    color: var(--mud-palette-text-primary, #424242);
}

/* Keeps a column's content on one line (e.g. "Gestita il"'s timestamp) instead of wrapping
   awkwardly mid-value when the table has many columns competing for width. */
.dg-nowrap {
    white-space: nowrap;
}

.dg-thead-row {
    background: var(--mud-palette-background, #faf9fe);
}

.dg-thead-row th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mud-palette-text-secondary, #757575);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-bottom: 8px;
}

.dg-filter-row td {
    padding-top: 8px;
    padding-bottom: 14px;
}

.dg-th-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dg-th-link:hover {
    color: var(--mud-palette-primary, #594ae2);
}

.dg-filter-input,
.dg-filter-select {
    box-sizing: border-box;
    width: 100%;
    height: 34px;
    padding: 6px 8px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--mud-palette-text-primary, #424242);
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--mud-palette-lines-inputs, #c4c4c4);
    border-radius: var(--mud-default-borderradius, 4px);
    outline: none;
}

.dg-filter-input:focus,
.dg-filter-select:focus {
    border-color: var(--mud-palette-primary, #594ae2);
    border-width: 2px;
    padding: 5px 7px;
}

.dg-row:hover td {
    background: var(--mud-palette-background, #f7f6fd);
}

.dg-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.dg-badge-yes {
    background: #e3f6e8;
    color: #1e7d3a;
}

.dg-badge-no {
    background: #fbe9e9;
    color: #b3261e;
}

.dg-badge-pending {
    background: #fff4e0;
    color: #92600b;
}

.dg-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--mud-palette-lines-default, #e0e0e0);
    background: var(--mud-palette-background, #faf9fe);
}

.dg-btn {
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: .02em;
    border-radius: var(--mud-default-borderradius, 4px);
    padding: 7px 16px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    display: inline-block;
}

.dg-btn-primary {
    background: var(--mud-palette-primary, #594ae2);
    color: #fff;
}

.dg-btn-primary:hover {
    background: var(--mud-palette-primary-darken, #4a3dd0);
}

.dg-btn-text {
    background: transparent;
    color: var(--mud-palette-primary, #594ae2);
    padding: 7px 10px;
}

.dg-btn-text:hover {
    background: rgba(89, 74, 226, 0.08);
}

.dg-row-action-icon {
    width: 1.25rem;
    height: 1.25rem;
    vertical-align: text-bottom;
    margin-right: .25rem;
}

/* Row-action buttons/links that show only their icon (label moved to a title/aria-label tooltip
   instead) - square padding instead of dg-btn-text's text-oriented padding, and no gap after the
   icon since there's no label following it. */
.dg-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px;
}

.dg-btn-icon .dg-row-action-icon {
    margin-right: 0;
}

.dg-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.dg-pagination-info {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary, #757575);
}

.dg-pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dg-page-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--mud-default-borderradius, 4px);
    border: 1px solid var(--mud-palette-lines-inputs, #c4c4c4);
    background: var(--mud-palette-surface, #fff);
    color: var(--mud-palette-text-primary, #424242);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.dg-page-btn:hover {
    border-color: var(--mud-palette-primary, #594ae2);
    color: var(--mud-palette-primary, #594ae2);
}

.dg-page-btn-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.dg-page-label {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-primary, #424242);
    padding: 0 6px;
}

.dg-row-actions {
    white-space: nowrap;
    text-align: right;
}

/* Keeps the row-actions column in view while .dg-table-wrap scrolls the rest of the columns
   horizontally - needs its own opaque background per row type since a transparent sticky cell
   would let the scrolling columns behind it show through. */
.dg-sticky-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--mud-palette-surface, #fff);
    box-shadow: 1px 0 0 var(--mud-palette-lines-default, #f0f0f0);
}

.dg-thead-row .dg-sticky-col {
    background: var(--mud-palette-background, #faf9fe);
}

.dg-row:hover .dg-sticky-col {
    background: var(--mud-palette-background, #f7f6fd);
}

/* Panel content for the .admin-modal-overlay backdrop (shared with Users.razor) - a plain-HTML
   sibling to that overlay's .admin-modal since this page doesn't use MudPaper elsewhere. Laid out
   as header/body/footer flex rows (not just "overflow-y: auto on the whole card") so a long
   transcript scrolls inside .dg-modal-body while the header and the note-modal's Annulla/Conferma
   footer (.dg-toolbar) stay put - and so overflow:hidden here can clip both to the card's own
   rounded corners instead of leaving square corners peeking out under a scrollbar. */
.dg-modal {
    width: 100%;
    max-width: 640px;
    max-height: min(720px, calc(100vh - 96px));
    display: flex;
    flex-direction: column;
    background: var(--mud-palette-surface, #fff);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    animation: dg-modal-in .15s ease-out;
}

@keyframes dg-modal-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.dg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #ececec);
    flex-shrink: 0;
}

.dg-modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}

.dg-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--mud-palette-text-secondary, #6e6e6e);
    text-decoration: none;
    flex-shrink: 0;
}

.dg-modal-close:hover {
    background: var(--mud-palette-background, #f5f5f7);
    color: var(--mud-palette-text-primary, #424242);
}

.dg-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.dg-field-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--mud-palette-text-secondary, #66788a);
    margin-bottom: 8px;
}

.dg-textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--mud-palette-text-primary, #424242);
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--mud-palette-lines-inputs, #c4c4c4);
    border-radius: var(--mud-default-borderradius, 4px);
    outline: none;
    resize: vertical;
}

.dg-textarea:focus {
    border-color: var(--mud-palette-primary, #594ae2);
    border-width: 2px;
    padding: 11px 13px;
}

/* "Vedi conversazione" modal's status/summary line, above the transcript bubbles. */
.dg-transcript-meta-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #ececec);
}

.dg-transcript-summary {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary, #757575);
}

.dg-transcript {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dg-transcript-turn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    max-width: 80%;
    border-radius: 14px;
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--mud-palette-lines-default, #ececec);
}

.dg-transcript-turn-agent {
    align-self: flex-end;
    background: var(--mud-palette-primary, #594ae2);
    border-color: transparent;
    border-bottom-right-radius: 4px;
}

.dg-transcript-turn-agent .dg-transcript-meta,
.dg-transcript-turn-agent .dg-transcript-time {
    color: rgba(255, 255, 255, 0.75);
}

.dg-transcript-turn-agent .dg-transcript-meta strong,
.dg-transcript-turn-agent .dg-transcript-text {
    color: #fff;
}

.dg-transcript-turn-customer {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.dg-transcript-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary, #6e6e6e);
}

.dg-transcript-time {
    font-variant-numeric: tabular-nums;
}

.dg-transcript-text {
    font-size: 0.875rem;
    color: var(--mud-palette-text-primary, #424242);
}
