/* StashMail Server control panel. Layout and small additions on top of Bootstrap 5. */

[x-cloak] { display: none !important; }

:root {
	--sm-sidebar-width: 15.5rem;
	--sm-accent: #2563eb;
}

body {
	min-height: 100vh;
	background-color: var(--bs-tertiary-bg);
}

/* Busy indicator: a thin animated bar along the top of the window. */
.sm-busy {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 2000;
	overflow: hidden;
	background: rgba(37, 99, 235, .15);
}
.sm-busy::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 35%;
	background: var(--sm-accent);
	animation: sm-busy 1.1s ease-in-out infinite;
}
@keyframes sm-busy {
	from { left: -35%; }
	to { left: 100%; }
}

.sm-brand-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: .5rem;
	background: var(--sm-accent);
	color: #fff;
}

/* Sidebar */
@media (min-width: 992px) {
	.sm-sidebar {
		width: var(--sm-sidebar-width);
		flex: 0 0 var(--sm-sidebar-width);
		position: sticky;
		top: 3.6rem;
		height: calc(100vh - 3.6rem);
		overflow-y: auto;
	}
}
.sm-sidebar .nav-link {
	display: flex;
	align-items: center;
	gap: .65rem;
	padding: .45rem .75rem;
	border-radius: .5rem;
	color: var(--bs-body-color);
}
.sm-sidebar .nav-link:hover {
	background-color: var(--bs-secondary-bg);
}
.sm-sidebar .nav-link.active {
	background-color: rgba(37, 99, 235, .12);
	color: var(--sm-accent);
	font-weight: 600;
}
[data-bs-theme="dark"] .sm-sidebar .nav-link.active {
	color: #8fb3ff;
}
.sm-sidebar .sm-nav-heading {
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--bs-secondary-color);
	padding: 1rem .75rem .35rem;
}

.sm-main {
	min-width: 0;
	max-width: 80rem;
}

.sm-page-title {
	font-weight: 700;
	margin-bottom: .25rem;
}
.sm-page-lead {
	color: var(--bs-secondary-color);
	margin-bottom: 1.5rem;
}
/* The title and intro of a page share the row with its buttons, which stay
   on the right however long the intro is (they wrap below only on phones). */
.sm-page-intro {
	flex: 1 1 20rem;
	min-width: 0;
}

.card {
	border-color: var(--bs-border-color-translucent);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.card-header {
	background-color: transparent;
	font-weight: 600;
}

.table > :not(caption) > * > * {
	vertical-align: middle;
}
.table .sm-group-row > th {
	background-color: var(--bs-secondary-bg);
	font-weight: 600;
	font-size: .9rem;
}

/* Wrap long values (domains, DNS records) only where they don't fit. */
.sm-break { overflow-wrap: anywhere; }
.sm-mono { font-family: var(--bs-font-monospace); font-size: .875em; }
.sm-pre {
	white-space: pre-wrap;
	word-break: break-word;
	font-family: var(--bs-font-monospace);
	font-size: .8125rem;
	margin: 0;
}
.sm-pre-box {
	max-height: 26rem;
	overflow: auto;
	background-color: var(--bs-secondary-bg);
	border-radius: .5rem;
	padding: .75rem 1rem;
}

.sm-col-name { min-width: 14rem; width: 30%; }

.sm-inactive .sm-address {
	text-decoration: line-through;
	color: var(--bs-secondary-color);
}

/* Status checks */
.sm-stat {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: .85rem;
}
.sm-stat .sm-stat-icon {
	font-size: 1.6rem;
	line-height: 1;
}
.sm-stat .sm-stat-value {
	font-size: 1.6rem;
	font-weight: 700;
	line-height: 1;
}
.sm-check {
	display: flex;
	gap: .75rem;
	padding: .6rem 0;
	border-top: 1px solid var(--bs-border-color-translucent);
}
.sm-check:first-child { border-top: 0; }
.sm-check .bi { font-size: 1.1rem; }

.sm-login {
	max-width: 26rem;
	margin: 4rem auto;
}

.sm-qr {
	width: 14rem;
	max-width: 100%;
	height: auto;
	background: #fff;
	padding: .5rem;
	border-radius: .5rem;
}

.toast-container { z-index: 1090; }

details.sm-api > summary {
	cursor: pointer;
	font-weight: 600;
}

.sm-brand-icon-lg {
	width: 3.25rem;
	height: 3.25rem;
	border-radius: .85rem;
}

/* Scroll targets: keep them clear of the sticky top bar. */
.sm-anchor {
	scroll-margin-top: 5rem;
}

/* Address picker (aliases): chosen addresses as removable chips. */
.sm-chips {
	display: flex;
	flex-wrap: wrap;
	gap: .375rem;
	min-height: 1.75rem;
}
.sm-chip {
	display: inline-flex;
	align-items: center;
	gap: .25rem;
	max-width: 100%;
	padding: .125rem .25rem .125rem .5rem;
	border: 1px solid var(--bs-border-color);
	border-radius: var(--bs-border-radius-pill);
	background: var(--bs-tertiary-bg);
	font-size: .875rem;
	overflow-wrap: anywhere;
}
.sm-chip .btn-close {
	font-size: .55rem;
	padding: .35rem;
}
.sm-at {
	font-weight: 600;
}
/* An input group whose first field is hidden (x-show): round the next item. */
.input-group > [style*="display: none"]:first-child + * {
	margin-left: 0;
	border-top-left-radius: var(--bs-border-radius);
	border-bottom-left-radius: var(--bs-border-radius);
}

/* DNS records with copy buttons (status checks). The buttons appear on
   mouse-over; on touch screens they are always shown. */
.sm-records {
	display: grid;
	gap: .25rem;
	margin: .35rem 0 .5rem;
}
.sm-record {
	display: grid;
	grid-template-columns: minmax(6rem, max-content) auto minmax(0, 1fr);
	min-width: 0;
	align-items: start;
	gap: .5rem;
	padding: .35rem .5rem;
	border: 1px solid var(--bs-border-color-translucent);
	border-radius: var(--bs-border-radius);
	background: var(--bs-tertiary-bg);
	font-size: .875rem;
}
@media (max-width: 575.98px) {
	.sm-record { grid-template-columns: minmax(0, 1fr) auto; }
	.sm-record .sm-record-value { grid-column: 1 / -1; }
}
.sm-copyable {
	display: inline-flex;
	align-items: flex-start;
	gap: .125rem;
	min-width: 0;
}
.sm-copy-target {
	cursor: copy;
	border-radius: .2rem;
}
.sm-copyable:hover .sm-copy-target {
	background: var(--bs-secondary-bg);
}
.sm-copy-btn {
	flex-shrink: 0;
	border: 0;
	background: none;
	padding: 0 .3rem;
	line-height: 1.4;
	color: var(--bs-secondary-color);
	opacity: 0;
	transition: opacity .15s;
}
.sm-copy-btn:hover {
	color: var(--bs-primary);
}
.sm-copyable:hover .sm-copy-btn,
.sm-copy-btn:focus-visible {
	opacity: 1;
}
@media (hover: none) {
	.sm-copy-btn { opacity: 1; }
}

.min-w-0 {
	min-width: 0;
}

/* Tables of DNS records: on narrow screens, show each record as a block
   (name and type on one line, the value below at full width) so that long
   values such as DKIM keys wrap instead of running off the screen. */
@media (max-width: 767.98px) {
	.sm-stack-table thead {
		display: none;
	}
	.sm-stack-table tr {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: .25rem .5rem;
		padding: .5rem .75rem;
		border-bottom: 1px solid var(--bs-border-color);
	}
	.sm-stack-table td {
		display: block;
		padding: 0;
		border: 0;
		min-width: 0;
	}
	.sm-stack-table td:last-child {
		flex: 1 0 100%;
	}
}

/* fail2ban log */
.sm-log {
	max-height: 28rem;
	overflow-y: auto;
	font-size: .8125rem;
	font-family: var(--bs-font-monospace);
}
.sm-log-line {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: .25rem .5rem;
	padding: .2rem .75rem;
	border-bottom: 1px solid var(--bs-border-color-translucent);
}
.sm-log-ban { background: var(--bs-danger-bg-subtle); }
.sm-log-unban { background: var(--bs-success-bg-subtle); }
.sm-log-warn { background: var(--bs-warning-bg-subtle); }

/* Firewall: attacks per day */
.sm-bars {
	display: flex;
	align-items: flex-end;
	gap: 2px;
	height: 8rem;
	padding-bottom: 1px;
	border-bottom: 1px solid var(--bs-border-color);
}
.sm-bar {
	position: relative;
	flex: 1 1 0;
	min-width: 0;
	height: 100%;
}
.sm-bar-failures,
.sm-bar-bans {
	position: absolute;
	bottom: 0;
	border-radius: 2px 2px 0 0;
}
.sm-bar-failures {
	left: 0;
	right: 0;
	background: var(--bs-danger-bg-subtle);
	border: 1px solid var(--bs-danger-border-subtle);
	border-bottom: 0;
}
.sm-bar-bans {
	left: 25%;
	right: 25%;
	background: var(--bs-danger);
}
.sm-bar:hover .sm-bar-failures { background: var(--bs-danger-border-subtle); }
.sm-legend {
	display: inline-block;
	width: .75rem;
	height: .75rem;
	margin-right: .35rem;
	vertical-align: -.1rem;
	border-radius: 2px;
}
.sm-legend-failures { background: var(--bs-danger-bg-subtle); border: 1px solid var(--bs-danger-border-subtle); }
.sm-legend-bans { background: var(--bs-danger); }

/* Mail activity: emails per day, one column per type */
.sm-mbar {
	display: flex;
	align-items: flex-end;
	gap: 1px;
	flex: 1 1 0;
	min-width: 0;
	height: 100%;
}
.sm-mbar-col {
	flex: 1 1 0;
	min-width: 0;
	border-radius: 2px 2px 0 0;
}
.sm-mbar:hover { background: var(--bs-tertiary-bg); }
.sm-mbar-sent { background: var(--bs-primary); }
.sm-mbar-received { background: var(--bs-success); }
.sm-mbar-rejected_in { background: var(--bs-warning); }
.sm-mbar-rejected_out { background: var(--bs-danger); }
.sm-mbar-nodata {
	background: repeating-linear-gradient(135deg, var(--bs-secondary-bg) 0 3px, transparent 3px 6px);
}
.sm-account-filter { width: auto; max-width: 18rem; }
.sm-input-narrow { width: 6rem; }
.sm-log-pre { max-height: 24rem; overflow-y: auto; }
.sm-events { max-height: 28rem; overflow-y: auto; }
.sm-events thead th { position: sticky; top: 0; background: var(--bs-body-bg); }

/* Monitoring and Spam filter: tiles and charts */
.sm-tile { padding: .75rem 1rem; }
.sm-tile-value {
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.2;
	margin-top: .15rem;
	white-space: nowrap;
}
.sm-tile-bar { height: .3rem; margin-top: .4rem; }
.text-orange { color: #f97316 !important; }
.text-bg-orange { color: #fff !important; background-color: #ea580c !important; }
.sm-section-toggle {
	font-weight: 600;
	cursor: pointer;
	background-color: transparent;
	color: var(--bs-body-color);
}
.sm-section-toggle:hover { background-color: var(--bs-tertiary-bg); }
.sm-chart {
	position: relative;
	min-height: 14rem;
	width: 100%;
}
.sm-chart-empty::after {
	content: "No data yet";
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px dashed var(--bs-border-color);
	border-radius: var(--bs-border-radius);
	color: var(--bs-secondary-color);
	font-size: .875rem;
}
.sm-chart .uplot {
	font-family: var(--bs-body-font-family);
	color: var(--bs-body-color);
}
.sm-chart .u-legend {
	font-size: .75rem;
	text-align: left;
	margin-top: .25rem;
}
.sm-chart .u-legend .u-series { padding: 0 .4rem; }
.sm-chart .u-legend .u-series th { font-weight: 500; }
.sm-chart .u-legend .u-marker { border-radius: 2px; }
.sm-chart .u-select { background: rgba(37, 99, 235, .1); }

/* Spam filter: message history */
.sm-history-row { cursor: pointer; }
.sm-history-detail-row > td { background-color: var(--bs-tertiary-bg); }
.sm-history-meta dt { font-weight: 500; color: var(--bs-secondary-color); }
.sm-history-meta dd { margin-bottom: .2rem; }

/* Reputation → Settings: alert recipient picker */
.sm-pick-list { max-height: 12rem; }
.sm-badge-close { font-size: .55em; }

/* Sending limits: usage per metric */
.sl-usage-col { min-width: 9rem; }

/* Migrate mail */
.mi-folders { max-height: 28rem; overflow-y: auto; }
.mi-folders thead th { background: var(--bs-body-bg); }
.mi-log { max-height: 50vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
