/* Page Loader */
.shortcodeglut-page-loader {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(245, 245, 245, 0.98);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 9999;
}

.shortcodeglut-loader-spinner {
	width: 50px;
	height: 50px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #2271b1;
	border-radius: 50%;
	animation: shortcodeglut-spin 1s linear infinite;
}

@keyframes shortcodeglut-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.shortcodeglut-loader-text {
	margin-top: 20px;
	font-size: 16px;
	font-weight: 500;
	color: #1d2327;
	animation: shortcodeglut-pulse 1.5s ease-in-out infinite;
}

@keyframes shortcodeglut-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

/* Template Editor Page - Full Width Layout */
body.shortcodeglut-fullpage-editor #wpwrap {
	margin-top: 0 !important;
}

body.shortcodeglut-fullpage-editor #adminmenumain {
	display: none !important;
}

body.shortcodeglut-fullpage-editor #wpbody {
	margin-left: 0 !important;
}

body.shortcodeglut-fullpage-editor #wpbody-content {
	padding-left: 0 !important;
	padding-bottom: 0 !important;
}

body.shortcodeglut-fullpage-editor #wpcontent,
body.shortcodeglut-fullpage-editor #wpfooter {
	margin-left: 0 !important;
}

body.shortcodeglut-fullpage-editor.html.wp-toolbar {
	padding-top: 0 !important;
}

/* More specific override for html.wp-toolbar */
html.shortcodeglut-fullpage-editor.wp-toolbar {
	padding-top: 0 !important;
	box-sizing: border-box;
}

/* Direct targeting with maximum specificity */
html.shortcodeglut-fullpage-editor.wp-toolbar[xmlns] {
	padding-top: 0 !important;
}

body.shortcodeglut-fullpage-editor .wrap {
	margin: 20px;
}

/* Template Editor Page Layout */
.shortcodeglut-template-editor-page {
	max-width: 100%;
	padding: 0;
	min-height: calc(100vh - 100px);
	position: relative;
	clear: both;
}

/* Editor Header with Back Button */
.shortcodeglut-editor-header {
	display: flex;
	align-items: center;
	margin-bottom: 20px;
	position: relative;
}

.shortcodeglut-header-left {
	flex-shrink: 0;
}

.shortcodeglut-header-left .button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	font-size: 14px;
	height: auto;
	line-height: 1.4;
}

.shortcodeglut-header-left .button .dashicons {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	font-size: 18px;
}

.shortcodeglut-header-center {
	flex: 1;
}

.shortcodeglut-header-center h1 {
	margin: 0;
	padding: 0;
	font-size: 23px;
	font-weight: 400;
	line-height: 1.3;
}

.shortcodeglut-header-right {
	flex-shrink: 0;
}

.shortcodeglut-header-right .button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	font-size: 14px;
	height: auto;
	line-height: 1.4;
}

.shortcodeglut-header-right .button .dashicons {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	font-size: 18px;
}

/* Editor Layout with Sidebar */
.shortcodeglut-editor-layout {
	display: flex;
	gap: 20px;
	margin-top: 20px;
}

.shortcodeglut-editor-main {
	flex: 1;
	max-width: calc(100% - 350px);
	padding-bottom: 150px;
}

.shortcodeglut-editor-sidebar {
	width: 340px;
	flex-shrink: 0;
}

/* Form Field Styling - Labels Above Inputs */
.shortcodeglut-form-field {
	margin-bottom: 25px;
}

.shortcodeglut-form-field > label {
	display: block;
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 8px;
	color: #1d2327;
}

.shortcodeglut-form-field input[type="text"],
.shortcodeglut-form-field input[type="email"],
.shortcodeglut-form-field input[type="url"],
.shortcodeglut-form-field textarea,
.shortcodeglut-form-field select {
	width: 100%;
	max-width: 100%;
}

.shortcodeglut-form-field .description {
	margin-top: 8px;
	font-size: 13px;
	color: #646970;
	font-style: normal;
}

/* Form Row - Side by Side Fields */
.shortcodeglut-form-row {
	display: flex;
	gap: 20px;
	margin-bottom: 25px;
}

.shortcodeglut-form-half {
	flex: 1;
	min-width: 0;
}

.shortcodeglut-form-half .shortcodeglut-form-field {
	margin-bottom: 0;
}

/* Tags Panel */
.shortcodeglut-tags-panel {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 15px;
	max-height: calc(100vh - 150px);
	overflow-y: auto;
	position: sticky;
	top: 20px;
}

.shortcodeglut-tags-panel h3 {
	margin-top: 0;
	font-size: 14px;
	font-weight: 600;
	padding-bottom: 10px;
	border-bottom: 1px solid #c3c4c7;
	margin-bottom: 10px;
}

.shortcodeglut-tags-panel .description {
	font-size: 11px;
	color: #646970;
	margin-bottom: 12px;
	line-height: 1.4;
}

.shortcodeglut-tag-category {
	margin-bottom: 15px;
}

.shortcodeglut-tag-category:last-child {
	margin-bottom: 0;
}

.shortcodeglut-tag-category h4 {
	font-size: 11px;
	font-weight: 600;
	margin: 0 0 8px 0;
	color: #1d2327;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding-bottom: 5px;
	border-bottom: 1px dashed #c3c4c7;
}

.shortcodeglut-tag-list {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
	max-height: 500px;
	overflow-y: auto;
	padding-right: 5px;
}

/* Scrollbar styling for tag list */
.shortcodeglut-tag-list::-webkit-scrollbar {
	width: 6px;
}

.shortcodeglut-tag-list::-webkit-scrollbar-track {
	background: #f0f0f1;
	border-radius: 3px;
}

.shortcodeglut-tag-list::-webkit-scrollbar-thumb {
	background: #c3c4c7;
	border-radius: 3px;
}

.shortcodeglut-tag-list::-webkit-scrollbar-thumb:hover {
	background: #a7aaad;
}

.shortcodeglut-tag-item {
	background: #f6f7f7;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 8px;
	font-size: 11px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.shortcodeglut-tag-item:hover {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
	transform: translateY(-1px);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.shortcodeglut-tag-item code {
	background: none;
	padding: 0;
	font-size: 11px;
	color: inherit;
	font-weight: 600;
	font-family: Monaco, Consolas, monospace;
	word-break: break-all;
}

.shortcodeglut-tag-description {
	font-size: 10px;
	opacity: 0.85;
	line-height: 1.3;
	word-break: break-word;
}

/* Form Table Adjustments */
.shortcodeglut-template-editor-page .form-table {
	max-width: 100%;
}

.shortcodeglut-template-editor-page .form-table td {
	padding: 15px 10px;
}

/* HTML Template Textarea */
.shortcodeglut-template-editor-page #template_html {
	font-family: Monaco, Consolas, monospace;
	font-size: 13px;
	line-height: 1.5;
	tab-size: 4;
}

/* CSS Textarea */
.shortcodeglut-template-editor-page #template_css {
	font-family: Monaco, Consolas, monospace;
	font-size: 13px;
	line-height: 1.5;
	tab-size: 4;
}

/* Responsive */
@media (max-width: 1200px) {
	.shortcodeglut-editor-layout {
		flex-direction: column;
	}

	.shortcodeglut-editor-main {
		max-width: 100%;
	}

	.shortcodeglut-editor-sidebar {
		width: 100%;
		max-width: 100%;
		max-height: 400px;
	}

	.shortcodeglut-tag-list {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* Responsive for shortcodeglut header */
@media (max-width: 768px) {
	.shortcodeglut-editor-header {
		flex-wrap: wrap;
		gap: 10px;
	}

	.shortcodeglut-header-left {
		width: 100%;
	}

	.shortcodeglut-header-center h1 {
		font-size: 20px;
	}

	.shortcodeglut-editor-sidebar {
		max-height: 350px;
	}

	.shortcodeglut-tag-list {
		grid-template-columns: repeat(2, 1fr);
	}

	.scg-code-editor {
		min-height: 300px;
	}
}

/* Responsive for shortcodeglut header */
@media (max-width: 768px) {
	.shortcodeglut-editor-header {
		flex-wrap: wrap;
		gap: 10px;
	}

	.shortcodeglut-header-left {
		width: 100%;
	}

	.shortcodeglut-header-center {
		width: 100%;
	}

	.shortcodeglut-header-center h1 {
		font-size: 20px;
	}
}

/* Fixed Form Actions at Bottom Left */
.shortcodeglut-form-actions {
	position: fixed;
	bottom: 0;
	left: 0;
	z-index: 1001;
	background: #fff;
	padding: 15px 20px;
	border-radius: 0;
	box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	border-top: 1px solid #c3c4c7;
	border-right: 1px solid #c3c4c7;
	display: flex;
	gap: 15px;
}

/* Ensure WordPress footer stays at bottom */
.shortcodeglut-template-editor-page {
	min-height: calc(100vh - 32px - 50px);
}

/* Hide WordPress admin footer on template editor page */
body.shortcodeglut-fullpage-editor #wpfooter {
	display: none !important;
}

.shortcodeglut-form-actions .button {
	margin: 0;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 600;
	height: 46px;
	line-height: 1.2;
	min-width: 120px;
}

.shortcodeglut-form-actions .button.button-primary {
	padding: 12px 28px;
}

/* Responsive styles for fixed buttons */
@media (max-width: 768px) {
	.shortcodeglut-form-actions {
		right: 0;
		padding: 12px 15px;
		gap: 10px;
	}

	.shortcodeglut-form-actions .button {
		flex: 1;
		text-align: center;
		font-size: 14px;
		padding: 10px 20px;
		min-width: 100px;
	}
}

/* Fix button text color */
.shortcodeglut-form-actions .button.button-primary {
	color: #ffffff !important;
}

/* Ensure white text on primary button */
.shortcodeglut-form-actions .button.button-primary,
.shortcodeglut-form-actions .button.button-primary:hover,
.shortcodeglut-form-actions .button.button-primary:focus {
	color: #ffffff !important;
}

/* ====== NEW TEMPLATE EDITOR STYLES (scg-*) ====== */

/* Required field indicator */
.required {
	color: #dc3232;
	font-weight: bold;
}

/* Editor Layout */
.scg-editor-body {
	display: flex;
	gap: 20px;
	align-items: flex-start;
}

.scg-editors-section {
	flex: 1;
	min-width: 0;
}

.scg-form-group {
	margin-bottom: 20px;
}

.scg-form-group > label {
	display: block;
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 8px;
	color: #1d2327;
}

/* Form Row Layout - Side by Side Fields */
.scg-form-row {
	display: flex;
	gap: 20px;
	margin-bottom: 20px;
}

.scg-form-half {
	flex: 1;
	min-width: 0;
}

.scg-form-half .scg-form-group {
	margin-bottom: 0;
}

.scg-code-editor {
	width: 100%;
	min-height: 400px;
	font-family: Monaco, Consolas, monospace;
	font-size: 13px;
	line-height: 1.5;
	padding: 12px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	background: #f6f7f7;
	resize: vertical;
}

.scg-code-editor:focus {
	border-color: #2271b1;
	outline: none;
	background: #fff;
}

/* Tags Sidebar - 2 Column Layout */
.scg-tags-sidebar {
	width: 520px;
	flex-shrink: 0;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	overflow: hidden;
	max-height: calc(100vh - 200px);
	display: flex;
	flex-direction: column;
}

.scg-tags-header {
	padding: 15px 18px;
	background: #f6f7f7;
	border-bottom: 1px solid #c3c4c7;
}

.scg-tags-header h3 {
	margin: 0 0 5px 0;
	font-size: 15px;
	font-weight: 600;
	color: #1d2327;
}

.scg-tags-header p {
	margin: 0;
	font-size: 12px;
	color: #646970;
}

.scg-tags-list {
	flex: 1;
	overflow-y: auto;
	padding: 15px;
	background: #fff;
}

/* 2-Column Grid for Tags */
.scg-tag-section {
	margin-bottom: 18px;
}

.scg-tag-section:last-child {
	margin-bottom: 0;
}

.scg-tag-section h4 {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin: 0 0 10px 0;
	padding-bottom: 6px;
	border-bottom: 1px dashed #c3c4c7;
	color: #1d2327;
}

/* Grid layout for tag items - 2 columns */
.scg-tag-section .scg-tag-items {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px 10px;
}

.scg-tag-item {
	background: #f6f7f7;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 8px 10px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.scg-tag-item:hover {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
	transform: translateY(-1px);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.scg-tag-item code {
	font-family: Monaco, Consolas, monospace;
	font-size: 11px;
	font-weight: 600;
	color: inherit;
	background: none;
	padding: 0;
	line-height: 1.3;
	word-break: break-all;
}

.scg-tag-item small {
	font-size: 10px;
	opacity: 0.85;
	line-height: 1.3;
	word-break: break-word;
	color: inherit;
}

/* Scrollbar styling */
.scg-tags-list::-webkit-scrollbar {
	width: 8px;
}

.scg-tags-list::-webkit-scrollbar-track {
	background: #f0f0f1;
}

.scg-tags-list::-webkit-scrollbar-thumb {
	background: #c3c4c7;
	border-radius: 4px;
}

.scg-tags-list::-webkit-scrollbar-thumb:hover {
	background: #a7aaad;
}

/* Responsive */
@media (max-width: 1400px) {
	.scg-tags-sidebar {
		width: 480px;
	}
}

@media (max-width: 1200px) {
	.scg-editor-body {
		flex-direction: column;
	}

	.scg-editors-section {
		width: 100%;
	}

	.scg-tags-sidebar {
		width: 100%;
		max-width: 100%;
		max-height: 500px;
	}

	.scg-tag-section .scg-tag-items {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 768px) {
	.scg-tag-section .scg-tag-items {
		grid-template-columns: repeat(2, 1fr);
	}

	.scg-code-editor {
		min-height: 300px;
	}
}

/* Tabs Navigation */
.scg-tabs-nav {
	display: flex;
	gap: 4px;
	border-bottom: 2px solid #c3c4c7;
	margin-bottom: 20px;
}

.scg-tab-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 20px;
	background: transparent;
	border: none;
	border-bottom: 3px solid transparent;
	font-size: 14px;
	font-weight: 500;
	color: #646970;
	cursor: pointer;
	transition: all 0.2s ease;
}

.scg-tab-btn:hover {
	color: #1d2327;
	background: #f6f7f7;
}

.scg-tab-btn.active {
	color: #2271b1;
	border-bottom-color: #2271b1;
}

.scg-tabs-content {
	position: relative;
}

.scg-tab-pane {
	display: none;
}

.scg-tab-pane.active {
	display: block;
}

/* Preview Styles */
.scg-preview-wrapper {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	overflow: hidden;
}

.scg-preview-header {
	padding: 15px 18px;
	background: #f6f7f7;
	border-bottom: 1px solid #c3c4c7;
}

.scg-preview-header h3 {
	margin: 0 0 5px 0;
	font-size: 15px;
	font-weight: 600;
}

.scg-preview-desc {
	margin: 0;
	font-size: 12px;
	color: #646970;
}

.scg-preview-area {
	padding: 30px;
	min-height: 400px;
	background: #f8f9fa;
}

.scg-preview-placeholder {
	text-align: center;
	padding: 60px 20px;
	color: #646970;
	font-size: 14px;
}

/* Bottom spacer for scrolling past fixed elements */
.shortcodeglut-bottom-spacer {
	height: 100px;
	clear: both;
}

/* Tag Search Styling */
.shortcodeglut-tag-search {
	position: relative;
	margin-bottom: 15px;
}

.shortcodeglut-search-input {
	width: 100%;
	padding: 8px 36px 8px 12px;
	font-size: 13px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	background: #fff;
	transition: border-color 0.2s;
}

.shortcodeglut-search-input:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

.shortcodeglut-search-icon {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: #646970;
	pointer-events: none;
	width: 18px;
	height: 18px;
	font-size: 16px;
}

.shortcodeglut-no-tags-message {
	text-align: center;
	padding: 20px;
	color: #646970;
	font-size: 13px;
	font-style: italic;
}

.shortcodeglut-tag-item.hidden {
	display: none !important;
}

.shortcodeglut-tag-category:has(.shortcodeglut-tag-item:not(.hidden)) {
	display: block;
}

.shortcodeglut-tag-category:not(:has(.shortcodeglut-tag-item:not(.hidden))) {
	display: none;
}
