/*
| Application shell for the private area.
| Flat page background, white sticky header, light sidebar and the dashboard
| widget grid. Widget internals keep their own styles.
*/

.app-body,
html {
	--app-bg: #f3f4f7;
	--app-surface: #ffffff;
	--app-border: #e6e8ee;
	--app-border-soft: #eef1f4;
	--app-panel: #f1f4f8;
	--app-panel-hover: #e9eef4;
	--app-text: #26333f;
	--app-text-soft: #33424f;
	--app-text-muted: #8b97a3;
	--app-accent: #3276b1;
	--app-primary: #1b2433;
	--app-green: #1a9f52;
	--app-red: #d64545;
	--app-radius: 16px;
	--app-radius-sm: 10px;
	--app-shadow: 0 1px 3px rgba(16, 24, 40, .08);
	--app-header-h: 60px;
	--sidebar-w: 276px;
	--sidebar-w-rail: 64px;
	--sidebar-offset: 0px;
	--app-content-max: 1680px;
	--app-col-max: 520px;
	--app-gap: 20px;
	--app-ease: cubic-bezier(.2, .7, .3, 1);
}

html {
	background: var(--app-bg) !important;
	background-image: none !important;
}

body.app-body {
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0;
	background: var(--app-bg) !important;
	background-image: none !important;
	color: var(--app-text);
	font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}

/* The legacy SmartAdmin resize helper re-adds .container above 1200px.
   The new shell must always fill the viewport instead of a fixed column. */
body.app-body.container {
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	box-shadow: none !important;
}

.app-body.app-menu-locked {
	overflow: hidden !important;
	overscroll-behavior: none;
}

.app-shell {
	position: relative;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--app-bg);
}

/* Keyboard users land on the page content, not on the whole menu. */
.app-skip-link {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 200;
	padding: 10px 14px;
	border-radius: var(--app-radius-sm);
	background: var(--app-primary);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	transform: translateY(-160%);
	transition: transform .16s ease;
}

.app-skip-link:focus {
	color: #fff;
	text-decoration: none;
	transform: translateY(0);
}

/* -------------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------------- */

.app-sidebar {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	z-index: 60;
	display: flex;
	flex-direction: column;
	width: var(--sidebar-w);
	height: 100vh;
	height: 100dvh;
	padding-top: env(safe-area-inset-top, 0px);
	border-right: 1px solid var(--app-border);
	background: #f7f9fc;
	visibility: hidden;
	transform: translateX(-100%);
	transition: transform .2s var(--app-ease), width .2s var(--app-ease), box-shadow .2s ease;
}

.app-sidebar-brand {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex: 0 0 auto;
	gap: 8px;
	min-height: var(--app-header-h);
	padding: 0 12px;
	border-bottom: 1px solid var(--app-border-soft);
}

.app-brand {
	display: flex;
	align-items: center;
	min-width: 0;
	max-width: 100%;
	text-decoration: none;
}

.app-brand:hover,
.app-brand:focus {
	text-decoration: none;
}

.app-brand-logo {
	display: block;
	max-width: 154px;
	max-height: 32px;
	width: auto;
	height: auto;
}

.app-brand-logo-mini {
	display: none;
	max-width: 30px;
	max-height: 30px;
}

.app-sidebar-close {
	display: none;
	flex: 0 0 auto;
}

.app-icon-btn.app-sidebar-close {
	display: none;
}

.app-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--app-text);
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
	-webkit-tap-highlight-color: transparent;
}

.app-icon-btn:hover,
.app-icon-btn:focus {
	background: var(--app-panel);
	color: var(--app-text);
	text-decoration: none;
}

.app-icon-btn:focus-visible,
.app-nav a:focus-visible,
.app-sidebar-toggle:focus-visible,
.app-brand:focus-visible,
.app-btn:focus-visible {
	outline: 2px solid var(--app-accent);
	outline-offset: 2px;
}

.app-sidebar-close svg {
	width: 18px;
	height: 18px;
}

.app-nav {
	flex: 1 1 auto;
	min-height: 0;
	padding: 14px 12px;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #cfd6de transparent;
}

.app-nav::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}

.app-nav::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background: #cfd6de;
}

.app-nav::-webkit-scrollbar-track {
	background: transparent;
}

.app-nav ul {
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

.app-nav li {
	position: relative;
	margin: 0;
	padding: 0;
}

.app-nav a {
	position: relative;
	display: flex;
	align-items: center;
	gap: 13px;
	min-height: 36px;
	padding: 0 14px;
	border-radius: 12px;
	color: #4b5563;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	transition: background .15s ease, color .15s ease;
	-webkit-tap-highlight-color: transparent;
}

.app-nav a:hover,
.app-nav a:focus {
	background: #e9eef4;
	color: #26333f;
	text-decoration: none;
}

.app-nav li.active > a,
.app-nav a.active {
	background: #e8f0fe;
	color: #3b6bff !important;
	font-weight: 600;
}

/* SmartAdmin paints its sidebar links white with !important and adds a
   decorative pseudo-element. The new menu does not use either. */
.app-nav a::before,
.app-nav a::after {
	content: none !important;
	display: none !important;
}

.app-nav a > .fa,
.app-nav a > .fa-fw {
	flex: 0 0 22px;
	width: 22px;
	font-size: 18px;
	line-height: 1;
	text-align: center;
	color: #7b8794;
	transition: color .15s ease;
}

.app-nav li.active > a > .fa,
.app-nav li.active > a > .fa-fw,
.app-nav a.active > .fa,
.app-nav a.active > .fa-fw {
	color: #3b6bff;
}

.app-nav a > .app-nav-svg {
	flex: 0 0 22px;
	width: 22px;
	height: 22px;
	padding: 2px;
	margin-right: 5px;
	box-sizing: border-box;
	color: #7b8794;
	fill: currentColor;
	transition: color .15s ease;
}

.app-nav li.active > a > .app-nav-svg,
.app-nav a.active > .app-nav-svg {
	color: #3b6bff;
}

.app-nav a > .app-nav-svg-stroke {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.app-nav-label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.app-nav-badge {
	position: absolute;
	top: 50%;
	right: 10px;
	margin-top: -10px;
	padding: 2px 6px;
	border-radius: 9px;
	background: var(--app-red);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1.4;
}

.app-sidebar-footer {
	flex: 0 0 auto;
	padding: 8px;
	padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--app-border-soft);
}

.app-sidebar-toggle {
	display: flex;
	align-items: center;
	gap: 13px;
	width: 100%;
	min-height: 36px;
	padding: 0 14px;
	border: 0;
	border-radius: 12px;
	background: transparent;
	color: var(--app-text-muted);
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	text-align: left;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}

.app-sidebar-toggle:hover,
.app-sidebar-toggle:focus {
	background: #f7f8fa;
	color: var(--app-text-soft);
}

.app-collapse-icon {
	flex: 0 0 20px;
	width: 20px;
	height: 20px;
	transition: transform .2s var(--app-ease);
}

.app-overlay {
	position: fixed;
	inset: 0;
	z-index: 55;
	background: rgba(16, 24, 40, .38);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .2s ease;
}

/* -------------------------------------------------------------------------
   Header and content column
   ------------------------------------------------------------------------- */

.app-main {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 100vh;
	min-height: 100dvh;
	margin-left: var(--sidebar-offset);
	background-repeat: repeat;
	background-position: top left;
	transition: margin-left .2s var(--app-ease);
}

/* Keep the old .minified #main rule from taking over the content offset.
   The legacy #main rule also sets min-height: 500px, which stopped the main
   column (and its wallpaper) short on pages with little content. */
#main.app-main {
	margin-left: var(--sidebar-offset);
	min-height: 100vh;
	min-height: 100dvh;
}

.app-header {
	position: sticky;
	top: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: calc(var(--app-header-h) + env(safe-area-inset-top, 0px));
	padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
	border-bottom: 1px solid var(--app-border);
	background: var(--app-surface);
}

.app-header-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.app-header-right {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	gap: 8px;
}

.app-burger-icon {
	display: block;
	width: 23.4px;
	height: 17.1px;
	fill: currentColor;
}

.app-section-title {
	min-width: 0;
	margin: 0;
	overflow: hidden;
	color: var(--app-text);
	font-size: 17px;
	font-weight: 600;
	line-height: 1.25;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.app-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 0 16px;
	border: 1px solid transparent;
	border-radius: var(--app-radius-sm);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.app-btn:hover,
.app-btn:focus {
	text-decoration: none;
}

.app-btn-primary {
	border-color: var(--app-primary);
	background: var(--app-primary);
	color: #fff;
}

.app-btn-primary:hover,
.app-btn-primary:focus {
	border-color: #0f1621;
	background: #0f1621;
	color: #fff;
}

.app-btn.app-register-btn {
	display: inline-flex;
	height: 32px;
	min-height: 32px;
	padding: 0 14px;
	border: 1px solid #000000;
	border-radius: 999px;
	background: transparent;
	color: #000000;
	box-shadow: none;
}

.app-btn.app-register-btn:hover,
.app-btn.app-register-btn:focus {
	border-color: #000000;
	background: rgba(0, 0, 0, .05);
	color: #000000;
}

.app-logout {
	display: flex;
	align-items: center;
}

.app-logout-btn {
	width: auto;
	min-width: 44px;
	padding: 0 10px;
	gap: 8px;
}

.app-logout-btn .fa {
	font-size: 18px;
	line-height: 1;
}

.app-logout-label {
	display: none;
	font-size: 13px;
	font-weight: 500;
}

.app-content {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
}

.app-content-inner {
	width: 100%;
	max-width: var(--app-content-max);
	margin: 0 auto;
	padding: 20px max(24px, env(safe-area-inset-right, 0px)) max(36px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
}

.app-content #content {
	width: auto;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
}

.app-embedded .app-main {
	margin-left: 0 !important;
}

/* -------------------------------------------------------------------------
   Sidebar states
   ------------------------------------------------------------------------- */

.app-shell[data-menu="drawer"] .app-sidebar {
	width: min(var(--sidebar-w), calc(100vw - 56px));
	visibility: visible;
	transform: translateX(0);
	box-shadow: 0 18px 40px rgba(16, 24, 40, .18);
}

.app-shell[data-menu="drawer"] .app-overlay {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.app-shell[data-menu="drawer"] .app-sidebar-close {
	display: inline-flex;
}

.app-shell[data-menu="rail"] .app-brand-logo-full,
.app-shell[data-menu="overlay"] .app-brand-logo-full,
.app-shell[data-menu="full"] .app-brand-logo-full {
	display: block;
}

.app-shell[data-menu="rail"] .app-brand-logo-mini,
.app-shell[data-menu="overlay"] .app-brand-logo-mini,
.app-shell[data-menu="full"] .app-brand-logo-mini {
	display: none;
}

@media (min-width: 1024px) {
	.app-shell {
		--sidebar-offset: var(--sidebar-w-rail);
	}

	.app-sidebar {
		visibility: visible;
		transform: none;
		width: var(--sidebar-w-rail);
	}

	.app-shell[data-menu="rail"] .app-sidebar,
	.app-shell[data-menu="overlay"] .app-sidebar,
	.app-shell[data-menu="full"] .app-sidebar {
		visibility: visible;
		transform: none;
	}

	.app-shell[data-menu="rail"] .app-sidebar {
		width: var(--sidebar-w-rail);
	}

	.app-shell[data-menu="overlay"] .app-sidebar {
		width: var(--sidebar-w);
		box-shadow: 0 18px 40px rgba(16, 24, 40, .14);
	}

	.app-shell[data-menu="full"] .app-sidebar {
		width: var(--sidebar-w);
	}

	.app-shell[data-menu="full"] {
		--sidebar-offset: var(--sidebar-w);
	}

	.app-shell[data-menu="rail"] .app-brand-logo-full,
	.app-shell[data-menu="rail"] .app-brand-logo-mini {
		display: none;
	}

	.app-shell[data-menu="rail"] .app-brand {
		justify-content: center;
		width: 100%;
	}

	.app-shell[data-menu="rail"] .app-brand-logo-mini {
		display: block;
	}

	.app-shell[data-menu="rail"] .app-sidebar-brand {
		justify-content: center;
		padding: 0 8px;
	}

	.app-shell[data-menu="rail"] .app-nav {
		padding: 10px 8px;
		scrollbar-width: none;
	}

	.app-shell[data-menu="rail"] .app-nav::-webkit-scrollbar {
		width: 0;
		height: 0;
	}

	.app-shell[data-menu="rail"] .app-nav a,
	.app-shell[data-menu="rail"] .app-sidebar-toggle {
		align-items: center;
		justify-content: center;
		width: 44px;
		min-width: 44px;
		height: 44px;
		min-height: 44px;
		padding: 0;
		margin: 0 auto;
	}

	.app-shell[data-menu="rail"] .app-nav-label {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
		border: 0;
	}

	.app-shell[data-menu="rail"] .app-nav a > .fa,
	.app-shell[data-menu="rail"] .app-nav a > .fa-fw {
		font-size: 18px;
	}

	.app-shell[data-menu="rail"] .app-nav a > .app-nav-svg {
		margin-right: 0;
	}

	.app-shell[data-menu="rail"] .app-nav-badge {
		top: 7px;
		right: 7px;
		width: 8px;
		height: 8px;
		margin: 0;
		padding: 0;
		border-radius: 50%;
		font-size: 0;
		line-height: 0;
	}

	.app-shell[data-menu="rail"] .app-sidebar-toggle {
		gap: 0;
	}

	.app-shell[data-menu="rail"] .app-collapse-icon {
		transform: rotate(180deg);
	}

	.app-shell[data-menu="rail"] .app-sidebar-footer {
		padding: 8px;
	}

	/* On a tablet the expanded menu floats over the page without moving it. */
	.app-shell[data-menu="overlay"] .app-main {
		margin-left: var(--sidebar-w-rail);
	}

	.app-shell[data-menu="overlay"] .app-overlay {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
	}

	.app-shell[data-menu="overlay"] .app-sidebar-close {
		display: inline-flex;
	}
}

@media (min-width: 1536px) {
	.app-shell {
		--sidebar-offset: var(--sidebar-w);
	}

	.app-shell[data-menu="rail"] {
		--sidebar-offset: var(--sidebar-w-rail);
	}
}

@media (max-width: 1023.98px) {
	.app-shell,
	.app-shell[data-menu="full"],
	.app-shell[data-menu="rail"],
	.app-shell[data-menu="overlay"] {
		--sidebar-offset: 0px;
	}

	.app-shell[data-menu="full"] .app-sidebar,
	.app-shell[data-menu="rail"] .app-sidebar,
	.app-shell[data-menu="overlay"] .app-sidebar {
		visibility: hidden;
		transform: translateX(-100%);
	}

	.app-shell[data-menu="full"] .app-main,
	.app-shell[data-menu="rail"] .app-main,
	.app-shell[data-menu="overlay"] .app-main {
		margin-left: 0;
	}

	.app-sidebar-footer {
		display: none;
	}
}

@media (min-width: 900px) {
	.app-logout-label {
		display: inline;
	}
}

@media (max-width: 719.98px) {
	.app-header {
		gap: 8px;
		padding-right: max(10px, env(safe-area-inset-right, 0px));
		padding-left: max(8px, env(safe-area-inset-left, 0px));
	}

	.app-header-left {
		gap: 6px;
	}

	.app-header-right {
		gap: 4px;
	}

	.app-section-title {
		font-size: 15px;
	}

	.app-btn {
		min-height: 44px;
		padding: 0 12px;
		font-size: 12px;
	}

	.app-btn.app-register-btn {
		height: 32px;
		min-height: 32px;
		padding: 0 12px;
		border-radius: 999px;
		font-size: 11.5px;
	}

	.app-icon-btn {
		width: 44px;
		height: 44px;
	}

	.app-content-inner {
		padding: 12px max(12px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.app-sidebar,
	.app-main,
	.app-overlay,
	.app-collapse-icon,
	.app-skip-link,
	.app-icon-btn,
	.app-nav a,
	.app-sidebar-toggle,
	.app-btn {
		transition: none !important;
	}
}

/* -------------------------------------------------------------------------
   Dashboard grid
   ------------------------------------------------------------------------- */

#widget-grid {
	margin: 0;
	padding: 0;
}

.dash-notices {
	margin: 0 0 var(--app-gap);
}

.dash-notices .ad-notice {
	margin-bottom: 0;
}

.dash-notices:empty {
	display: none;
}

.dash-grid {
	display: grid;
	grid-template-columns: minmax(0, var(--app-col-max));
	gap: var(--app-gap);
	align-items: start;
	justify-content: center;
	width: 100%;
}

.dash-grid[data-layout="2"] {
	grid-template-columns: repeat(2, minmax(0, var(--app-col-max)));
}

.dash-grid[data-layout="3"] {
	grid-template-columns: repeat(3, minmax(0, var(--app-col-max)));
}

.dash-col {
	display: flex;
	flex-direction: column;
	gap: var(--app-gap);
	min-width: 0;
}

.dash-col[hidden] {
	display: none !important;
}

.dash-col > .jarviswidget,
.dash-col > .dash-slot > .jarviswidget {
	width: 100%;
	margin: 0 !important;
}

.dash-grid .jarviswidget {
	border: 1px solid var(--app-border);
	border-radius: var(--app-radius) !important;
	box-shadow: var(--app-shadow);
}

.dash-grid .jarviswidget > header {
	border-radius: var(--app-radius) var(--app-radius) 0 0 !important;
}

.dash-grid .jarviswidget > div {
	border-radius: 0 0 var(--app-radius) var(--app-radius);
	overflow: hidden;
}

.ai-insights-slot {
	display: none;
}

.ai-insights-slot[hidden] {
	display: none !important;
}
