/* CSS Variables - Status Colors */
:root {
	--status-added: #2ecc71;
	--status-edited: #f39c12;
	--status-moved: #3498db;
	--status-deleted: #c0392b;
}

/* Base styles */
body {
	background: #111;
	color: #eee;
	font-family: Arial, sans-serif;
	margin: 0;
}
header {
	text-align: center;
	padding: 24px;
	background: #1b1b1b;
}
header img {
	max-width: 640px;
	width: 100%;
	height: auto;
}
.subtitle {
	color: #ddd;
	font-size: 18px;
	letter-spacing: 2px;
	margin-top: 8px;
}

/* Login modal styles */
.login-container {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.85);
	z-index: 1000;
	justify-content: center;
	align-items: center;
	padding: 20px;
}

.login-container.show {
	display: flex;
}

.login-box {
	background: #1c1c1c;
	padding: 30px;
	border-radius: 12px;
	border: 2px solid #8a03f9;
	box-shadow: 0 10px 40px rgba(138, 3, 249, 0.3);
	width: 100%;
	max-width: 400px;
	position: relative;
	animation: modalSlideIn 0.3s ease-out;
}

/* Live DB warning modal */
.live-warning-modal {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.9);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 2000;
}

.live-warning-box {
	background: #1c1c1c;
	border: 3px solid #c0392b;
	border-radius: 14px;
	padding: 32px;
	text-align: center;
	max-width: 420px;

	animation: liveBeaconPulse 1.1s ease-in-out infinite;
}

/* stronger flashing glow outside the box */
.live-warning-box {
	animation: liveBeaconPulse 1.1s ease-in-out infinite;
}

/* Border "breathing" like an alarm */
.live-warning-box {
	animation: liveBeaconPulse 1.1s ease-in-out infinite;
}

@keyframes liveBeaconPulse {
	0% {
		border-color: #b92f23;
		box-shadow:
			0 0 25px rgba(192,57,43,0.45),
			0 0 0 rgba(255, 80, 80, 0.0);
	}
	50% {
		border-color: #ff4d4d;
		box-shadow:
			0 0 55px rgba(255,77,77,0.70),
			0 0 18px rgba(255,77,77,0.35);
	}
	100% {
		border-color: #b92f23;
		box-shadow:
			0 0 25px rgba(192,57,43,0.45),
			0 0 0 rgba(255, 80, 80, 0.0);
	}
}

/* Optional: reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
	.live-warning-box,
	.live-warning-box::before {
		animation: none !important;
	}
}

.live-warning-box h2 {
	margin-top: 0;
	color: #ff4d4d;
}

.live-warning-box button {
	margin-top: 20px;
	background: #c0392b;
	color: #fff;
	border: none;
	padding: 12px 20px;
	border-radius: 8px;
	font-weight: 700;
	cursor: pointer;
}

.live-warning-box button:hover {
	background: #e74c3c;
}

@keyframes modalSlideIn {
	from {
		opacity: 0;
		transform: translateY(-30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.login-box h3 {
	margin: 0 0 20px 0;
	color: #8a03f9;
	font-size: 20px;
	text-align: center;
}

.login-box input {
	width: 100%;
	padding: 12px 16px;
	margin-bottom: 15px;
	background: #252525;
	border: 2px solid #333;
	border-radius: 6px;
	color: #eee;
	font-size: 15px;
	box-sizing: border-box;
	transition: border-color 0.2s;
}

.login-box input:focus {
	outline: none;
	border-color: #8a03f9;
}

.login-box button {
	width: 100%;
	padding: 12px;
	background: #8a03f9;
	border: none;
	border-radius: 6px;
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.login-box button:hover {
	background: #7a02dc;
}

.error-message {
	background: #4a1515;
	border: 1px solid #8b2828;
	color: #ff6b6b;
	padding: 10px 15px;
	border-radius: 6px;
	margin-bottom: 15px;
	font-size: 14px;
	text-align: center;
}

/* User bar styles */
.user-bar {
	background: #1c1c1c;
	border-bottom: 2px solid #2a2a2a;
	padding: 12px 20px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 20px;
	position: sticky;
	top: 0;
	z-index: 1000;
	box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.user-bar-left {
	display: flex;
	align-items: center;
	gap: 15px;
	flex-wrap: wrap;
}

.user-identity {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-left: 15px;
	border-left: 2px solid #333;
}

.user-bar-right {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.user-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.user-name {
	color: #eee;
	font-weight: 600;
	font-size: 15px;
}

.staff-badge {
	background: #8a03f9;
	color: #fff;
	padding: 4px 12px;
	border-radius: 12px;
	font-size: 12px;
	font-weight: 600;
}

.btn-logout-inline {
	color: #ff6b6b;
	text-decoration: none;
	font-size: 13px;
	padding: 4px 10px;
	border-radius: 4px;
	transition: all 0.2s;
	font-weight: 500;
}

.btn-logout-inline:hover {
	background: rgba(255, 107, 107, 0.1);
	color: #ff5252;
}

.user-actions {
	display: flex;
	gap: 10px;
	align-items: center;
}

.btn-edit-mode {
	background: #2a2a2a;
	color: #eee;
	border: 2px solid #444;
	padding: 8px 16px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	transition: all 0.2s;
}

.btn-edit-mode:hover {
	background: #333;
	border-color: #555;
}

.btn-edit-mode.active {
	background: #8a03f9;
	border-color: #8a03f9;
	color: #fff;
}

.btn-logout {
	background: #4a1515;
	color: #ff6b6b;
	border: 2px solid #8b2828;
	padding: 8px 16px;
	border-radius: 6px;
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
	transition: all 0.2s;
	display: inline-block;
}

.btn-logout:hover {
	background: #5a1a1a;
	border-color: #a03030;
}

.page-intro {
	text-align: center;
	margin: 15px auto 10px;
	max-width: 900px;
	padding: 12px 18px;
	background: #161616;
	border: 1px solid #2a2a2a;
	border-radius: 10px;
}
.page-intro h1 {
	margin: 0 0 4px;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: 1px;
}
.page-intro p {
	margin: 0;
	color: #aaa;
	font-size: 14px;
}
.page-intro .hint {
	color: #8a03f9;
	font-weight: 600;
}
.page-intro a {
	transition: all 0.2s ease;
}
.page-intro a:hover {
	color: #a020ff;
	text-decoration: underline;
}

/* Rules page specific styles */
.rules-container {
	max-width: 900px;
	margin: 0 auto 40px;
	background: #1c1c1c;
	padding: 20px;
	border-radius: 12px;
}
.category-section {
	margin-bottom: 30px;
	background: #1a1a1a;
	border: 1px solid #2a2a2a;
	border-radius: 10px;
	padding: 20px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.category-section:last-child {
	margin-bottom: 0;
}
.category-header {
	color: #8a03f9;
	font-size: 20px;
	font-weight: 700;
	margin: 0 0 15px 0;
	padding-bottom: 8px;
	border-bottom: 2px solid #8a03f9;
	letter-spacing: 0.5px;
}
.rules-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.rule-item {
	background: #252525;
	border-radius: 10px;
	overflow: hidden;
	transition: all 0.3s ease;
	border: 2px solid #2a2a2a;
	position: relative;
}

.rule-item.status-added,
.rule-item.status-edited,
.rule-item.status-moved,
.rule-item.status-deleted {
	padding-left: 4px;
}
.rule-item:hover {
	border-color: #444;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.rule-item.expanded {
	border-color: #8a03f9;
	box-shadow: 0 6px 20px rgba(138, 3, 249, 0.15);
}
.rule-header {
	padding: 12px 16px;
	cursor: pointer;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	user-select: none;
	transition: background 0.2s;
}
.rule-header:hover {
	background: #2d2d2d;
}
.rule-item.expanded .rule-header {
	background: #2a2a2a;
}
.rule-number {
	color: #8a03f9;
	font-weight: 800;
	font-size: 16px;
	min-width: 45px;
	flex-shrink: 0;
}
.rule-text {
	flex: 1;
	color: #eee;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.4;
	padding-top: 2px;
}
.expand-icon {
	color: #666;
	font-size: 16px;
	transition: transform 0.3s ease, color 0.3s ease;
	margin-left: auto;
	flex-shrink: 0;
	margin-top: 2px;
}
.rule-item.expanded .expand-icon {
	color: #8a03f9;
}
.rule-details {
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.4s ease;
	background: #1e1e1e;
	border-top: 1px solid #333;
	padding: 0 16px;
}
.rule-details p {
	color: #bbb;
	font-size: 14px;
	line-height: 1.5;
	margin: 0;
	white-space: pre-wrap;
	padding: 12px 0;
}

/* Edit mode styles */
.btn-save-changes,
.btn-cancel-changes,
.btn-help {
	padding: 8px 16px;
	border-radius: 6px;
	border: 2px solid;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
}

.btn-save-changes {
	background: #2a2a2a;
	border-color: #2ecc71;
	color: #2ecc71;
}

.btn-save-changes:hover {
	background: #2ecc71;
	color: #fff;
}

.btn-cancel-changes {
	background: #2a2a2a;
	border-color: #e67e22;
	color: #e67e22;
}

.btn-cancel-changes:hover {
	background: #e67e22;
	color: #fff;
}

.btn-help {
	background: #2a2a2a;
	border-color: #3498db;
	color: #3498db;
}

.btn-help:hover {
	background: #3498db;
	color: #fff;
}

/* Menu button styles */
.btn-menu {
	padding: 8px 12px;
	border-radius: 6px;
	border: 2px solid #555;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	background: #2a2a2a;
	color: #ddd;
	position: relative;
}

.btn-menu:hover {
	background: #333;
	border-color: #666;
	color: #fff;
}

/* Dropdown menu */
.menu-dropdown {
	position: absolute;
	top: 100%;
	right: 0;
	margin-top: 8px;
	background: #1c1c1c;
	border: 2px solid #444;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
	min-width: 220px;
	z-index: 1000;
	overflow: hidden;
	animation: dropdownSlideIn 0.2s ease-out;
}

@keyframes dropdownSlideIn {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.menu-item {
	padding: 12px 16px;
	cursor: pointer;
	transition: all 0.2s;
	border-bottom: 1px solid #2a2a2a;
	display: flex;
	align-items: center;
	gap: 10px;
	color: #ddd;
	font-size: 14px;
	font-weight: 500;
}

.menu-item:last-child {
	border-bottom: none;
}

.menu-item:hover {
	background: #2a2a2a;
	color: #fff;
}

.menu-item-icon {
	font-size: 16px;
	width: 20px;
	text-align: center;
}

.menu-item-label {
	flex: 1;
}

.menu-item.menu-item-danger:hover {
	background: rgba(192, 57, 43, 0.2);
	color: #ff6b6b;
}

.menu-item.menu-item-primary:hover {
	background: rgba(138, 3, 249, 0.2);
	color: #8a03f9;
}

.menu-item.menu-item-warning:hover {
	background: rgba(243, 156, 18, 0.2);
	color: #f39c12;
}


/* Status indicators - left border strips */
.status-added {
	border-left: 4px solid var(--status-added) !important;
	padding-left: 16px !important;
}

.status-edited {
	border-left: 4px solid var(--status-edited) !important;
	padding-left: 16px !important;
}

.status-moved {
	border-left: 4px solid var(--status-moved) !important;
	padding-left: 16px !important;
}

.status-deleted {
	border-left: 4px solid var(--status-deleted) !important;
	padding-left: 16px !important;
	opacity: 0.6;
	text-decoration: line-through;
}

/* Edit controls for rules */
.rule-edit-header {
	padding: 12px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	background: #252525;
}

.rule-edit-controls {
	margin-left: auto;
	display: flex;
	gap: 6px;
	align-items: center;
}

.btn-inline-edit,
.btn-inline-delete,
.btn-inline-move {
	padding: 4px 10px;
	border-radius: 4px;
	border: 1px solid;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	background: transparent;
}

.btn-inline-move {
	border-color: #3498db;
	color: #3498db;
}

.btn-inline-move:hover {
	background: #3498db;
	color: #fff;
}

.btn-inline-edit {
	border-color: #8a03f9;
	color: #8a03f9;
}

.btn-inline-edit:hover {
	background: #8a03f9;
	color: #fff;
}

.btn-inline-delete {
	border-color: #c03030;
	color: #ff6b6b;
}

.btn-inline-delete:hover {
	background: #c03030;
	color: #fff;
}

.btn-arrow {
	padding: 2px 8px;
	border: 1px solid #555;
	background: #2a2a2a;
	color: #aaa;
	border-radius: 3px;
	font-size: 11px;
	cursor: pointer;
	transition: all 0.2s;
}

.btn-arrow:hover:not(:disabled) {
	background: #333;
	border-color: #666;
	color: #fff;
}

.btn-arrow:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

/* Drag handle */
.drag-handle {
	color: #666;
	font-size: 18px;
	padding: 0 4px;
	user-select: none;
	cursor: grab;
}

.drag-handle:active {
	cursor: grabbing;
}

.drag-handle:hover {
	color: #8a03f9;
}

/* Drop indicator overlays - positioned absolutely so they don't affect layout */
.drop-indicator-top,
.drop-indicator-bottom {
	position: relative;
}

.drop-indicator-top::before,
.drop-indicator-bottom::before {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	height: 3px;
	background: #8a03f9;
	z-index: 100;
	pointer-events: none;
	box-shadow: 0 0 8px rgba(138, 3, 249, 0.6);
}

.drop-indicator-top::before {
	top: 0;
}

.drop-indicator-bottom::before {
	bottom: 0;
}

.drop-indicator-top::after,
.drop-indicator-bottom::after {
	content: attr(data-drop-message);
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	background: #8a03f9;
	color: white;
	padding: 8px 16px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	z-index: 1000;
	pointer-events: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.drop-indicator-top::after {
	top: 20px;
}

.drop-indicator-bottom::after {
	bottom: 20px;
}

/* Category indicators */
.category-section.drop-indicator-top::after,
.category-section.drop-indicator-bottom::after {
	content: 'Drop here to swap';
	font-size: 13px;
}

.rules-list.drop-target-empty {
	position: relative;
	background: rgba(138, 3, 249, 0.1) !important;
	border: 2px dashed #8a03f9 !important;
	border-radius: 8px;
	min-height: 80px;
}

.rules-list.drop-target-empty .empty-category-placeholder {
	opacity: 0.3;
}

.rules-list.drop-target-empty::after {
	content: attr(data-drop-message);
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: #8a03f9;
	font-size: 14px;
	font-weight: 600;
	pointer-events: none;
	z-index: 10;
}

/* Dragging state */
.dragging {
	opacity: 0.4;
}

/* Category edit controls */
.category-header {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.category-display {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 8px;
}

.category-overview-checkbox {
	display: flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	padding: 4px 8px;
	background: #2a2a2a;
	border-radius: 4px;
	border: 1px solid #444;
	transition: all 0.2s;
}

.category-overview-checkbox:hover {
	background: #333;
	border-color: #555;
}

.category-overview-checkbox input[type="checkbox"] {
	cursor: pointer;
	width: 16px;
	height: 16px;
	margin: 0;
}

.category-edit-controls {
	display: flex;
	gap: 6px;
	align-items: center;
	margin-left: auto;
}

/* Rule details in edit mode - always visible */
.rule-details-edit {
	background: #1e1e1e;
	border-top: 1px solid #333;
	padding: 12px 16px;
	margin-left: 56px; /* Align with rule text (drag handle + rule number width) */
	margin-right: 16px; /* Add right margin for spacing */
}

.rule-details-edit p {
	color: #bbb;
	font-size: 14px;
	line-height: 1.5;
	margin: 0;
	padding: 0;
	white-space: pre-wrap;
}

/* Add buttons */
.btn-add-rule,
.btn-add-category {
	width: 100%;
	padding: 12px;
	margin-top: 15px;
	background: #2a2a2a;
	border: 2px dashed #555;
	border-radius: 8px;
	color: #8a03f9;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
}

.btn-add-rule:hover,
.btn-add-category:hover {
	background: #333;
	border-color: #8a03f9;
	color: #fff;
}

.btn-add-category {
	margin-bottom: 20px;
}

/* Modal styles */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.8);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 2000;
	animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.modal-box {
	background: #1c1c1c;
	border: 2px solid #8a03f9;
	border-radius: 12px;
	padding: 30px;
	max-width: 500px;
	width: 90%;
	box-shadow: 0 10px 40px rgba(138, 3, 249, 0.3);
	animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.modal-box h3 {
	margin: 0 0 15px 0;
	color: #8a03f9;
	font-size: 20px;
}

.modal-box p {
	color: #ccc;
	margin-bottom: 10px;
}

.modal-box button {
	padding: 10px 20px;
	border: none;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
}

.modal-box button:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-box select,
.modal-box input[type="text"] {
	box-sizing: border-box;
}

.modal-box input[type="text"]:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.modal-box input[type="text"]:focus {
	outline: none;
	border-color: #8a03f9;
	box-shadow: 0 0 0 3px rgba(138, 3, 249, 0.1);
}

/* Environment badge */
.env-badge {
	position: fixed;
	top: 10px;
	right: 10px;
	z-index: 1001;
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 1px;
	text-transform: uppercase;
	box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.env-badge-inline {
	padding: 4px 10px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 1px;
	text-transform: uppercase;
	text-decoration: none;
	display: inline-block;
	transition: opacity 0.2s;
}

.env-badge-inline:hover {
	opacity: 0.85;
}

.env-live {
	background: #c0392b;
	color: #fff;
}

.env-test {
	background: #2ecc71;
	color: #111;
}

.btn-view-overview {
	background: #8a03f9;
	padding: 8px 16px;
	border: none;
	border-radius: 4px;
	color: white;
	cursor: pointer;
	font-size: 14px;
	margin-right: 10px;
	transition: background 0.2s;
}

.btn-view-overview:hover {
	background: #5a0c9d;
}

@media (max-width: 768px) {
	.rules-container {
		padding: 20px 16px;
	}
	
	.category-header {
		font-size: 22px;
		flex-wrap: wrap;
	}
	
	.rule-number {
		min-width: 40px;
		font-size: 18px;
	}
	
	.rule-text {
		font-size: 15px;
	}
	
	.rule-header {
		padding: 16px 18px;
		gap: 12px;
	}
	
	.rule-edit-header {
		flex-wrap: wrap;
	}
	
	.rule-edit-controls,
	.category-edit-controls {
		flex-wrap: wrap;
	}
	
	.user-bar {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}
	
	.user-bar-left,
	.user-bar-right {
		flex-wrap: wrap;
		justify-content: center;
	}
	
	.user-identity {
		border-left: none;
		padding-left: 0;
		padding-top: 10px;
		border-top: 1px solid #333;
		width: 100%;
		justify-content: center;
	}
	
	.user-actions {
		width: 100%;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	
	.login-box {
		padding: 20px;
	}
	
	.modal-box {
		padding: 20px;
	}
}

/* ===================================================================
   PERMISSIONS EDITOR MODAL STYLES
   =================================================================== */

/* Full-page permissions modal */
.permissions-modal-fullpage {
	max-width: none !important;
	width: 95vw !important;
	height: 95vh !important;
	display: flex !important;
	flex-direction: column !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 2px solid #8a03f9;
	border-radius: 12px;
	overflow: hidden;
}

.permissions-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px;
	border-bottom: 2px solid #333;
	background: #1a1a1a;
	flex-shrink: 0;
}

.permissions-grid-wrapper {
	flex: 1;
	overflow: auto;
	background: #111;
	position: relative;
	min-height: 0; /* Critical for flex container scrolling */
}

/* Tab container */
.permissions-modal-fullpage > div[style*="border-bottom"] {
	background: #1a1a1a;
	flex-shrink: 0;
}

.permissions-footer {
	display: flex;
	gap: 10px;
	justify-content: flex-end;
	padding: 20px;
	border-top: 2px solid #333;
	background: #1a1a1a;
	flex-shrink: 0;
}

/* Permission tabs */
.perm-tab {
	background: #2a2a2a;
	color: #ccc;
	border: none;
	padding: 10px 20px;
	cursor: pointer;
	font-size: 14px;
	border-radius: 6px 6px 0 0;
	transition: all 0.2s;
	font-weight: 500;
}

.perm-tab:hover {
	background: #333;
	color: #fff;
}

.perm-tab.active {
	background: #8c03fc;
	color: #fff;
	font-weight: 600;
}

/* Tab content wrapper */
.perm-tab-content {
	padding: 20px;
}

/* Permissions grid container */
.perm-grid {
	display: inline-block;
	background: #1a1a1a;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid #333;
	min-width: 100%;
}

/* Header row container */
.perm-grid-header {
	display: flex;
	background: #2a2a2a;
	border-bottom: 2px solid #444;
	position: sticky;
	top: 0;
	z-index: 10;
}

/* Regular row container */
.perm-grid-row {
	display: flex;
	border-bottom: 1px solid #333;
}

/* Zebra striping */
.perm-grid-row:nth-child(even) {
	background: #1a1a1a;
}

.perm-grid-row:nth-child(odd) {
	background: #151515;
}

/* Hover effect */
.perm-grid-row:hover {
	background: #252525 !important;
}

/* All cells base styling */
.perm-grid-cell {
	padding: 12px 10px;
	border-right: 1px solid #333;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 120px;
	max-width: 120px;
	flex-shrink: 0;
}

/* Remove border from last cell in each row */
.perm-grid-header > .perm-grid-cell:last-child,
.perm-grid-row > .perm-grid-cell:last-child {
	border-right: none;
}

/* Header cells */
.perm-grid-header > .perm-grid-cell {
	color: #fff;
	font-weight: 600;
	font-size: 13px;
	padding: 14px 10px;
	text-align: center;
	overflow-wrap: break-word;
	white-space: normal;
	line-height: 1.3;
}

/* First cell in header AND rows (permission label column) */
.perm-grid-header > .perm-grid-cell:first-child,
.perm-grid-row > .perm-grid-cell:first-child {
	min-width: 200px;
	max-width: 200px;
	width: 200px;
	justify-content: flex-start;
	text-align: left;
	position: sticky;
	left: 0;
	z-index: 5;
	border-right: 2px solid #444;
}

/* Header first cell gets higher z-index */
.perm-grid-header > .perm-grid-cell:first-child {
	z-index: 15;
	background: #2a2a2a;
	font-size: 14px;
}

/* Row first cells maintain row background */
.perm-grid-row > .perm-grid-cell:first-child {
	font-weight: 500;
	color: #8c03fc;
	font-size: 13px;
	background: inherit;
}

/* Ensure sticky backgrounds work on zebra rows */
.perm-grid-row:nth-child(even) > .perm-grid-cell:first-child {
	background: #1a1a1a;
}

.perm-grid-row:nth-child(odd) > .perm-grid-cell:first-child {
	background: #151515;
}

/* Maintain background on hover for sticky column */
.perm-grid-row:hover > .perm-grid-cell:first-child {
	background: #252525 !important;
}

/* Role header cells */
.role-header {
	font-size: 12px;
	font-weight: 600;
	text-align: center;
}

/* Permission checkboxes */
.perm-checkbox {
	width: 20px;
	height: 20px;
	cursor: pointer;
	accent-color: #8c03fc;
	margin: 0;
}

.perm-checkbox:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Mobile responsiveness for permissions editor */
@media (max-width: 768px) {
	.permissions-modal-fullpage {
		width: 100vw !important;
		height: 100vh !important;
		max-height: 100vh !important;
		border-radius: 0 !important;
		overflow: hidden !important;
	}
	
	.permissions-header {
		padding: 15px;
		flex-shrink: 0;
	}
	
	.permissions-header h3 {
		font-size: 18px;
	}
	
	/* Tab container */
	.permissions-modal-fullpage > div[style*="border-bottom"] {
		flex-shrink: 0;
	}
	
	.perm-tab {
		padding: 8px 12px;
		font-size: 12px;
	}
	
	.perm-tab-content {
		padding: 10px;
		height: 100%;
		overflow: auto;
	}
	
	/* Fix grid wrapper to not take too much space */
	.permissions-grid-wrapper {
		flex: 1 1 auto;
		min-height: 0 !important;
		max-height: none;
		overflow: auto;
	}
	
	/* Make grid scrollable horizontally on mobile */
	.perm-grid {
		min-width: auto;
		overflow-x: auto;
	}
	
	/* Reduce cell sizes on mobile */
	.perm-grid-cell {
		min-width: 90px;
		max-width: 90px;
		padding: 10px 6px;
		font-size: 11px;
	}
	
	.perm-grid-header > .perm-grid-cell {
		padding: 12px 6px;
		font-size: 11px;
	}
	
	/* Keep first column visible but narrower */
	.perm-grid-header > .perm-grid-cell:first-child,
	.perm-grid-row > .perm-grid-cell:first-child {
		min-width: 140px;
		max-width: 140px;
		width: 140px;
		font-size: 11px;
	}
	
	.permissions-footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 12px;
		flex-direction: row;
		gap: 8px;
		flex-shrink: 0;
		z-index: 10;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
	}
	
	.permissions-footer button {
		flex: 1;
		padding: 12px !important;
		margin: 0 !important;
	}
	
	/* Add padding to permissions-grid-wrapper to account for fixed footer */
	.permissions-grid-wrapper {
		padding-bottom: 70px;
	}
}

/* Extra small devices */
@media (max-width: 480px) {
	.perm-grid-cell {
		min-width: 70px;
		max-width: 70px;
		padding: 8px 4px;
		font-size: 10px;
	}
	
	.perm-grid-header > .perm-grid-cell {
		padding: 10px 4px;
		font-size: 10px;
	}
	
	.perm-grid-header > .perm-grid-cell:first-child,
	.perm-grid-row > .perm-grid-cell:first-child {
		min-width: 110px;
		max-width: 110px;
		width: 110px;
		font-size: 10px;
	}
	
	.perm-checkbox {
		width: 16px;
		height: 16px;
	}
	
	.perm-tab {
		padding: 6px 8px;
		font-size: 11px;
	}
}

/* ===================================================================
   AUDIT LOG MODAL STYLES
   =================================================================== */

/* Desktop styles for audit log table */
#auditLogTable {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

#auditLogTable thead {
	position: sticky;
	top: 0;
	background: #1a1a1a;
	z-index: 10;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#auditLogTable th {
	padding: 12px 8px;
	text-align: left;
	border-bottom: 2px solid #333;
	cursor: pointer;
	user-select: none;
	color: #fff;
	font-weight: 600;
}

#auditLogTable td {
	padding: 10px 8px;
	border-bottom: 1px solid #333;
	color: #ddd;
}

#auditLogTable tbody tr:hover {
	background: #252525;
}

/* Mobile styles for audit log */
@media (max-width: 768px) {
	/* Make filters stack vertically */
	#auditLogModal .permissions-header {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}
	
	#auditLogModal .permissions-header h3 {
		font-size: 18px;
	}
	
	#auditLogModal .permissions-header button {
		width: 100%;
	}
	
	/* Stack filter grid on mobile */
	#auditLogModal div[style*="grid-template-columns"] {
		display: flex !important;
		flex-direction: column !important;
		gap: 10px !important;
	}
	
	/* Convert table to card layout on mobile */
	#auditLogTable thead {
		display: none;
	}
	
	#auditLogTable tbody {
		display: block;
	}
	
	#auditLogTable tbody tr {
		display: block;
		margin-bottom: 15px;
		background: #1a1a1a;
		border: 1px solid #333;
		border-radius: 8px;
		padding: 12px;
	}
	
	#auditLogTable tbody tr:hover {
		background: #252525;
		border-color: #444;
	}
	
	#auditLogTable tbody td {
		display: block;
		padding: 6px 0;
		border: none;
		text-align: left;
	}
	
	/* Add labels before each cell on mobile */
	#auditLogTable tbody td:nth-child(1)::before {
		content: "Time: ";
		font-weight: 600;
		color: #8c03fc;
		display: inline;
	}
	
	#auditLogTable tbody td:nth-child(2)::before {
		content: "Player: ";
		font-weight: 600;
		color: #8c03fc;
		display: inline;
	}
	
	#auditLogTable tbody td:nth-child(3)::before {
		content: "Database: ";
		font-weight: 600;
		color: #8c03fc;
		display: inline;
	}
	
	#auditLogTable tbody td:nth-child(4)::before {
		content: "Summary: ";
		font-weight: 600;
		color: #8c03fc;
		display: inline;
	}
	
	#auditLogTable tbody td:nth-child(5)::before {
		content: "Details: ";
		font-weight: 600;
		color: #8c03fc;
		display: inline;
		vertical-align: top;
	}
	
	/* Make details text wrap nicely */
	#auditLogTable tbody td:nth-child(5) {
		word-wrap: break-word;
		overflow-wrap: break-word;
		white-space: pre-wrap;
	}
	
	/* Adjust pagination for mobile */
	#auditLogModal div[style*="justify-content: space-between"] {
		flex-direction: column !important;
		gap: 10px !important;
	}
	
	#auditPaginationInfo {
		text-align: center;
	}
	
	#auditPaginationControls {
		justify-content: center !important;
		flex-wrap: wrap !important;
	}
	
	/* Make filter buttons stack */
	#auditLogModal div[style*="gap: 10px; margin-top: 10px"] {
		flex-direction: column !important;
	}
	
	#auditLogModal div[style*="gap: 10px; margin-top: 10px"] button {
		width: 100%;
	}
}

/* Extra small devices - even more compact */
@media (max-width: 480px) {
	#auditLogTable tbody tr {
		padding: 10px;
		font-size: 12px;
	}
	
	#auditLogTable tbody td {
		padding: 5px 0;
		font-size: 12px;
	}
	
	#auditLogModal .permissions-header {
		padding: 12px;
	}
	
	#auditLogModal div[style*="padding: 20px"] {
		padding: 12px !important;
	}
}
