@import url("css/design-tokens.css");
@import url("css/fluent-theme.css");

* { box-sizing: border-box; }

html,
body.console-fluent-theme {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--console-bg);
    color: var(--console-text);
    font-family: var(--console-font-sans);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color-scheme: dark;
}

h1 {
    margin: 0 0 var(--space-3);
    font-family: var(--console-font-display);
    font-size: var(--font-size-2xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--console-color-text-primary);
}

.page-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin: 0 0 var(--space-3);
    width: 100%;
}

.page-title-row h1 {
    margin: 0;
    min-width: 0;
}

.page-build {
    margin: 0 0 0 auto;
    flex-shrink: 0;
    white-space: nowrap;
    text-align: right;
    font-family: var(--console-font-mono);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-sm);
    color: var(--console-color-text-label);
    white-space: nowrap;
}

h2 {
    margin: var(--space-4) 0 var(--space-2);
    font-family: var(--console-font-display);
    font-size: var(--font-size-lg);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--console-color-text-secondary);
}

p { margin: 0 0 var(--space-3); }

a {
    color: var(--console-color-link);
    text-decoration: none;
}

a:hover {
    color: var(--console-color-link-hover);
}

/* Sidebar shell — Console dark theme */
.shell-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top left, var(--console-color-hero-glow), transparent 50%), var(--console-bg);
    color: var(--console-text);
    font-family: var(--console-font-sans);
}

.bank-top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: var(--space-3) var(--space-5) 0;
}

.bank-auth {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--console-color-text-secondary);
    font-size: var(--font-size-sm);
    text-align: right;
}

.bank-auth-user {
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bank-auth a,
.bank-auth .auth-link-button {
    color: var(--console-color-link);
    white-space: nowrap;
}

.auth-link-button {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    flex: 1;
    min-height: 0;
}

.nav {
    background: var(--console-color-glass);
    backdrop-filter: blur(25px);
    border-right: 1px solid var(--console-color-glass-border);
    border-left: 4px solid var(--tile-bankhost-edge);
    color: var(--console-color-text-primary);
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    box-shadow: var(--console-shadow);
}

.console-eyebrow {
    margin: 0;
    color: var(--console-color-brand);
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.4em;
    text-transform: uppercase;
}

.console-brand-title {
    margin: 0 0 var(--space-1);
    font-family: var(--console-font-display);
    font-size: var(--font-size-xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: var(--line-height-xl);
    color: var(--console-color-accent);
}

.nav nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.nav-section {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--console-color-text-label);
    margin-top: var(--space-3);
    margin-bottom: var(--space-1);
    padding-left: var(--space-2);
    font-weight: 600;
}

.nav a {
    color: var(--console-color-text-muted);
    text-decoration: none;
    padding: var(--space-2) var(--space-2);
    border-radius: var(--console-radius);
    font-size: var(--font-size-sm);
    transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--console-color-text-primary);
}

.nav a.active {
    background: rgba(14, 165, 233, 0.15);
    color: var(--console-color-accent);
    font-weight: 600;
}

.content {
    padding: var(--space-4) var(--space-5);
    max-width: var(--console-content-max-width);
    overflow-x: auto;
}

@media (max-width: 800px) {
    .shell-wrap .shell {
        grid-template-columns: 1fr;
    }

    .bank-top-bar {
        padding: var(--space-2) var(--space-3) 0;
    }

    .nav {
        border-right: none;
        border-bottom: 1px solid var(--console-color-glass-border);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--console-color-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--console-color-glass-border);
    border-left: 4px solid var(--tile-bankhost-edge);
    border-radius: var(--console-radius-lg);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
    box-shadow: var(--console-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-1px);
    box-shadow: var(--console-glow);
}

.card h2 {
    margin-top: 0;
    font-size: var(--font-size-base);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--console-color-text-label);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-3);
    margin: var(--space-3) 0;
}

.product-map {
    display: grid;
    grid-template-columns: repeat(16, minmax(0, 1fr));
    grid-template-rows: repeat(16, minmax(30px, auto));
    column-gap: var(--product-map-column-gap);
    row-gap: var(--product-map-row-gap);
    margin: var(--space-3) 0;
    min-width: 960px;
}

.tile {
    display: block;
    min-height: var(--hit-target);
    min-width: var(--hit-target);
    padding: var(--space-3);
    border: 1px solid var(--console-color-glass-border);
    border-left: 4px solid var(--console-color-brand);
    border-radius: var(--console-radius-lg);
    background: var(--tile-bg);
    backdrop-filter: blur(20px);
    color: inherit;
    text-decoration: none;
    position: relative;
    box-shadow: var(--console-shadow);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile-dashboard {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: var(--space-1);
    min-height: 140px;
    overflow: hidden;
}

.tile h3 {
    margin: 0;
    font-family: var(--console-font-display);
    font-size: var(--font-size-base);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--console-color-text-primary);
}

.tile-eyebrow {
    font-size: var(--font-size-xs);
    line-height: var(--line-height-xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--console-color-text-label);
}

.tile-stat {
    margin: 0;
    font-family: var(--console-font-display);
    font-size: var(--font-size-2xl);
    line-height: var(--line-height-2xl);
    font-weight: 800;
    color: var(--console-color-accent);
}

.tile-detail {
    margin: 0;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-sm);
    color: var(--console-color-text-muted);
    word-break: break-word;
}

.tile:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: var(--console-glow);
}

.tile:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--console-bg), 0 0 0 4px var(--console-accent);
}

.tile:active {
    transform: scale(0.99);
}

.tile-tone-bankhost {
    background: var(--tile-bankhost);
    border-color: var(--tile-bankhost-edge);
    border-left-color: var(--tile-bankhost-edge);
}

.tile-tone-bankstream {
    background: var(--tile-bankstream);
    border-color: var(--tile-bankstream-edge);
    border-left-color: var(--tile-bankstream-edge);
}

.tile-tone-brand {
    background: var(--tile-brand);
    border-color: var(--tile-brand-edge);
    border-left-color: var(--tile-brand-edge);
}

.tile-tone-azure {
    background: var(--tile-azure-fill);
    border-color: var(--tile-azure-edge);
    border-left-color: var(--tile-azure-edge);
}

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
}

label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--console-color-text-label);
    margin-bottom: var(--space-1);
}

.new-account-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.new-account-stack > .card {
    width: 100%;
    margin-bottom: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-3);
    max-width: 40rem;
}

input[type=text],
input[type=search],
input[type=number],
textarea,
select {
    width: 100%;
    max-width: 28rem;
    padding: var(--space-2) var(--space-2);
    border: 1px solid var(--console-color-border);
    border-radius: var(--console-radius);
    margin-bottom: var(--space-3);
    font: inherit;
    background: rgba(2, 6, 23, 0.65);
    color: var(--console-color-text-primary);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--console-color-brand);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}

button, .btn {
    appearance: none;
    border: 1px solid var(--console-color-brand);
    background: var(--console-color-brand);
    color: var(--console-color-text-primary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--console-radius);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover:not(:disabled), .btn:hover {
    background: var(--console-color-accent);
    border-color: var(--console-color-accent);
}

button.secondary, .btn.secondary {
    background: transparent;
    border-color: var(--console-color-border);
    color: var(--console-color-text-secondary);
}

button.secondary:hover, .btn.secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--console-color-text-muted);
    color: var(--console-color-text-primary);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.muted {
    color: var(--console-muted);
    font-size: var(--font-size-sm);
}

.error { color: var(--status-unhealthy); }
.ok { color: var(--status-healthy); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

th, td {
    border-bottom: 1px solid var(--console-color-glass-border);
    text-align: left;
    padding: var(--space-2) var(--space-2);
    vertical-align: top;
}

th {
    background: rgba(255, 255, 255, 0.04);
    color: var(--console-color-text-label);
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--font-size-xs);
    letter-spacing: 0.06em;
}

pre {
    background: rgba(2, 6, 23, 0.65);
    border: 1px solid var(--console-color-glass-border);
    border-radius: var(--console-radius);
    padding: var(--space-3);
    overflow: auto;
    max-height: 320px;
    font-size: var(--font-size-xs);
    color: var(--console-color-text-secondary);
}

.stat {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    font-family: var(--console-font-display);
    color: var(--console-color-accent);
    line-height: var(--line-height-3xl);
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

code {
    font-family: var(--console-font-mono);
    font-size: 0.9em;
    color: var(--console-color-accent);
}

a.entity-link {
    color: var(--console-color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
}

a.entity-link:hover {
    color: var(--console-color-link-hover);
}

.credit { color: var(--status-healthy); font-weight: 600; }
.debit { color: var(--status-unhealthy); font-weight: 600; }

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--status-unhealthy);
    color: var(--console-color-text-primary);
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: var(--console-color-text-primary);
    text-decoration: underline;
    margin-left: var(--space-3);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: var(--space-4);
    top: var(--space-3);
}

/* Reconnect modal */
.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

#components-reconnect-modal {
    background: var(--console-color-surface);
    color: var(--console-color-text-primary);
    width: 20rem;
    margin: 20vh auto;
    padding: var(--space-5);
    border: 1px solid var(--console-color-glass-border);
    border-radius: var(--console-radius-lg);
    box-shadow: var(--console-shadow);
    opacity: 0;
    transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
    animation: components-reconnect-modal-fadeOutOpacity 0.5s both;
}

#components-reconnect-modal[open] {
    animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s, components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: var(--console-color-overlay);
    animation: components-reconnect-modal-fadeInOpacity 0.5s ease-in-out;
    opacity: 1;
}

@keyframes components-reconnect-modal-slideUp {
    0% { transform: translateY(30px) scale(0.95); }
    100% { transform: translateY(0); }
}

@keyframes components-reconnect-modal-fadeInOpacity {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes components-reconnect-modal-fadeOutOpacity {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

#components-reconnect-modal p {
    margin: 0;
    text-align: center;
    color: var(--console-color-text-secondary);
}

#components-reconnect-modal button {
    border: 0;
    background-color: var(--console-color-brand);
    color: var(--console-color-text-primary);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--console-radius);
}

#components-reconnect-modal button:hover {
    background-color: var(--console-color-accent);
}

.components-rejoining-animation {
    position: relative;
    width: 80px;
    height: 80px;
}

.components-rejoining-animation div {
    position: absolute;
    border: 3px solid var(--console-color-brand);
    opacity: 1;
    border-radius: 50%;
    animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-rejoining-animation {
    0% { top: 40px; left: 40px; width: 0; height: 0; opacity: 0; }
    4.9% { top: 40px; left: 40px; width: 0; height: 0; opacity: 0; }
    5% { top: 40px; left: 40px; width: 0; height: 0; opacity: 1; }
    100% { top: 0; left: 0; width: 80px; height: 80px; opacity: 0; }
}

.config-table-wrap {
    overflow-x: auto;
    margin-top: var(--space-2);
}

.config-settings {
    min-width: 48rem;
}

.config-settings .config-key {
    font-family: var(--console-font-mono);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.config-settings .config-value {
    font-family: var(--console-font-mono);
    font-size: var(--font-size-xs);
    word-break: break-word;
}

.config-settings tr.is-overlay td {
    background: rgba(251, 191, 36, 0.08);
}

.config-settings tr.is-runtime td {
    background: rgba(248, 113, 113, 0.1);
}

.config-badge {
    display: inline-block;
    margin: 0 0.25rem 0.15rem 0;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--console-color-glass-border);
    color: var(--console-color-text-label);
}

.config-badge-overlay {
    border-color: var(--status-warning);
    color: var(--status-warning);
}

.config-badge-runtime {
    border-color: var(--status-unhealthy);
    color: var(--status-unhealthy);
}

.config-legend {
    display: inline-block;
    padding: 0 0.35rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.config-legend-overlay {
    color: var(--status-warning);
}

.config-legend-runtime {
    color: var(--status-unhealthy);
}

@media (prefers-reduced-motion: reduce) {
    .card,
    .card:hover,
    .tile,
    .tile:hover,
    .tile:active {
        transform: none;
        transition: none;
    }
}
