/*
 * Copyright © 2026 Spinium Property Management OÜ - All rights reserved.
 * Author: Timo J. Rinne <tri@iki.fi>
 *
 * Unreleased and unlicensed. Any use is explicitly prohibited without a prior
 * written license from Spinium Property Management OÜ (https://spinium.com).
 * See COPYING.
 */

/* Dialogs (ROADMAP.md §28.1), for both surfaces at once.
 *
 * Every colour here is `var(--bank-*, var(--admin-token, literal))`. The
 * net-bank sets --bank-* on :root from the bank's own tokens, so a dialog
 * raised in a bank is in that bank's colours and typeface without this file
 * knowing anything about skins. The admin console sets none of them, so each
 * falls through to the console's own variable, and the literal at the end is
 * for neither — it is what keeps this readable if a page loads the stylesheet
 * and nothing else.
 *
 * That ordering is the whole trick, and it is why the modal markup is not
 * styled by the skins themselves: a skin that forgot to style it would have an
 * unreadable dialog, and there are five of them plus whatever an operator
 * writes next. */

.bsim-modal-layer {
	position: fixed;
	inset: 0;
}

.bsim-modal-backdrop {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(10, 12, 18, .5);
	overflow-y: auto;
}

.bsim-modal {
	width: 100%;
	max-width: 460px;
	max-height: calc(100vh - 40px);
	display: flex;
	flex-direction: column;
	background: var(--bank-surface, var(--card, #ffffff));
	color: var(--bank-on-surface, var(--fg, #16181d));
	font-family: var(--bank-font, inherit);
	border: 1px solid var(--bank-line, var(--line, #e0e2e8));
	border-radius: var(--bank-radius, 6px);
	box-shadow: 0 18px 50px rgba(0, 0, 0, .32);
}

.bsim-modal-wide { max-width: 680px; }

.bsim-modal-head {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 16px 18px 0 18px;
}

.bsim-modal-title {
	margin: 0;
	flex: 1;
	font-size: 17px;
	font-weight: 600;
	font-family: var(--bank-font-heading, inherit);
	line-height: 1.3;
}

/* The ✕. Every dialog has one, because ESC and a backdrop click are both
 * invisible affordances and a dialog with no visible way out reads as stuck. */
.bsim-modal-x {
	margin: -4px -6px 0 0;
	padding: 0 6px;
	font-size: 22px;
	line-height: 1;
	background: transparent;
	color: var(--bank-muted, var(--muted, #666a75));
	border: 0;
	border-radius: var(--bank-radius, 6px);
	cursor: pointer;
}

.bsim-modal-x:hover {
	background: transparent;
	color: var(--bank-on-surface, var(--fg, #16181d));
}

.bsim-modal-body {
	padding: 10px 18px 4px 18px;
	overflow-y: auto;
	font-size: 14px;
	line-height: 1.5;
}

.bsim-modal-body p { margin: 0 0 10px 0; white-space: pre-line; }

.bsim-modal-body label {
	display: block;
	margin: 0 0 4px 0;
	font-size: 13px;
	color: var(--bank-muted, var(--muted, #666a75));
}

.bsim-modal-body input[type="text"],
.bsim-modal-body input[type="password"],
.bsim-modal-body input[type="number"],
.bsim-modal-body input[type="date"] {
	width: 100%;
	box-sizing: border-box;
	margin: 0 0 10px 0;
	padding: 8px 10px;
	font: inherit;
	color: inherit;
	background: var(--bank-surface, var(--card, #ffffff));
	border: 1px solid var(--bank-line, var(--line, #e0e2e8));
	border-radius: var(--bank-radius, 6px);
}

.bsim-modal-foot {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	flex-wrap: wrap;
	padding: 12px 18px 16px 18px;
}

/* Buttons are styled here rather than inherited, because the two surfaces
 * disagree about what a `button` looks like and a dialog that changed shape
 * between them would be two dialogs. */
.bsim-modal-foot button {
	margin: 0;
	padding: 8px 16px;
	font: inherit;
	font-weight: 500;
	color: var(--bank-on-primary, #ffffff);
	background: var(--bank-primary, var(--accent, #1d5cff));
	border: 1px solid transparent;
	border-radius: var(--bank-radius, 6px);
	cursor: pointer;
}

.bsim-modal-foot button:hover { filter: brightness(.92); }

.bsim-modal-foot button.secondary {
	color: var(--bank-primary, var(--accent, #1d5cff));
	background: transparent;
	border-color: var(--bank-line, var(--line, #e0e2e8));
}

.bsim-modal-foot button.danger {
	color: #ffffff;
	background: var(--bank-danger, var(--danger, #c43d3d));
}

.bsim-modal-foot button:focus-visible,
.bsim-modal-x:focus-visible,
.bsim-modal-body input:focus-visible {
	outline: 2px solid var(--bank-accent, var(--accent, #1d5cff));
	outline-offset: 2px;
}

/* Content a caller builds: a password to copy, a TOTP secret with its QR, a
 * list of what a deletion would take with it. */
.bsim-modal-html .bsim-modal-note {
	margin: 0 0 10px 0;
	font-size: 13px;
	color: var(--bank-muted, var(--muted, #666a75));
}

.bsim-modal-html .bsim-modal-secret {
	margin: 0 0 12px 0;
	padding: 10px 12px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 17px;
	letter-spacing: .06em;
	word-break: break-all;
	text-align: center;
	background: var(--bank-line, var(--line-soft, #eceef2));
	border-radius: var(--bank-radius, 6px);
}

.bsim-modal-html .bsim-modal-qr {
	margin: 0 auto 12px auto;
	padding: 10px;
	width: 190px;
	background: #ffffff;
	border: 1px solid var(--bank-line, var(--line, #e0e2e8));
	border-radius: var(--bank-radius, 6px);
}

.bsim-modal-html .bsim-modal-qr svg { display: block; width: 100%; height: auto; }

.bsim-modal-html ul { margin: 0 0 10px 0; padding-left: 20px; }

.bsim-modal-html .bsim-modal-warn {
	color: var(--bank-danger, var(--danger, #c43d3d));
	font-weight: 500;
}

/* While a dialog is open the page behind it does not scroll: a backdrop that
 * scrolls away from what it is covering stops being a backdrop. */
body.bsim-modal-open { overflow: hidden; }
