/**
 * AI-forward SaaS layer — works on top of CYBER / Bootstrap 5
 * Root: add .ai-saas on #app (admin) or .ai-saas-auth on body (login/errors)
 */

:root {
	--ai-cyan: #22d3ee;
	--ai-violet: #a78bfa;
	--ai-fuchsia: #e879f9;
	--ai-emerald: #34d399;
	--ai-amber: #fbbf24;
	--ai-surface: rgba(15, 23, 42, 0.55);
	--ai-border: rgba(148, 163, 184, 0.18);
	--ai-glow: 0 0 40px rgba(34, 211, 238, 0.12);
}

@keyframes ai-pulse-ring {
	0%, 100% { opacity: 0.55; transform: scale(1); }
	50% { opacity: 1; transform: scale(1.04); }
}

@keyframes ai-shimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

@keyframes ai-grid-drift {
	0% { background-position: 0 0, 0 0; }
	100% { background-position: 48px 48px, -24px -24px; }
}

/* ---- Admin shell ---- */
.ai-saas #appContent {
	position: relative;
}

.ai-saas .ai-saas-canvas {
	position: relative;
	z-index: 0;
	min-height: calc(100vh - 120px);
	background:
		radial-gradient(ellipse 80% 50% at 20% -10%, rgba(167, 139, 250, 0.16), transparent 50%),
		radial-gradient(ellipse 60% 40% at 100% 20%, rgba(34, 211, 238, 0.12), transparent 45%),
		radial-gradient(ellipse 50% 35% at 50% 100%, rgba(232, 121, 249, 0.08), transparent 40%);
}

.ai-saas .ai-saas-canvas::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	opacity: 0.35;
	background-image:
		linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
		linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
	background-size: 48px 48px;
	animation: ai-grid-drift 80s linear infinite;
}

.ai-saas .ai-saas-canvas > * {
	position: relative;
	z-index: 1;
}

/* Breadcrumb + page header */
.ai-saas .ai-breadcrumb-wrap {
	background: linear-gradient(90deg, rgba(15, 23, 42, 0.65), rgba(30, 27, 75, 0.35)) !important;
	border-bottom: 1px solid var(--ai-border) !important;
	backdrop-filter: blur(12px);
}

.ai-saas .breadcrumb {
	--bs-breadcrumb-divider-color: rgba(148, 163, 184, 0.4);
	margin-bottom: 0 !important;
}

.ai-saas .breadcrumb-item a {
	color: var(--ai-cyan) !important;
	text-decoration: none;
	font-weight: 500;
}

.ai-saas .breadcrumb-item.active {
	color: rgba(226, 232, 240, 0.9) !important;
}

.ai-saas .ai-page-header-wrap {
	background: linear-gradient(135deg, rgba(15, 23, 42, 0.5), rgba(49, 46, 129, 0.25)) !important;
	border-bottom: 1px solid var(--ai-border) !important;
	backdrop-filter: blur(10px);
}

.ai-saas .ai-page-header-wrap .page-header {
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.ai-saas .ai-page-header-wrap .page-header small {
	font-weight: 500;
	font-size: 0.85rem !important;
	letter-spacing: 0.02em;
}

/* AI badge / chip */
.ai-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.25rem 0.65rem;
	border-radius: 999px;
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(167, 139, 250, 0.25));
	border: 1px solid rgba(34, 211, 238, 0.35);
	color: #e0f2fe;
	box-shadow: 0 0 20px rgba(34, 211, 238, 0.15);
}

.ai-chip-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ai-emerald);
	box-shadow: 0 0 10px var(--ai-emerald);
	animation: ai-pulse-ring 2s ease-in-out infinite;
}

/* Glass cards */
.ai-glass-card {
	background: var(--ai-surface) !important;
	border: 1px solid var(--ai-border) !important;
	border-radius: 16px !important;
	box-shadow:
		0 4px 24px rgba(0, 0, 0, 0.25),
		var(--ai-glow);
	backdrop-filter: blur(14px);
	overflow: hidden;
	transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

.ai-glass-card:hover {
	border-color: rgba(34, 211, 238, 0.35) !important;
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.3),
		0 0 48px rgba(167, 139, 250, 0.08);
}

.ai-glass-card .card-body {
	padding: 1.25rem 1.35rem;
}

.ai-glass-card .card-footer {
	border-top: 1px solid var(--ai-border) !important;
	background: rgba(15, 23, 42, 0.35) !important;
}

/* Stat cards */
.ai-stat-card .ai-stat-icon {
	width: 48px;
	height: 48px;
	border-radius: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.35rem;
	background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(167, 139, 250, 0.3));
	border: 1px solid rgba(255, 255, 255, 0.1);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ai-stat-card.ai-stat-violet .ai-stat-icon {
	background: linear-gradient(135deg, rgba(167, 139, 250, 0.35), rgba(232, 121, 249, 0.25));
}

.ai-stat-card.ai-stat-emerald .ai-stat-icon {
	background: linear-gradient(135deg, rgba(52, 211, 153, 0.3), rgba(34, 211, 238, 0.2));
}

.ai-stat-card.ai-stat-amber .ai-stat-icon {
	background: linear-gradient(135deg, rgba(251, 191, 36, 0.35), rgba(249, 115, 22, 0.2));
}

.ai-stat-label {
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: rgba(226, 232, 240, 0.55) !important;
}

.ai-stat-value {
	font-size: 1.75rem;
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1.1;
	background: linear-gradient(90deg, #f8fafc, #a5f3fc 40%, #e9d5ff);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent !important;
}

.ai-stat-sub {
	font-size: 0.8rem;
	color: rgba(203, 213, 225, 0.65) !important;
}

/* Section title inside cards */
.ai-section-title {
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: rgba(165, 243, 252, 0.65) !important;
	margin-bottom: 0.75rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.ai-section-title::before {
	content: "";
	width: 4px;
	height: 1rem;
	border-radius: 2px;
	background: linear-gradient(180deg, var(--ai-cyan), var(--ai-violet));
}

/* Tables */
.ai-table-card .table {
	--bs-table-bg: transparent;
	--bs-table-hover-bg: rgba(34, 211, 238, 0.06);
	margin-bottom: 0;
}

.ai-table-card thead th {
	font-size: 0.68rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	border-bottom: 1px solid var(--ai-border) !important;
	color: rgba(203, 213, 225, 0.75) !important;
	padding-top: 1rem !important;
	padding-bottom: 1rem !important;
}

.ai-table-card tbody td {
	vertical-align: middle;
	border-color: rgba(148, 163, 184, 0.08) !important;
	padding-top: 0.9rem !important;
	padding-bottom: 0.9rem !important;
}

.ai-table-card .btn-sm {
	border-radius: 8px;
	font-weight: 600;
}

.ai-empty-state {
	text-align: center;
	padding: 3rem 1.5rem !important;
	color: rgba(203, 213, 225, 0.55);
}

.ai-empty-state i {
	font-size: 2.5rem;
	opacity: 0.35;
	display: block;
	margin-bottom: 1rem;
	background: linear-gradient(135deg, var(--ai-cyan), var(--ai-violet));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* Toolbar */
.ai-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.25rem;
}

.ai-toolbar .btn-theme {
	border-radius: 10px;
	font-weight: 700;
	text-transform: uppercase;
	font-size: 0.72rem;
	letter-spacing: 0.06em;
	padding: 0.55rem 1.1rem;
	box-shadow: 0 4px 20px rgba(34, 211, 238, 0.2);
}

/* Forms */
.ai-form-card .form-label {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: rgba(203, 213, 225, 0.8) !important;
	margin-bottom: 0.4rem;
}

.ai-form-card .form-control,
.ai-form-card .form-select {
	border-radius: 10px;
	background: rgba(15, 23, 42, 0.45) !important;
	border: 1px solid var(--ai-border) !important;
	color: inherit;
	padding: 0.65rem 0.9rem;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-form-card .form-control:focus,
.ai-form-card .form-select:focus {
	border-color: rgba(34, 211, 238, 0.55) !important;
	box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15) !important;
}

/* Alerts */
.ai-saas .alert {
	border-radius: 12px;
	border: 1px solid transparent;
	backdrop-filter: blur(8px);
}

.ai-saas .alert-success {
	background: rgba(52, 211, 153, 0.12) !important;
	border-color: rgba(52, 211, 153, 0.35) !important;
	color: #d1fae5 !important;
}

.ai-saas .alert-danger {
	background: rgba(248, 113, 113, 0.12) !important;
	border-color: rgba(248, 113, 113, 0.35) !important;
}

/* Header brand accent */
.ai-saas .app-header .brand-logo {
	position: relative;
}

.ai-saas .app-header .brand-logo::after {
	content: "";
	position: absolute;
	inset: -4px -8px;
	border-radius: 12px;
	background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(167, 139, 250, 0.15));
	z-index: -1;
	opacity: 0.9;
}

/* ---- Login / auth fullscreen ---- */
.ai-saas-auth {
	min-height: 100vh;
}

.ai-saas-auth .login {
	position: relative;
}

.ai-saas-auth .login::before,
.ai-saas-auth .login::after {
	content: "";
	position: fixed;
	width: 60vmax;
	height: 60vmax;
	border-radius: 50%;
	pointer-events: none;
	z-index: 0;
	filter: blur(80px);
	opacity: 0.5;
}

.ai-saas-auth .login::before {
	background: radial-gradient(circle, rgba(34, 211, 238, 0.35), transparent 60%);
	top: -20%;
	left: -15%;
	animation: ai-pulse-ring 12s ease-in-out infinite;
}

.ai-saas-auth .login::after {
	background: radial-gradient(circle, rgba(167, 139, 250, 0.4), transparent 60%);
	bottom: -25%;
	right: -20%;
	animation: ai-pulse-ring 14s ease-in-out infinite reverse;
}

.ai-saas-auth .login-content {
	position: relative;
	z-index: 2;
	max-width: 420px;
	margin: 0 auto;
	padding: 2rem 2rem 2.25rem;
	border-radius: 20px;
	background: rgba(15, 23, 42, 0.55) !important;
	border: 1px solid var(--ai-border) !important;
	backdrop-filter: blur(20px);
	box-shadow:
		0 24px 80px rgba(0, 0, 0, 0.45),
		0 0 0 1px rgba(255, 255, 255, 0.05) inset,
		var(--ai-glow);
}

.ai-saas-auth .login-content h1 {
	font-weight: 800;
	letter-spacing: -0.02em;
}

.ai-saas-auth .login-content .btn-outline-light {
	border-radius: 12px;
	font-weight: 700;
	border-width: 2px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(167, 139, 250, 0.15));
	border-color: rgba(34, 211, 238, 0.45);
}

.ai-saas-auth .login-content .btn-outline-light:hover {
	background: linear-gradient(135deg, rgba(34, 211, 238, 0.35), rgba(167, 139, 250, 0.3));
	border-color: rgba(255, 255, 255, 0.35);
}

.ai-saas-auth .login-content .form-control {
	border-radius: 12px;
	background: rgba(15, 23, 42, 0.5) !important;
	border: 1px solid var(--ai-border) !important;
}

.ai-saas-auth .login-content .form-control:focus {
	border-color: rgba(34, 211, 238, 0.55) !important;
	box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15) !important;
}

/* Error page polish */
.ai-saas-auth .error-page-content {
	position: relative;
	z-index: 2;
}

.ai-saas-auth .error-code {
	background: linear-gradient(135deg, #22d3ee, #a78bfa, #e879f9);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent !important;
	text-shadow: none;
	filter: drop-shadow(0 0 24px rgba(34, 211, 238, 0.35));
}

.ai-saas-auth .btn-outline-theme {
	border-radius: 10px;
	font-weight: 700;
}

/* Pagination */
.ai-saas .pagination .page-link {
	border-radius: 8px !important;
	margin: 0 2px;
	border: 1px solid var(--ai-border) !important;
	background: rgba(15, 23, 42, 0.4) !important;
}

.ai-saas .pagination .page-item.active .page-link {
	background: linear-gradient(135deg, rgba(34, 211, 238, 0.35), rgba(167, 139, 250, 0.35)) !important;
	border-color: rgba(34, 211, 238, 0.4) !important;
}

/* Chart container */
.ai-chart-wrap {
	border-radius: 12px;
	padding: 0.5rem;
	background: rgba(0, 0, 0, 0.15);
	border: 1px solid rgba(148, 163, 184, 0.1);
}

/* Sidebar active hint */
.ai-saas .menu-item.active > .menu-link {
	border-radius: 10px;
	background: linear-gradient(90deg, rgba(34, 211, 238, 0.12), transparent) !important;
	box-shadow: inset 2px 0 0 var(--ai-cyan);
}

.ai-saas .menu-profile-link {
	border-radius: 12px;
	border: 1px solid var(--ai-border);
	background: rgba(15, 23, 42, 0.35);
}
