:root {
	/* Prisma Health Palette */
	--prism-lemon: #ffd600;
	--prism-tangerine: #f99b1c;
	--prism-apricot: #f15f22;
	--prism-rubine: #ed1849;
	--prism-fuchsia: #ec0086;
	--prism-plum: #b32572;
	--prism-eggplant: #830065;
	--prism-grey: #333333;
	--prism-light-grey: #f5f5f5;
	--prism-white: #ffffff;

	/* Functional Mappings */
	--phat-sidebar-bg: #1e293b;
	--phat-sidebar-text: #e2e8f0;
	--phat-sidebar-active: #334155;
	--phat-primary: #b32572;
	--phat-bg: #f3f4f6;
	--phat-surface: #ffffff;
	--phat-border: #e5e7eb;
	--phat-sidebar-width: 260px;
	--phat-header-height: 60px;
}

* {
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background: var(--phat-bg);
	color: #1f2937;
	margin: 0;
	padding: 0;
	height: 100vh;
	display: flex;
	overflow: hidden;
}

/* SIDEBAR */
.admin-sidebar {
	width: var(--phat-sidebar-width);
	background: var(--phat-sidebar-bg);
	color: var(--phat-sidebar-text);
	display: flex;
	flex-direction: column;
	border-right: 1px solid #0f172a;
	flex-shrink: 0;
}

.sidebar-header {
	height: var(--phat-header-height);
	padding: 0 20px;
	display: flex;
	align-items: center;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	background: rgba(0, 0, 0, 0.1);
}
.sidebar-header h1 {
	font-size: 16px;
	font-weight: 600;
	margin: 0;
	color: #fff;
	display: flex;
	align-items: center;
	gap: 10px;
}
.sidebar-header img {
	height: 24px;
	background: #fff;
	border-radius: 4px;
	padding: 2px;
}

.sidebar-nav {
	padding: 20px 0;
	flex: 1;
	overflow-y: auto;
}

.nav-section {
	padding: 15px 20px 5px;
	font-size: 11px;
	text-transform: uppercase;
	color: #94a3b8;
	font-weight: 700;
	letter-spacing: 0.5px;
}

.nav-item {
	display: flex;
	align-items: center;
	padding: 10px 20px;
	color: #cbd5e1;
	text-decoration: none;
	font-size: 14px;
	border-left: 3px solid transparent;
	transition: all 0.2s;
	cursor: pointer;
}
.nav-item:hover {
	background: rgba(255, 255, 255, 0.05);
	color: #fff;
}
.nav-item.active {
	background: var(--phat-sidebar-active);
	color: #fff;
	border-left-color: var(--prism-plum);
}
.nav-icon {
	width: 20px;
	margin-right: 10px;
	text-align: center;
	opacity: 0.8;
}

/* MAIN CONTENT */
.admin-main {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	position: relative;
}

.main-header {
	height: var(--phat-header-height);
	background: #fff;
	border-bottom: 1px solid var(--phat-border);
	padding: 0 30px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.main-header h2 {
	margin: 0;
	font-size: 20px;
	color: #111827;
}

.main-content-scroll {
	flex: 1;
	overflow-y: auto;
	padding: 30px;
}

/* CONTEXT BANNER */
.context-banner {
	background: #fffbeb;
	border-bottom: 1px solid #fde68a;
	padding: 8px 30px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 13px;
	color: #92400e;
	flex-shrink: 0;
}
.context-banner .org-info {
	display: flex;
	align-items: center;
	gap: 10px;
}
.context-banner .org-name {
	font-weight: 700;
	color: #b45309;
}
.context-banner .restore-btn {
	color: #b45309;
	text-decoration: underline;
	cursor: pointer;
	font-weight: 600;
	background: none;
	border: none;
	padding: 0;
	font-size: 12px;
}
.context-banner .restore-btn:hover {
	color: #92400e;
}

/* UTILS */
.phat-card {
	background: #fff;
	border: 1px solid var(--phat-border);
	border-radius: 6px;
	margin-bottom: 20px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.phat-section {
	padding: 20px;
}
.phat-site-header {
	padding: 15px 20px;
	background: #f9fafb;
	border-bottom: 1px solid var(--phat-border);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

/* BUTTONS */
.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 16px;
	font-size: 14px;
	font-weight: 500;
	border-radius: 6px;
	cursor: pointer;
	border: 1px solid #d1d5db;
	background: #fff;
	color: #374151;
	transition: all 0.2s;
	text-decoration: none;
}
.button:hover {
	background: #f3f4f6;
	border-color: #9ca3af;
}
.button-primary {
	background: #2563eb;
	color: #fff;
	border-color: #2563eb;
}
.button-primary:hover {
	background: #1d4ed8;
	border-color: #1d4ed8;
	color: #fff;
}
.button-small {
	padding: 4px 10px;
	font-size: 12px;
	min-height: 28px;
}

/* FORMS */
input,
select,
textarea {
	border: 1px solid #d1d5db;
	border-radius: 6px;
	padding: 8px 12px;
	font-size: 14px;
	width: 100%;
	background: #fff;
}
input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 1px #2563eb;
}

/* MODALS */
.phat-modal {
	display: none; /* Hidden by default */
	position: fixed;
	z-index: 1000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	overflow: auto;
}
.phat-modal-backdrop {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(2px);
	z-index: 1000;
}
.phat-modal-content {
	position: fixed; /* Force fixed centering */
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
	width: 800px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	z-index: 1001;
	overflow: hidden;
}
.modal-header {
	padding: 20px 30px;
	border-bottom: 1px solid var(--phat-border);
}
.modal-header h2 {
	margin: 0;
	font-size: 18px;
}

.phat-modal-tabs {
	display: flex;
	background: #f9fafb;
	border-bottom: 1px solid var(--phat-border);
	padding: 0 20px;
}
.phat-modal-tabs .modal-tab {
	padding: 15px 20px;
	cursor: pointer;
	color: #6b7280;
	font-weight: 500;
	border-bottom: 2px solid transparent;
}
.phat-modal-tabs .modal-tab.active {
	color: #2563eb;
	border-bottom-color: #2563eb;
}

.modal-body {
	padding: 30px;
	overflow-y: auto;
	flex: 1;
}
.modal-footer {
	padding: 20px 30px;
	border-top: 1px solid var(--phat-border);
	background: #f9fafb;
	text-align: right;
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

/* TABS VISIBILITY (IMPORTANT) */
.tab-content,
.modal-tab-content {
	display: none;
}
.tab-content.active,
.modal-tab-content.active {
	display: block;
	animation: fadeIn 0.3s;
}
.active-tab-content {
	display: block !important;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(5px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* LOGS */
.logs-split-view {
	display: flex;
	border: 1px solid var(--phat-border);
	border-radius: 6px;
	height: 600px;
	background: #fff;
}
.logs-list-pane {
	width: 350px;
	border-right: 1px solid var(--phat-border);
	overflow-y: auto;
	background: #f9fafb;
}
.logs-details-pane {
	flex: 1;
	overflow-y: auto;
	padding: 0;
}
.log-item {
	padding: 12px 15px;
	border-bottom: 1px solid var(--phat-border);
	cursor: pointer;
}
.log-item:hover {
	background: #fff;
}
.log-item.active {
	background: #eff6ff;
	border-left: 3px solid #2563eb;
}
.status-green {
	background: #10b981;
}
.status-orange {
	background: #f59e0b;
}
.log-status-badge {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	margin-right: 6px;
}

/* TABLES */
.wp-list-table {
	width: 100%;
	border-collapse: collapse;
}
.wp-list-table th {
	text-align: left;
	padding: 12px 20px;
	background: #f9fafb;
	border-bottom: 1px solid var(--phat-border);
	font-weight: 600;
	font-size: 13px;
	color: #6b7280;
	text-transform: uppercase;
}
.wp-list-table td {
	padding: 15px 20px;
	border-bottom: 1px solid var(--phat-border);
	color: #374151;
}
.wp-list-table tr:hover {
	background: #f9fafb;
}

/* SPINNER */
#phat-loader-overlay {
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	inset: 0;
	background: rgba(255, 255, 255, 0.8);
	z-index: 100;
}
.phat-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid #e5e7eb;
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: spin 1s linear infinite;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* UTILS */
.phat-row {
	display: flex;
	gap: 10px;
	margin-bottom: 10px;
	align-items: center;
}
.property-row,
.condition-row,
.transformation-row,
.shared-var-row {
	background: #f9fafb;
	padding: 10px;
	border-radius: 4px;
	border: 1px solid #e5e7eb;
}
.user-avatar-circle {
	width: 32px;
	height: 32px;
	background: var(--prism-plum);
	color: #fff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	font-size: 14px;
}
.user-profile {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* TOGGLES */
.toggle-switch-label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 13px;
	color: #374151;
}
.toggle-switch-wrapper {
	position: relative;
	width: 36px;
	height: 20px;
}
.toggle-switch-wrapper input {
	opacity: 0;
	width: 0;
	height: 0;
}
.toggle-switch {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: #ccc;
	transition: 0.4s;
	border-radius: 34px;
}
.toggle-switch:before {
	position: absolute;
	content: "";
	height: 16px;
	width: 16px;
	left: 2px;
	bottom: 2px;
	background-color: white;
	transition: 0.4s;
	border-radius: 50%;
}
.toggle-switch-wrapper input:checked + .toggle-switch {
	background-color: var(--phat-primary);
}
.toggle-switch-wrapper input:checked + .toggle-switch:before {
	transform: translateX(16px);
}

/* LOGIN PAGE OVERHAUL */
.login-page {
	background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100vh;
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.login-card {
	background: var(--phat-surface);
	width: 100%;
	max-width: 400px;
	padding: 40px;
	border-radius: 12px;
	box-shadow:
		0 20px 25px -5px rgba(0, 0, 0, 0.1),
		0 10px 10px -5px rgba(0, 0, 0, 0.04);
	text-align: center;
}

.login-header {
	margin-bottom: 30px;
}

.login-header h2 {
	color: var(--phat-primary);
	margin: 0 0 10px 0;
	font-size: 24px;
	font-weight: 700;
}

.login-header p {
	color: #64748b;
	margin: 0;
	font-size: 14px;
}

.login-form-group {
	margin-bottom: 20px;
	text-align: left;
}

.login-form-group label {
	display: block;
	margin-bottom: 8px;
	font-size: 13px;
	font-weight: 600;
	color: #334155;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.login-form-group input {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	font-size: 15px;
	transition: all 0.2s;
	outline: none;
}

.login-form-group input:focus {
	border-color: var(--phat-primary);
	box-shadow: 0 0 0 3px rgba(179, 37, 114, 0.1);
}

.login-btn {
	width: 100%;
	background: var(--phat-primary);
	color: white;
	border: none;
	padding: 14px;
	font-size: 16px;
	font-weight: 600;
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.2s;
}

.login-btn:hover {
	background: var(--prism-rubine);
}

.login-error {
	background: #fef2f2;
	color: #ef4444;
	padding: 12px;
	border-radius: 6px;
	font-size: 14px;
	margin-top: 20px;
	display: none;
	border: 1px solid #fee2e2;
}
