/* Shared building blocks reused across multiple pages/components.
   Consolidated here instead of being duplicated in each *.razor.css file. */

/* ---- Stat summary cards (Dashboard-style tiles) ---- */
.stat-card {
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    background: var(--surface-card);
    height: 100%;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-brown-shade-64);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-brown-shade-64);
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0.15rem;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--color-brown-shade-64);
    margin-top: 0.1rem;
}

/* ---- Row action menu (fixed popover opened from a "..." button) ---- */
.btn-icon {
    background: transparent;
    border: 0;
    color: var(--color-brown-shade-64);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
}

.btn-icon:hover {
    background: rgba(128, 128, 128, 0.15);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
}

.action-menu {
    position: fixed;
    z-index: 1055;
    min-width: 11rem;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 0.3rem;
    text-align: left;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: transparent;
    border: 0;
    border-radius: 6px;
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
    color: var(--color-dark-brown);
    text-align: left;
}

a.action-item {
    color: inherit;
    text-decoration: none;
}

.action-item:hover:not(:disabled) {
    background: var(--surface-raised);
}

.action-item:disabled {
    color: var(--color-brown-shade-32);
    cursor: not-allowed;
}

.action-item.danger:not(:disabled) {
    color: var(--color-status-danger);
}

.action-sep {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.3rem 0;
}

/* ---- Delete-confirm modal ---- */
.modal-shade {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm {
    background: var(--surface-card);
    border-radius: 12px;
    padding: 1.25rem;
    width: 24rem;
    max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.form-check-input:checked {
    background-color: var(--color-telenet-yellow);
    border-color: var(--color-telenet-yellow);
}

/* ---- Table shell: bordered, rounded wrapper around a <table> ---- */
.table-wrap {
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.table-wrap.is-refreshing {
    opacity: 0.5;
}

.table-sm {
    font-size: 0.85rem;
}

.row-clickable {
    cursor: pointer;
}

.row-clickable:hover {
    background-color: rgba(255, 196, 33, 0.08);
}

/* ---- Search box with a leading icon ---- */
.search-box {
    position: relative;
    width: 15rem;
}

.search-box i {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-brown-shade-64);
    font-size: 0.85rem;
}

.search-box input {
    padding-left: 1.9rem;
}

/* ---- Searchable select (dropdown with type-to-filter) ---- */
.searchable-select {
    position: relative;
}

.searchable-select > button {
    min-width: 10rem;
}

.searchable-select-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.searchable-select-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 1001;
    min-width: 100%;
    width: 16rem;
    padding: 0.5rem;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--border-subtle);
    border-radius: 0.375rem;
}

.searchable-select-items {
    max-height: 15rem;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.searchable-select-item {
    display: block;
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 0.875rem;
    border-radius: 0.25rem;
}

.searchable-select-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

.searchable-select-item.active {
    font-weight: 600;
}

/* ---- Column picker (grid toolbar): show/hide and reorder columns ---- */
/* The row just above every grid: search and filters on the left, refresh and the column picker on the right. */
.grid-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.grid-toolbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.column-picker {
    position: relative;
}

.column-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.column-picker-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    right: 0;
    z-index: 1001;
    width: 17rem;
    padding: 0.5rem;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
}

.column-picker-title {
    padding: 0.125rem 0.5rem 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.column-picker-items {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 22rem;
    overflow-y: auto;
}

.column-picker-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.25rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
    border-top: 2px solid transparent;
}

.column-picker-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

.column-picker-item[draggable="true"] .column-picker-grip {
    cursor: grab;
}

.column-picker-item.dragging {
    opacity: 0.5;
}

.column-picker-item.drag-over {
    border-top-color: var(--color-brand-primary);
}

.column-picker-grip {
    color: var(--bs-secondary-color);
}

.column-picker-item .btn-icon {
    padding: 0 0.25rem;
    line-height: 1;
}

.column-picker-reset {
    margin-top: 0.375rem;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
}

/* ---- Resizable grid columns: drag handle on the right edge of a <th> ---- */
th.resizable {
    position: relative;
}

th.resizable[style] {
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    touch-action: none;
}

.col-resizer:hover,
body.col-resizing .col-resizer:active {
    background: var(--color-brand-primary);
    opacity: 0.5;
}

body.col-resizing {
    cursor: col-resize;
    user-select: none;
}

/* ---- Tabs (VM detail, settings): buttons or NavLinks with the yellow active underline ---- */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.tab {
    background: transparent;
    border: 0;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-brown-shade-64);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    text-decoration: none;
}

.tab:hover {
    color: var(--color-dark-brown);
}

.tab.active {
    color: var(--color-dark-brown);
    border-bottom-color: var(--color-telenet-yellow);
}

.tab:disabled {
    color: var(--color-brown-shade-32);
    cursor: not-allowed;
}

/* ---- Locked feature (LockedButton): disabled control with a lock; the wrapper carries the tooltip ---- */
.feature-locked {
    display: inline-block;
    cursor: not-allowed;
}

.feature-locked-block {
    display: block;
}

.feature-locked > button:disabled {
    pointer-events: none;
}

.feature-lock-icon {
    font-size: 0.75em;
    margin-left: 0.15rem;
}

/* ---- Sub-tabs (Access management): pills under the settings tabs, dark when active ---- */
.subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.subtab {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: var(--border-subtle);
    color: var(--color-dark-brown);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.subtab:hover {
    color: var(--color-dark-brown);
    filter: brightness(0.95);
}

/* Fixed brand colours: --color-dark-brown flips to a light ink in dark mode. */
.subtab.active {
    background: #291D18;
    color: #fff;
}

[data-bs-theme="dark"] .subtab {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
}

[data-bs-theme="dark"] .subtab.active {
    background: var(--color-telenet-yellow);
    border-color: var(--color-telenet-yellow);
    color: #291D18;
}

/* ---- Role chip (team/customer roles) with a remove button ---- */
.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.35rem 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--color-lemon);
    color: #291D18;   /* fixed: stays dark on the lemon chip in dark mode too */
    font-size: 0.875rem;
    font-weight: 600;
}

.role-chip-link {
    color: inherit;
    text-decoration: none;
}

.role-chip-link:hover,
.role-chip-link:focus-visible {
    text-decoration: underline;
}

.role-chip .bi:first-child {
    font-size: 0.9rem;
}

.role-chip-remove {
    border: 0;
    background: transparent;
    color: inherit;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.role-chip-remove:hover:not(:disabled) {
    background: rgba(41, 29, 24, 0.12);
}

/* ---- Access overview: "what can this role do?" feature cards per domain ---- */
.access-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.access-group-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.access-group-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #291D18;   /* fixed: the domain tints are light in both modes */
    background: var(--color-brown-shade-08);
}

.access-domain-vm { background: #a6d9d9; }
.access-domain-backup { background: #add1a6; }
.access-domain-customer,
.access-domain-customers { background: #fdd671; }
.access-domain-namespaces { background: #fbe3a0; }
.access-domain-clusters { background: #b7cfe8; }
.access-domain-audit-logs { background: #e5cfc7; }
.access-domain-mail-queue { background: #fac7ba; }
.access-domain-tasks,
.access-domain-operations { background: #d6d0c4; }
.access-domain-app-settings,
.access-domain-os-icons,
.access-domain-feedback { background: #dcd6ce; }
.access-domain-rbac,
.access-domain-teams,
.access-domain-team-roles,
.access-domain-roles,
.access-domain-role-features,
.access-domain-workforce-users { background: #c9b6d8; }

/* Cells of the access matrices (UserAccessMatrix, the permissions page): a check, or an empty box. */
.access-matrix-on {
    display: inline-flex;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: #291D18;
    color: var(--color-telenet-yellow);
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.access-matrix-off {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 8px;
    border: 2px solid var(--color-brown-shade-32);
}

[data-bs-theme="dark"] .access-matrix-on {
    background: var(--color-telenet-yellow);
    color: #291D18;
}

.access-card {
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--surface-card);
    box-shadow: 0 2px 8px rgba(41, 29, 24, 0.06);
    padding: 0.9rem 1rem;
}

/* Collapsible permission domains (<details>) and the overview's Features tile (a button), chevron on the right. */
.access-section > summary {
    list-style: none;
    cursor: pointer;
}

.access-section > summary::-webkit-details-marker {
    display: none;
}

.access-collapse-icon {
    margin-left: auto;
    color: var(--color-brown-shade-64);
    transition: transform 0.15s ease;
}

details[open] > summary .access-collapse-icon,
.access-collapse-icon.open {
    transform: rotate(180deg);
}

.stat-card-toggle {
    display: block;
    width: 100%;
    text-align: start;
    color: inherit;
    cursor: pointer;
}

.stat-card-toggle:hover {
    border-color: var(--color-brown-shade-64);
}

.access-card-killed {
    opacity: 0.7;
    border-style: dashed;
}

.access-card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    flex-grow: 1;
}

.access-card-desc {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    color: var(--color-brown-shade-64);
}

.access-actions {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0.6rem 0 0;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.875rem;
}

.access-actions .bi {
    color: var(--color-status-success);
    margin-right: 0.25rem;
}

.access-badge-rollout {
    background: #fac7ba;
    color: #291D18;
}

/* "Default" team/role: where new users land, the role every new customer gets. */
.access-badge-default {
    background: var(--color-telenet-yellow);
    color: #291D18;
}

.access-badge-active {
    background: #add1a6;
    color: #291D18;
}

/* Kill switch panel on the feature detail: a warning, readable in both modes. */
.kill-switch-card {
    background: #fde8e3;
    border-color: #f2b8aa;
    color: #291D18;
}

[data-bs-theme="dark"] .kill-switch-card {
    background: #4a1d17;
    border-color: #c4493a;
    color: #fadad5;
}

.access-badge-killed {
    background: var(--color-status-danger);
    color: #fff;
}
