/* Modern UI Styles */
:root {
	/* Color Palette */
	--primary-color: #6366f1;
	--primary-hover: #4f46e5;
	--secondary-color: #3b82f6;
	--secondary-hover: #2563eb;
	--dark-color: #111827;
	--darker-color: #030712;
	--light-color: #f9fafb;

	/* Gray Scale */
	--gray-100: #f3f4f6;
	--gray-200: #e5e7eb;
	--gray-300: #d1d5db;
	--gray-400: #9ca3af;
	--gray-500: #6b7280;
	--gray-600: #4b5563;
	--gray-700: #374151;
	--gray-800: #1f2937;
	--gray-900: #111827;

	/* Status Colors */
	--success-color: #10b981;
	--success-hover: #059669;
	--warning-color: #f59e0b;
	--warning-hover: #d97706;
	--danger-color: #ef4444;
	--danger-hover: #dc2626;

	/* Design Tokens */
	--border-radius-sm: 8px;
	--border-radius: 12px;
	--border-radius-lg: 16px;
	--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
	--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3),
		0 2px 4px -1px rgba(0, 0, 0, 0.16);
	--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3),
		0 4px 6px -2px rgba(0, 0, 0, 0.15);

	/* Transitions */
	--transition-fast: all 0.2s ease;
	--transition: all 0.3s ease;
	--transition-slow: all 0.5s ease;

	/* Typography */
	--font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
		'Helvetica Neue', Arial, sans-serif;

	/* Dark Theme (Default) */
	--bg-primary: var(--dark-color);
	--bg-secondary: var(--gray-800);
	--bg-tertiary: var(--gray-700);
	--text-primary: var(--gray-100);
	--text-secondary: var(--gray-300);
	--border-color: var(--gray-700);

	/* RGB Values for Transparency */
	--bg-primary-rgb: 17, 24, 39;
	--bg-secondary-rgb: 31, 41, 55;
	--bg-tertiary-rgb: 55, 65, 81;
}

/* Light Theme Override */
:root.light-theme {
	--bg-primary: #ffffff;
	--bg-secondary: #f8f9fa;
	--bg-tertiary: #e9ecef;
	--text-primary: #212529;
	--text-secondary: #495057;
	--border-color: #dee2e6;
	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
	--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
		0 2px 4px -1px rgba(0, 0, 0, 0.06);
	--shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1),
		0 8px 10px -6px rgba(0, 0, 0, 0.05);

	/* Light Theme RGB Values */
	--bg-primary-rgb: 255, 255, 255;
	--bg-secondary-rgb: 248, 249, 250;
	--bg-tertiary-rgb: 233, 236, 239;
}

/* Global Styles */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	font-family: var(--font-sans);
}

body {
	width: 100%;
	height: 100vh;
	overflow: hidden;
	background-color: var(--bg-primary);
	color: var(--text-primary);
	line-height: 1.5;
}

.app {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100vh;
	overflow: hidden;
}

/* ===== Header Styles ===== */
.app-header {
	display: none;
}

/* ===== Main Layout Updates ===== */
.main-container {
	display: flex;
	flex: 1;
	overflow: hidden;
	position: relative;
}

.canvas-container {
	position: relative;
	flex: 1;
	width: 100%;
	overflow: hidden;
	display: flex;
	justify-content: center;
	align-items: center;
	background-color: var(--bg-primary);
}

/* Camera Controls - Make buttons float independently */
.camera-controls {
	position: absolute;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	flex-direction: row;
	gap: 10px;
	z-index: 10;
	background-color: var(--bg-secondary);
	padding: 10px;
	border-radius: 50px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
	border: 1px solid var(--border-color);
}

.camera-controls .control-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
}

.camera-controls .control-btn i {
	font-size: 1.2rem;
}

/* Loading Overlay */
.loading-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(var(--bg-primary-rgb), 0.8);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 1000;
}

.spinner {
	width: 50px;
	height: 50px;
	border: 5px solid rgba(var(--bg-secondary-rgb), 0.3);
	border-radius: 50%;
	border-top-color: var(--primary-color);
	animation: spin 1s linear infinite;
	margin-bottom: 1rem;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.loading-overlay p {
	color: var(--text-primary);
	font-size: 1rem;
}

/* ===== Customization Panel ===== */
.customization-panel {
	width: 360px;
	height: 100%;
	background-color: var(--bg-secondary);
	box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
	border-right: 1px solid var(--border-color);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 20;
	transition: transform 0.3s ease;
	order: -1;
}

.panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem;
	background-color: var(--bg-tertiary);
	border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--text-primary);
}

.panel-close {
	display: none;
}

.panel-content {
	padding: 20px;
	overflow: auto;
	height: 100%;
	max-height: 70vh;
}

/* Customization Sections */
.customization-section {
	margin-bottom: 1.5rem;
}

.section-header {
	display: flex;
	align-items: center;
	margin-bottom: 1rem;
}

.section-header i {
	font-size: 1.25rem;
	margin-right: 0.75rem;
	color: var(--primary-color);
}

.section-header h3 {
	font-size: 1.1rem;
	font-weight: 500;
	color: var(--text-primary);
}

.section-divider {
	height: 1px;
	background-color: var(--border-color);
	margin: 1.5rem 0;
}

.section-title {
	margin-bottom: 1rem;
}

.section-title h3 {
	font-size: 1rem;
	font-weight: 500;
	margin-bottom: 0.25rem;
	color: var(--text-primary);
}

.section-title p {
	font-size: 0.875rem;
	color: var(--text-secondary);
}

/* Tab Navigation */
.tab-navigation {
	display: flex;
	border-radius: var(--border-radius);
	background-color: var(--bg-tertiary);
	margin-bottom: 1.25rem;
	overflow: hidden;
}

.tab-btn {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.75rem;
	background-color: transparent;
	border: none;
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition-fast);
}

.tab-btn i {
	font-size: 1rem;
	margin-right: 0.5rem;
}

.tab-btn span {
	font-size: 0.875rem;
	font-weight: 500;
}

.tab-btn:hover:not(.active) {
	color: var(--text-primary);
	background-color: rgba(var(--bg-tertiary-rgb), 0.5);
}

.tab-btn.active {
	background-color: var(--primary-color);
	color: white;
}

/* Tab Panels */
.tab-panel {
	display: none;
}

.tab-panel.active {
	display: block;
	animation: fadeIn 0.3s ease;
}

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

/* Color Picker */
.color-section {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.color-wheel-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
}

.color-wheel-wrapper {
	width: 180px;
	height: 180px;
	border-radius: 50%;
	overflow: hidden;
	border: 1px solid var(--border-color);
	box-shadow: var(--shadow-sm);
}

#color-wheel {
	width: 100%;
	height: 100%;
	cursor: pointer;
}

.color-info {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.25rem;
}

.color-name {
	font-size: 1rem;
	font-weight: 500;
	color: var(--text-primary);
}

.color-code {
	font-size: 0.875rem;
	color: var(--text-secondary);
	font-family: monospace;
}

.preset-colors h4 {
	font-size: 0.875rem;
	font-weight: 500;
	margin-bottom: 0.75rem;
	color: var(--text-primary);
}

.colors {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.5rem;
}

.color-btn {
	width: 100%;
	aspect-ratio: 1/1;
	border-radius: var(--border-radius-sm);
	border: 1px solid var(--border-color);
	cursor: pointer;
	transition: var(--transition-fast);
	position: relative;
	overflow: hidden;
}

.color-btn:hover {
	transform: scale(1.05);
	z-index: 1;
}

.color-btn.active {
	border: 2px solid var(--primary-color);
	box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.5);
}

/* Light border for white button to make it visible */
.color-btn[data-color="#FFFFFF"] {
	border: 1px solid #ddd;
}

.color-btn[data-color="#FFFFFF"].active {
	border: 2px solid var(--primary-color);
}

/* AI Generator */
.ai-input-container {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#ai-prompt {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

#ai-prompt:focus {
	outline: none;
	border-color: var(--primary-color);
}

.ai-preview {
	border-radius: var(--border-radius);
	background-color: var(--bg-primary);
	border: 1px solid var(--border-color);
	min-height: 200px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: visible; /* Changed from overflow:hidden to allow images to maintain their ratio */
	height: auto; /* Allow height to adapt to content */
}

.ai-preview .ai-result {
	width: 100%;
	height: auto; /* Changed from 100% to auto to adapt to image size */
	display: flex;
	align-items: center;
	justify-content: center;
}

.ai-preview .ai-result img {
	max-width: 100%;
	height: auto;
	object-fit: contain; /* Ensures the image maintains its aspect ratio */
	display: block;
}

.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	text-align: center;
}

.empty-state i {
	font-size: 2.5rem;
	color: var(--text-secondary);
	margin-bottom: 1rem;
}

.empty-state p {
	color: var(--text-secondary);
	font-size: 0.875rem;
}

/* Material Settings */
.material-settings {
	padding: 0.5rem 0;
}

.setting-group {
	margin-bottom: 1rem;
}

.setting-group:last-child {
	margin-bottom: 0;
}

.setting-group label {
	display: block;
	font-size: 0.875rem;
	margin-bottom: 0.5rem;
	color: var(--text-primary);
}

.material-select {
	width: 100%;
	padding: 0.75rem;
	border-radius: var(--border-radius);
	border: 1px solid var(--border-color);
	background-color: var(--bg-primary);
	color: var(--text-primary);
	font-size: 0.875rem;
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd' /%3E%3C/svg%3E");
	background-position: right 0.75rem center;
	background-size: 1rem;
	background-repeat: no-repeat;
	transition: var(--transition-fast);
}

.material-select:focus {
	outline: none;
	border-color: var(--primary-color);
}

/* Model Selector */
.model-selector {
	margin-bottom: 0.5rem;
}

.model-options {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1rem;
}

.model-option {
	position: relative;
	cursor: pointer;
}

.model-option input {
	position: absolute;
	opacity: 0;
	cursor: pointer;
}

.model-thumbnail {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	border-radius: var(--border-radius);
	background-color: var(--bg-primary);
	border: 1px solid var(--border-color);
	transition: var(--transition-fast);
	height: 100px;
}

.model-thumbnail i {
	font-size: 2rem;
	margin-bottom: 0.5rem;
	color: var(--text-secondary);
}

.model-thumbnail span {
	font-size: 0.875rem;
	color: var(--text-primary);
}

.model-option input:checked + .model-thumbnail {
	border-color: var(--primary-color);
	background-color: rgba(var(--primary-color), 0.1);
}

.model-option input:checked + .model-thumbnail i,
.model-option input:checked + .model-thumbnail span {
	color: var(--primary-color);
}

/* Fabric.js Editor */
.fabric-editor-container {
	margin-top: 0.75rem;
}

.fabric-canvas-wrapper {
	width: 100%;
	background-color: white;
	border-radius: var(--border-radius);
	overflow: hidden;
	margin-bottom: 1rem;
	box-shadow: var(--shadow-sm);
}

#fabric-canvas {
	width: 100%;
	height: auto;
	max-width: 100%;
	display: block;
}

.fabric-controls {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.control-group {
	display: flex;
	gap: 0.5rem;
}

.tool-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem 0.75rem;
	border-radius: var(--border-radius-sm);
	background-color: var(--bg-tertiary);
	border: none;
	color: var(--text-primary);
	cursor: pointer;
	transition: var(--transition-fast);
}

.tool-btn:hover {
	background-color: var(--primary-color);
	color: white;
}

.tool-btn i {
	font-size: 1rem;
	margin-right: 0.5rem;
}

.tool-btn span {
	font-size: 0.875rem;
}

/* Button Styles */
.action-buttons {
	display: flex;
	gap: 0.75rem;
}

.button {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.75rem 1.25rem;
	border-radius: var(--border-radius);
	border: none;
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: var(--transition-fast);
	white-space: nowrap;
}

.button i {
	margin-right: 0.5rem;
}

.button.primary {
	background-color: var(--primary-color);
	color: white;
	box-shadow: var(--shadow-sm);
}

.button.primary:hover {
	background-color: var(--primary-hover);
	box-shadow: var(--shadow-md);
}

.button.secondary {
	background-color: var(--bg-tertiary);
	color: var(--text-primary);
}

.button.secondary:hover {
	background-color: var(--gray-600);
	color: white;
}

.button:active {
	transform: scale(0.98);
}

/* Mobile Action Bar */
.mobile-action-bar {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
	padding: 0.75rem;
	background-color: var(--bg-secondary);
	box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	z-index: 100;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.5rem;
}

.action-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 0.75rem 0.5rem;
	border-radius: var(--border-radius-sm);
	background-color: transparent;
	border: none;
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition-fast);
}

.action-btn i {
	font-size: 1.25rem;
	margin-bottom: 0.25rem;
}

.action-btn span {
	font-size: 0.75rem;
}

.action-btn.active {
	color: var(--primary-color);
}

.action-btn:active {
	transform: scale(0.95);
}

/* Responsive Styles */
@media (max-width: 1200px) {
	.customization-panel {
		width: 320px;
	}
}

@media (max-width: 992px) {
	.customization-panel {
		width: 280px;
	}

	.panel-content {
		padding: 0.75rem;
	}
}

@media (max-width: 768px) {
	/* Change to mobile layout */
	.app {
		flex-direction: column;
	}
	
	.main-container {
		flex-direction: column;
	}
	
	.canvas-container {
		width: 100%;
		height: calc(100vh - 120px); /* Adjust for header and mobile action bar */
	}
	
	.floating-controls {
		left: 20px;
		top: 50%;
		transform: translateY(-50%);
		display: flex;
		flex-direction: column;
		gap: 10px;
		background-color: var(--bg-secondary);
		padding: 10px;
		border-radius: 50px;
		box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
		border: 1px solid var(--border-color);
	}
	
	.floating-panel {
		left: 50%;
		top: auto;
		bottom: 80px;
		transform: translateX(-50%);
		width: 90%;
		max-width: 320px;
		max-height: 70%;
		border-radius: var(--border-radius) var(--border-radius) 0 0;
	}

	.floating-panel.active {
		animation: panelSlideUp 0.3s ease;
	}

	@keyframes panelSlideUp {
		from {
			transform: translateY(100%);
		}
		to {
			transform: translateY(0);
		}
	}

	.camera-controls {
		top: 20px;
		bottom: auto;
		left: 50%;
		transform: translateX(-50%);
		flex-direction: row;
		gap: 10px;
		background-color: var(--bg-secondary);
		padding: 10px;
		border-radius: 50px;
		box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
		border: 1px solid var(--border-color);
	}

	.camera-controls .control-btn {
		width: 40px;
		height: 40px;
		border-radius: 50%;
	}

	.camera-controls .control-btn i {
		font-size: 1.2rem;
	}
}

@media (max-width: 480px) {
	.header-logo h1 {
		font-size: 1.25rem;
	}

	.colors {
		grid-template-columns: repeat(4, 1fr);
	}

	.panel-content {
		padding: 0.5rem;
	}

	.tool-btn span {
		display: none;
	}

	.tool-btn i {
		margin-right: 0;
	}

	.floating-controls {
		bottom: 15px;
		padding: 8px;
		gap: 8px;
	}

	.floating-controls .floating-btn,
	.floating-controls .control-btn,
	.floating-controls .model-control-btn {
		width: 35px;
		height: 35px;
	}

	.floating-controls .floating-btn i,
	.floating-controls .control-btn i,
	.floating-controls .model-control-btn i {
		font-size: 1rem;
	}

	.floating-panel {
		bottom: 70px;
		width: 95%;
		max-width: 280px;
	}

	.camera-controls {
		top: 15px;
		padding: 8px;
		gap: 8px;
	}

	.camera-controls .control-btn {
		width: 35px;
		height: 35px;
	}

	.camera-controls .control-btn i {
		font-size: 1rem;
	}
}

/* Animations */
@keyframes slideIn {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(0);
	}
}

@keyframes slideOut {
	0% {
		transform: translateX(0);
	}
	100% {
		transform: translateX(-100%);
	}
}

/* Edit mode cursor */
.edit-mode-cursor {
	cursor: crosshair !important;
}

/* Extra visible transform handles */
.transform-handle {
	background-color: white;
	border: 2px solid #2196f3;
	width: 20px;
	height: 20px;
	position: absolute;
	z-index: 100;
}

.transform-handle.rotation {
	background-color: #4caf50;
	border-radius: 50%;
}

.transform-handle.scale {
	cursor: nwse-resize;
}

.transform-handle.move {
	cursor: move;
}

/* Edit controls panel */
.edit-controls {
	position: absolute;
	bottom: 80px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	background-color: var(--bg-secondary);
	border-radius: var(--border-radius);
	padding: 8px;
	box-shadow: var(--shadow-md);
	z-index: 30;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s, visibility 0.3s;
	border: 1px solid var(--border-color);
}

.edit-controls.visible {
	opacity: 1;
	visibility: visible;
}

.edit-controls button {
	padding: 6px 10px;
	margin: 0 5px;
	border: none;
	background-color: var(--bg-tertiary);
	color: var(--text-primary);
	border-radius: var(--border-radius-sm);
	cursor: pointer;
	transition: var(--transition);
	display: flex;
	align-items: center;
	box-shadow: var(--shadow-sm);
}

.edit-controls button i {
	margin-right: 4px;
}

.edit-controls button:hover {
	background-color: var(--primary-color);
	color: white;
	transform: translateY(-2px);
	box-shadow: var(--shadow-md);
}

.edit-controls button:active {
	transform: translateY(0);
	box-shadow: var(--shadow-sm);
}

.edit-controls button.confirm {
	background-color: var(--success-color);
	color: white;
}

.edit-controls button.cancel {
	background-color: var(--danger-color);
	color: white;
}

/* Advanced Editor Controls */
.editor-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 15px;
}

.editor-controls .control-button {
	background: white;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 8px 12px;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.editor-controls .control-button:hover {
	border-color: var(--primary-color, #4a90e2);
	background-color: #f7f9ff;
}

.editor-controls .control-button.active {
	background-color: var(--primary-color, #4a90e2);
	color: white;
	border-color: var(--primary-color, #4a90e2);
}

.editor-controls .control-button i {
	font-size: 16px;
}

/* Smart Placement Indicator */
.smart-placement-indicator {
	position: absolute;
	border: 2px solid var(--primary-color, #4a90e2);
	border-radius: 4px;
	pointer-events: none;
	z-index: 100;
	animation: pulse 1.5s infinite;
}

@keyframes pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4);
	}
	70% {
		box-shadow: 0 0 0 10px rgba(74, 144, 226, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(74, 144, 226, 0);
	}
}

/* Notification styles */
.notification {
	position: fixed;
	top: 20px;
	right: 20px;
	padding: 12px 20px;
	border-radius: 8px;
	background-color: var(--gray-800);
	color: var(--light-color);
	font-size: 14px;
	font-weight: 500;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
	z-index: 1000;
	display: flex;
	align-items: center;
	gap: 10px;
	animation: slideInRight 0.4s ease, fadeIn 0.4s ease;
}

.notification.success {
	background-color: var(--success-color);
}

.notification.error {
	background-color: var(--danger-color);
}

.notification.warning {
	background-color: var(--warning-color);
}

.notification i {
	font-size: 18px;
}

.notification.fade-out {
	opacity: 0;
}

@keyframes slideInRight {
	from {
		transform: translateX(100%);
	}
	to {
		transform: translateX(0);
	}
}

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

/* Disabled button style */
.button.disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Text editor and shape editor styles for floating panels */
.text-edit-input {
	width: 100%;
	min-height: 120px;
	padding: 12px;
	margin-bottom: 16px;
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius-sm);
	font-size: 16px;
	resize: vertical;
	background-color: var(--bg-primary);
	color: var(--text-primary);
	font-family: var(--font-sans);
	transition: var(--transition);
	box-shadow: var(--shadow-sm);
}

.text-edit-input:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.text-edit-options {
	margin-bottom: 20px;
}

.text-edit-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
    padding: 8px;
    max-width: 320px;
}

.color-options-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 45px);
}

.color-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.color-option.active {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.color-picker-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #ff0000, #ff9900, #33cc33, #3399ff, #cc33ff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-picker-button i {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.color-picker-button:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.hidden-color-picker {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
}

.text-edit-buttons {
	display: flex;
	justify-content: flex-end;
	gap: 12px;
}

.text-edit-save,
.text-edit-cancel {
	padding: 10px 20px;
	border: none;
	border-radius: var(--border-radius-sm);
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	transition: var(--transition);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--shadow-sm);
}

.text-edit-save {
	background-color: var(--primary-color);
	color: white;
}

.text-edit-save:hover {
	background-color: rgba(108, 99, 255, 1);
	transform: translateY(-2px);
}

.text-edit-save:active {
	transform: translateY(0);
	box-shadow: var(--shadow-sm);
}

.text-edit-cancel {
	background-color: var(--bg-tertiary);
	color: var(--text-primary);
}

.text-edit-cancel:hover {
	background-color: rgba(255, 255, 255, 0.15);
	transform: translateY(-2px);
}

.text-edit-cancel:active {
	transform: translateY(0);
	box-shadow: var(--shadow-sm);
}

/* Shape options */
.shape-options {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
	margin-bottom: 16px;
}

.shape-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 12px;
	background-color: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius-sm);
	cursor: pointer;
	transition: var(--transition);
	position: relative;
	overflow: hidden;
}

.shape-option:hover {
	transform: translateY(-2px);
	border-color: var(--primary-color);
	box-shadow: var(--shadow-md);
}

.shape-option.active {
	background-color: var(--primary-color);
	border-color: var(--primary-color);
	color: white;
}

.shape-option i {
	font-size: 20px;
	margin-bottom: 6px;
}

.shape-option span {
	font-size: 12px;
	font-weight: 500;
}

/* Floating Controls */
.floating-controls {
	position: absolute;
	left: 20px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	gap: 10px;
	z-index: 90;
	background-color: var(--bg-secondary);
	padding: 10px;
	border-radius: 50px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
	border: 1px solid var(--border-color);
}

.floating-controls .floating-btn,
.floating-controls .control-btn,
.floating-controls .model-control-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
}

.floating-controls .floating-btn i,
.floating-controls .control-btn i,
.floating-controls .model-control-btn i {
	font-size: 1.2rem;
}

/* Remove text labels from floating buttons */
.floating-btn span,
.control-btn span,
.model-control-btn span {
	display: none;
}

/* Mobile styles for floating controls */
@media (max-width: 768px) {
	.floating-controls {
		left: 50%;
		top: auto;
		bottom: 20px;
		transform: translateX(-50%);
		flex-direction: row;
		gap: 10px;
		background-color: var(--bg-secondary);
		padding: 10px;
		border-radius: 50px;
		box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
		border: 1px solid var(--border-color);
	}

	.floating-controls .floating-btn,
	.floating-controls .control-btn,
	.floating-controls .model-control-btn {
		width: 40px;
		height: 40px;
	}

	.floating-controls .floating-btn i,
	.floating-controls .control-btn i,
	.floating-controls .model-control-btn i {
		font-size: 1.2rem;
	}
}

@media (max-width: 480px) {
	.floating-controls {
		bottom: 15px;
		padding: 8px;
		gap: 8px;
	}

	.floating-controls .floating-btn,
	.floating-controls .control-btn,
	.floating-controls .model-control-btn {
		width: 35px;
		height: 35px;
	}

	.floating-controls .floating-btn i,
	.floating-controls .control-btn i,
	.floating-controls .model-control-btn i {
		font-size: 1rem;
	}
}

/* Floating Panel */
.floating-panel {
	position: fixed;
	left: 100px;
	top: 50%;
	transform: translateY(-50%);
	width: 380px; /* Increased from 300px */
	max-height: 80vh;
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
	border: 1px solid rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	box-shadow: 0 25px 45px rgba(0, 0, 0, 0.2),
				0 0 30px rgba(0, 0, 0, 0.1),
				inset 0 0 0 1px rgba(255, 255, 255, 0.05);
	border-radius: 24px;
	z-index: 1000;
	overflow: hidden;
	display: none;
	flex-direction: column;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	pointer-events: auto;
}

.floating-panel.active {
	display: flex !important;
	opacity: 1;
	visibility: visible;
}

/* Make the panel change with theme */
:root.light-theme .floating-panel {
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.5));
	border: 1px solid rgba(255, 255, 255, 0.3);
	box-shadow: 0 25px 45px rgba(0, 0, 0, 0.05), 
				0 0 30px rgba(0, 0, 0, 0.08),
				inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

/* Ensure all floating panels have consistent styling */
#text-edit-panel,
#shape-edit-panel,
#model-panel,
#color-panel,
#photo-panel,
#text-panel,
#shape-panel,
#download-panel,
#photo-edit-panel,
.view-selection-container {
	position: fixed;
	left: 100px;
	top: 50%;
	transform: translateY(-50%);
	width: 380px; /* Increased from 300px */
	max-height: 80vh;
	border-radius: 24px;
	overflow: hidden;
	display: none;
	flex-direction: column;
	opacity: 0;
	visibility: hidden;
	z-index: 1000;
}

#text-edit-panel.active,
#shape-edit-panel.active,
#model-panel.active,
#color-panel.active,
#photo-panel.active,
#text-panel.active,
#shape-panel.active,
#download-panel.active,
#photo-edit-panel.active,
.view-selection-container.active {
	display: flex !important;
	opacity: 1;
	visibility: visible;
}

.panel-content {
	padding: 1.2rem;
	overflow-y: auto;
	pointer-events: auto;
	position: relative;
	z-index: 1;
}

.panel-header {
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
	border-bottom: 1px solid rgba(255, 255, 255, 0.07);
	padding: 1.2rem 1.5rem;
	border-radius: 24px 24px 0 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	z-index: 1001;
	pointer-events: auto;
}

/* Header theme responsiveness */
:root.light-theme .panel-header {
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.4));
	border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.panel-header h3 {
	font-size: 1.1rem;
	font-weight: 500;
	color: var(--text-primary);
	margin: 0;
}

.panel-close {
	background: rgba(255, 255, 255, 0.05);
	color: rgba(255, 255, 255, 0.7);
	border-radius: 50%;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	border: none;
	cursor: pointer;
}

.panel-close:hover {
	background-color: rgba(255, 255, 255, 0.1);
	color: rgba(255, 255, 255, 0.9);
	transform: rotate(90deg);
}

/* Mobile styles for floating panels */
@media (max-width: 768px) {
	.floating-panel,
	#text-edit-panel,
	#shape-edit-panel,
	#model-panel,
	#color-panel,
	#photo-panel,
	#text-panel,
	#shape-panel,
	#ai-panel,
	#download-panel,
	#photo-edit-panel,
	.view-selection-container {
		left: 50%;
		top: auto;
		bottom: 80px;
		transform: translateX(-50%);
		width: 95%;
		max-width: 400px; /* Increased from 320px */
		max-height: 70%;
		border-radius: 24px 24px 0 0;
	}

	.floating-panel.active,
	#text-edit-panel.active,
	#shape-edit-panel.active,
	#model-panel.active,
	#color-panel.active,
	#photo-panel.active,
	#text-panel.active,
	#shape-panel.active,
	#ai-panel.active,
	#download-panel.active,
	#photo-edit-panel.active,
	.view-selection-container.active {
		animation: panelSlideUp 0.3s ease;
	}
}

.selected-object-overlay {
	position: absolute;
	border: 2px dashed var(--primary-color);
	background-color: rgba(99, 102, 241, 0.05);
	pointer-events: none;
	z-index: 50;
}

.mode-indicator {
	position: fixed;
	top: 10px;
	left: 10px;
	background-color: var(--bg-secondary);
	color: var(--text-secondary);
	padding: 6px 12px;
	border-radius: var(--border-radius);
	box-shadow: var(--shadow-md);
	z-index: 100;
	display: none;
}

.mode-indicator.active {
	display: flex;
	align-items: center;
	gap: 8px;
}

body.dark-theme .mode-indicator {
	background-color: rgba(0, 0, 0, 0.7);
	color: #cccccc;
}

body.dark-theme .mode-indicator.active {
	color: #7bd4ff;
}

#editor-mode-toggle {
	position: fixed;
	bottom: 70px;
	right: 10px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: var(--primary-color);
	color: white;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 100;
	box-shadow: var(--shadow-lg);
	border: none;
	transition: all 0.3s ease;
}

#editor-mode-toggle:hover {
	transform: scale(1.1);
}

body.dark-theme #editor-mode-toggle {
	background-color: #0077cc;
}

body.dark-theme #editor-mode-toggle:hover {
	background-color: #0088ee;
}

/* -------------------------------------------------- */
/* Utility Classes for JS Interaction - Replacing Inline Styles */
/* -------------------------------------------------- */

/* Animation utility classes */
.animate-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.animate-element.animate-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Error message */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px;
    border-radius: 5px;
    z-index: 9999;
}

/* Theme toggle animation */
.rotating {
    transition: transform 0.3s ease, background-color 0.3s ease;
    transform: rotate(180deg);
}

/* Show/hide utility */
.hidden {
    display: none !important;
}

.standard-controls:not(.hidden) {
    display: flex;
}

.editor-controls:not(.hidden) {
    display: flex;
}

/* View Selection Panel */
.view-selection-container {
    position: fixed;
    left: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 80vh;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    display: none;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: auto;
}

.view-selection-container.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
}

.view-selection-container .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    z-index: 1001;
    pointer-events: auto;
}

.view-selection-container .panel-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.view-selection-container .panel-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-selection-container .panel-close:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.view-selection-container .panel-close i {
    font-size: 1.1rem;
}

.view-selection-container .panel-content {
    padding: 1rem;
    overflow-y: auto;
    pointer-events: auto;
}

.view-selection-container .image-preview {
    margin-bottom: 20px;
    text-align: center;
    background-color: var(--bg-primary);
    padding: 15px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-selection-container .image-preview img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    display: block;
    margin: 0 auto;
}

.view-selection-container p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.view-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.view-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.view-option:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.view-option i {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.view-option span {
    font-size: 14px;
    font-weight: 500;
}

.cancel-view-selection {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: block;
    margin: 0 auto;
}

.cancel-view-selection:hover {
    background-color: var(--gray-600);
    color: white;
}

@media (max-width: 768px) {
    .view-selection-container {
        left: 50%;
        top: auto;
        bottom: 80px;
        transform: translateX(-50%);
        width: 95%;
        max-width: 400px; /* Increased from 320px */
        max-height: 70%;
        border-radius: 24px 24px 0 0;
    }

    .view-selection-container.active {
        animation: panelSlideUp 0.3s ease;
    }

    .view-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .view-selection-container {
        bottom: 70px;
        width: 95%;
        max-width: 280px;
    }
}

/* Font Select Container - Needed by other parts of the application */
.font-select-container {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--bg-secondary);
	padding: 8px;
	border-radius: var(--border-radius);
	border: 1px solid var(--border-color);
	position: relative;
	margin-bottom: 15px;
	box-shadow: var(--shadow-sm);
}

.font-select-container label {
	font-size: 14px;
	color: var(--text-primary);
	font-weight: 500;
	min-width: 60px;
	display: flex;
	align-items: center;
}

.font-select-container label::before {
	content: 'Aa';
	margin-right: 8px;
	font-size: 16px;
	color: var(--primary-color);
}

.font-select {
	flex: 1;
	padding: 8px 12px;
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius-sm);
	font-size: 14px;
	background-color: var(--bg-primary);
	cursor: pointer;
	color: var(--text-primary);
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: right 8px center;
	background-size: 16px;
	padding-right: 32px;
	transition: var(--transition);
	box-shadow: var(--shadow-sm);
}

.font-select:hover {
	border-color: var(--primary-color);
}

.font-select:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.font-select option {
	padding: 8px;
	font-size: 14px;
	background-color: var(--bg-primary);
	color: var(--text-primary);
}

.font-select option:hover {
	background-color: var(--bg-hover);
}

/* Ensure the selected font is visible in dropdown button */
.font-select {
	font-family: inherit;
}

/* Apply the selected font to the font selector */
.font-select[value="Arial"] {
	font-family: Arial, sans-serif;
}

.font-select[value="Times New Roman"] {
	font-family: "Times New Roman", Times, serif;
}

.font-select[value="Helvetica"] {
	font-family: Helvetica, Arial, sans-serif;
}

.font-select[value="Verdana"] {
	font-family: Verdana, Geneva, sans-serif;
}

.font-select[value="Georgia"] {
	font-family: Georgia, serif;
}

.font-select[value="Courier New"] {
	font-family: "Courier New", Courier, monospace;
}

.font-select[value="Tahoma"] {
	font-family: Tahoma, Geneva, sans-serif;
}

.font-select[value="Trebuchet MS"] {
	font-family: "Trebuchet MS", sans-serif;
}

.font-select[value="Impact"] {
	font-family: Impact, Charcoal, sans-serif;
}

.font-select[value="Comic Sans MS"] {
	font-family: "Comic Sans MS", cursive, sans-serif;
}

/* Landing Page Styles */
.landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    z-index: 2000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    overflow: hidden;
}

.landing-page.fade-out {
    opacity: 0;
    visibility: hidden;
}

.landing-title {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInUp 1s ease;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
}

.landing-title span {
    color: var(--primary-color);
    position: relative;
}

.landing-title span::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-color);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.5s ease;
}

.landing-title span:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.landing-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInUp 1s ease 0.2s backwards;
    position: relative;
    z-index: 2;
}

.landing-tshirt {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: 500px;
    height: 500px;
    animation: float 6s ease-in-out infinite;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.3));
    z-index: 1;
}

.landing-tshirt canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(var(--bg-primary-rgb), 0.1), rgba(var(--bg-primary-rgb), 0.05));
    backdrop-filter: blur(10px);
}

.landing-button {
    padding: 1.2rem 3.5rem;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
    overflow: hidden;
}

.landing-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.landing-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.landing-button:hover::before {
    left: 100%;
}

.landing-button:active {
    transform: translateY(0);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

@keyframes float {
    0% {
        transform: translateY(-50%) rotate(0deg) scale(1);
        filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.3));
    }
    25% {
        transform: translateY(-50%) rotate(5deg) scale(1.05);
        filter: drop-shadow(0 25px 35px rgba(0, 0, 0, 0.4));
    }
    50% {
        transform: translateY(-50%) rotate(0deg) scale(1);
        filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.3));
    }
    75% {
        transform: translateY(-50%) rotate(-5deg) scale(0.95);
        filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.2));
    }
    100% {
        transform: translateY(-50%) rotate(0deg) scale(1);
        filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.3));
    }
}

/* Theme toggle for landing page */
.landing-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2001;
}

/* Hide main app content initially */
.app {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.app.visible {
    opacity: 1;
    visibility: visible;
}

/* Add animated background elements */
.landing-page::before,
.landing-page::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.1;
    animation: pulse 8s infinite;
    z-index: 0;
}

.landing-page::before {
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.landing-page::after {
    bottom: -100px;
    left: -100px;
    animation-delay: -4s;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.05;
    }
    100% {
        transform: scale(1);
        opacity: 0.1;
    }
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.theme-toggle:active,
.theme-toggle.active {
    transform: scale(0.95);
    box-shadow: var(--shadow-sm);
}

.theme-toggle i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.theme-toggle.rotating i {
    transform: rotate(180deg);
}

/* Restore original button styles */
.control-btn,
.model-control-btn,
.floating-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.control-btn:hover,
.model-control-btn:hover,
.floating-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.control-btn:active,
.model-control-btn:active,
.floating-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-sm);
}

.control-btn i,
.model-control-btn i,
.floating-btn i {
    font-size: 1.5rem;
    margin: 0;
}

/* Photo Edit Panel Styles */
#photo-edit-panel {
    display: none;
    position: fixed;
    left: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 80vh;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: auto;
}

#photo-edit-panel.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
}

#photo-edit-panel .preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    max-width: 300px;
    max-height: 300px;
}

#photo-edit-panel #photo-preview {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#photo-edit-panel .crop-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

#photo-edit-panel .photo-edit-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#photo-edit-panel .crop-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

#photo-edit-panel .crop-button {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

#photo-edit-panel .crop-button:hover {
    background-color: var(--primary-color);
    color: white;
}

#photo-edit-panel .adjustment-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

#photo-edit-panel .adjustment-dropdown {
    width: 100%;
    margin-bottom: 1rem;
}

#photo-edit-panel .adjustment-toggle,
#photo-edit-panel .filters-toggle {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

#photo-edit-panel .adjustment-toggle:hover,
#photo-edit-panel .filters-toggle:hover {
    background-color: var(--primary-color);
    color: white;
}

#photo-edit-panel .adjustment-toggle .toggle-icon,
#photo-edit-panel .filters-toggle .toggle-icon {
    transition: transform 0.3s ease;
}

#photo-edit-panel .adjustment-toggle.open .toggle-icon,
#photo-edit-panel .filters-toggle.open .toggle-icon {
    transform: rotate(180deg);
}

#photo-edit-panel .adjustment-content,
#photo-edit-panel .filters-content {
    display: none;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

#photo-edit-panel .adjustment-content.open,
#photo-edit-panel .filters-content.open {
    display: block;
    animation: slideDown 0.3s ease;
}

/* Filter options */
#photo-edit-panel .filter-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 0.5rem;
}

#photo-edit-panel .filter-option {
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s ease;
}

#photo-edit-panel .filter-option:hover {
    transform: scale(1.05);
}

#photo-edit-panel .filter-option.active {
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
}

#photo-edit-panel .filter-preview {
    width: 100%;
    height: 60px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: 0.3rem;
    background-image: url("../assets/sample-image.jpg");
    background-size: cover;
    background-position: center;
}

/* Filter styles */
#photo-edit-panel .filter-vintage {
    filter: sepia(50%) saturate(150%) contrast(120%);
}

#photo-edit-panel .filter-bw {
    filter: grayscale(100%) contrast(120%);
}

#photo-edit-panel .filter-hdr {
    filter: contrast(150%) saturate(140%) brightness(110%);
}

#photo-edit-panel .filter-cinematic {
    filter: contrast(130%) saturate(90%) brightness(90%) sepia(30%);
}

#photo-edit-panel .filter-retro {
    filter: sepia(60%) hue-rotate(-20deg) saturate(90%) brightness(105%);
}

#photo-edit-panel .filter-film {
    filter: contrast(110%) brightness(110%) sepia(30%) saturate(130%);
}

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

#photo-edit-panel .enhancement-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

#photo-edit-panel .enhancement-buttons button {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

#photo-edit-panel .enhancement-buttons button:hover {
    background-color: var(--primary-color);
    color: white;
}

#photo-edit-panel .photo-edit-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

#photo-edit-panel .photo-edit-buttons button {
    flex: 1;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

#photo-edit-panel .photo-edit-reset {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

#photo-edit-panel .photo-edit-reset:hover {
    background-color: var(--danger-color);
    color: white;
}

#photo-edit-panel .photo-edit-cancel {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

#photo-edit-panel .photo-edit-cancel:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

#photo-edit-panel .photo-edit-save {
    background-color: var(--primary-color);
    border: none;
    color: white;
}

#photo-edit-panel .photo-edit-save:hover {
    background-color: var(--primary-color-dark);
}

@media (max-width: 768px) {
    #photo-edit-panel {
        left: 50%;
        top: auto;
        bottom: 80px;
        transform: translateX(-50%);
        width: 90%;
        max-width: 320px;
        max-height: 70%;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }

    #photo-edit-panel.active {
        animation: panelSlideUp 0.3s ease;
    }
}

#photo-edit-panel .slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#photo-edit-panel .slider-container label {
    color: var(--text-primary);
    font-size: 0.9rem;
}

#photo-edit-panel .slider-container input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

#photo-edit-panel .slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

#photo-edit-panel .slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#photo-edit-panel .slider-container span {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: right;
}

/* Photo Crop Panel */
#photo-crop-panel {
    z-index: 1010; /* Higher than normal panels */
}

.crop-container {
    position: relative;
    margin: 0 auto;
    background-color: var(--bg-tertiary);
    overflow: hidden;
    border-radius: var(--border-radius);
}

.crop-image-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.crop-image {
    position: absolute;
    top: 0;
    left: 0;
    object-fit: contain;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.crop-box {
    position: absolute;
    border: 2px dashed white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: white;
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

.crop-handle.top-left {
    top: -7px;
    left: -7px;
    cursor: nwse-resize;
}

.crop-handle.top-right {
    top: -7px;
    right: -7px;
    cursor: nesw-resize;
}

.crop-handle.bottom-left {
    bottom: -7px;
    left: -7px;
    cursor: nesw-resize;
}

.crop-handle.bottom-right {
    bottom: -7px;
    right: -7px;
    cursor: nwse-resize;
}

.aspect-ratio-options {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
    gap: 0.5rem;
}

.aspect-ratio-btn {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    transition: var(--transition);
}

.aspect-ratio-btn:hover {
    background-color: var(--bg-secondary);
}

.aspect-ratio-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.crop-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.crop-cancel-btn, 
.crop-apply-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.crop-cancel-btn {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.crop-apply-btn {
    background-color: var(--primary-color);
    border: none;
    color: white;
}

/* Confirmation Dialog Styles */
.confirmation-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(var(--bg-primary-rgb), 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.confirmation-dialog.active {
    opacity: 1;
    visibility: visible;
}

.confirmation-content {
    width: 320px;
    max-width: 90%;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    padding: 24px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirmation-dialog.active .confirmation-content {
    transform: scale(1);
}

.confirmation-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    text-align: center;
}

.confirmation-content p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 24px 0;
    text-align: center;
}

.confirmation-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.confirmation-buttons button {
    flex: 1;
    padding: 10px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.confirmation-buttons .cancel-btn {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.confirmation-buttons .confirm-btn {
    background-color: var(--danger-color);
    color: white;
}

.confirmation-buttons .cancel-btn:hover {
    background-color: var(--border-color);
}

.confirmation-buttons .confirm-btn:hover {
    background-color: #e53935;
}

/* Saved Items Grid Styles */
.saved-items-section {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.saved-items-section h4 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.saved-items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.saved-item {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background-color: var(--bg-tertiary);
    height: 80px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.saved-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.item-thumbnail {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: rgba(var(--bg-tertiary-rgb), 0.5);
}

.item-thumbnail img {
    max-width: 100%;
    max-height: 60px;
    object-fit: contain;
}

.item-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    font-size: 0.9rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-preview i {
    font-size: 1.5rem;
}

.item-actions {
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 4px;
    display: flex;
    gap: 4px;
}

.item-actions button {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.item-actions button:hover {
    transform: scale(1.1);
}

.item-use-btn {
    background-color: var(--success-color) !important;
}

/* Make sure decal lighting toggle is visible */
.decal-lighting-toggle {
    position: absolute;
    top: 80px; /* Position below the theme toggle */
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    opacity: 1 !important;
    visibility: visible !important;
}

.decal-lighting-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.decal-lighting-toggle i {
    font-size: 1.2rem;
}

/* Active states - when lighting effects are enabled */
.decal-lighting-toggle.active {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
}

/* Light theme specific styles for the decal toggle button */
:root.light-theme .decal-lighting-toggle {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Dark theme specific styles for the decal toggle button */
:root:not(.light-theme) .decal-lighting-toggle {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Canvas container in preview mode */
.canvas-container.preview-mode {
    cursor: not-allowed;
}

/* Enhanced button lock indicators - just dim them without lock icons */
.floating-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none !important;
    position: relative;
    filter: grayscale(70%);
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
}

/* AI Button Special Styling */
#ai-generator-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    transition: all 0.3s cubic-bezier(0.2, 0.85, 0.4, 1.275);
    box-shadow: 0 5px 15px rgba(236, 72, 153, 0.3);
}

#ai-generator-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shine 4s infinite;
    z-index: 1;
}

#ai-generator-btn .sparkle-icon {
    position: relative;
    z-index: 2;
    font-size: 1.6rem;
    text-shadow: 0 0 8px rgba(255, 255, 255, 1), 0 0 15px rgba(255, 255, 255, 1);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 1)) brightness(2);
    color: white !important;
    display: inline-block;
    animation: sparkle 6s infinite;
    background: white;
    background-clip: border-box;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: #fff0;
}

#ai-generator-btn:hover {
    transform: scale(1.15) translateY(-2px) rotateZ(3deg);
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.5);
}

#ai-generator-btn:active {
    transform: scale(1.05) translateY(0);
    box-shadow: 0 4px 8px rgba(236, 72, 153, 0.4);
}

@keyframes sparkle {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    }
    25% {
        opacity: 0.8;
        transform: scale(0.9) rotate(5deg);
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.3));
    }
    50% { 
        opacity: 0.7; 
        transform: scale(0.8) rotate(-5deg);
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
    }
    75% { 
        opacity: 0.9; 
        transform: scale(1.1) rotate(3deg);
        filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.8));
    }
}

/* Ultra-Modern AI Floating Panel */
#ai-panel {
    background: linear-gradient(135deg, rgba(103, 82, 245, 0.05), rgba(236, 72, 153, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.2),
                0 0 40px rgba(103, 82, 245, 0.2),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    max-width: 420px; /* Increased from 350px */
    overflow: visible;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    position: fixed;
    left: 100px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9000;
    opacity: 0;
    visibility: hidden;
    display: none;
    max-height: 95vh; /* Limit maximum height to prevent scrolling */
    overflow: auto; /* Allow scrolling if needed */
}

#ai-panel.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    animation: ai-panel-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ai-panel-appear {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.95);
    }
    70% {
        opacity: 1;
        transform: translateY(-50%) scale(1.02);
    }
    100% {
        transform: translateY(-50%) scale(1);
    }
}

/* Make the panel change with theme */
:root.light-theme #ai-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.6));
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.05), 
                0 0 40px rgba(103, 82, 245, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

#ai-panel::before {
    content: '';
    position: absolute;
    top: -120%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at top right, 
                rgba(103, 82, 245, 0.5), 
                rgba(236, 72, 153, 0.5),
                transparent 70%);
    z-index: -1;
    opacity: 0.3;
    filter: blur(80px);
    pointer-events: none;
    animation: aurora 15s infinite alternate;
}

/* Add a second glow element */
#ai-panel::after {
    content: '';
    position: absolute;
    bottom: -50%;
    right: -20%;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle at bottom left, 
                rgba(56, 189, 248, 0.4), 
                rgba(103, 82, 245, 0.3),
                transparent 60%);
    z-index: -2;
    opacity: 0.3;
    filter: blur(60px);
    pointer-events: none;
    animation: aurora2 20s infinite alternate-reverse;
}

@keyframes aurora2 {
    0%, 100% {
        opacity: 0.2;
        transform: rotate(0deg) translate(0%, 0%) scale(1);
    }
    35% {
        opacity: 0.3;
        transform: rotate(-5deg) translate(-5%, 3%) scale(1.1);
    }
    70% {
        opacity: 0.4;
        transform: rotate(7deg) translate(3%, -2%) scale(0.8);
    }
}

@keyframes aurora {
    0%, 100% {
        opacity: 0.3;
        transform: rotate(0deg) translate(0%, 0%) scale(1);
    }
    25% {
        opacity: 0.4;
        transform: rotate(5deg) translate(2%, -3%) scale(1.1);
    }
    50% {
        opacity: 0.5;
        transform: rotate(-3deg) translate(-2%, -1%) scale(0.9);
    }
    75% {
        opacity: 0.4;
        transform: rotate(10deg) translate(1%, 5%) scale(1.05);
    }
}

/* Enhanced AI panel header */
#ai-panel .panel-header {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 1.4rem 1.5rem;
    border-radius: 30px 30px 0 0;
    text-align: center;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

:root.light-theme #ai-panel .panel-header {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.5));
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#ai-panel .panel-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: -0.01em;
    text-shadow: 0 2px 10px rgba(236, 72, 153, 0.2);
}

#ai-panel .panel-header h3::before {
    content: '✨';
    font-size: 1.8rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
    animation: sparkle 6s infinite;
    color: white !important;
}

@keyframes sparkle {
    /* Animation still defined but not used */
    0%, 100% { 
        opacity: 1; 
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    }
    25% {
        opacity: 0.8;
        transform: scale(0.9) rotate(5deg);
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.3));
    }
    50% { 
        opacity: 0.7; 
        transform: scale(0.8) rotate(-5deg);
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
    }
    75% { 
        opacity: 0.9; 
        transform: scale(1.1) rotate(3deg);
        filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.8));
    }
}

/* Special styling for AI panel close button */
#ai-panel .panel-close {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: none;
    position: absolute;
    right: 15px;
    top: 15px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#ai-panel .panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 15px rgba(103, 82, 245, 0.3);
}

/* Enhanced AI panel content */
#ai-panel .panel-content {
    padding: 1.7rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-height: calc(95vh - 60px); /* Account for header height */
    display: flex;
    flex-direction: column;
    justify-content: start;
    overflow-y: auto; /* Allow vertical scrolling if needed */
    padding: 20px;
    gap: 15px; /* Space between elements */
}

/* Ultra-modern AI preview styling */
#ai-panel .ai-preview {
    order: -1; /* Forces the preview to be the first item */
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
    min-height: 200px; /* Reduced from 250px to save space */
    max-height: 35vh; /* Limit maximum height to fit screen */
    width: 100%;
    height: auto; /* Allow height to adapt to content */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#ai-panel .ai-preview img {
    max-width: 100%;
    width: auto; /* Changed from 100% to auto to preserve aspect ratio */
    height: auto;
    object-fit: contain; /* Ensure the entire image is visible while maintaining aspect ratio */
    display: block;
    border-radius: 16px;
    margin: 0 auto;
}

#ai-panel .ai-preview .ai-result {
    width: 100%;
    height: auto; /* Changed from 100% to auto to adapt to image size */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-panel .ai-preview .ai-result img {
    max-width: 100%;
    width: auto; /* Changed from 100% to auto to preserve aspect ratio */
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 16px;
}

/* Hide the buttons inside the ai-result as they will now be shown in preview-actions instead */
#ai-panel .ai-preview .ai-buttons {
    display: none;
}

/* Default hide the preview actions, they will be shown after generation */
.ai-preview-actions {
    display: none;
    margin-top: 15px;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
}

/* Show the preview actions when needed */
.ai-preview-actions.visible {
    display: flex !important; /* Use !important to override any other display properties */
}

:root.light-theme #ai-panel .ai-preview {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(103, 82, 245, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05),
                inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

:root.light-theme #ai-panel .ai-preview:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08),
                0 0 20px rgba(103, 82, 245, 0.15),
                inset 0 0 0 1px rgba(103, 82, 245, 0.2);
}

/* Add a subtle separator between preview and input */
.ai-input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px; /* Reduced from 15px */
    position: relative;
    padding-top: 8px;
}

.ai-input-container::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(103, 82, 245, 0.3), 
        transparent);
}

/* Action buttons under preview */
.ai-preview-actions {
    margin-top: 15px;
    width: 100%;
    display: none; /* Hidden by default */
    justify-content: center; /* Center the buttons */
    gap: 10px; /* Equal spacing between buttons */
}

/* Show the preview actions when needed */
.ai-preview-actions.visible {
    display: flex !important; /* Use flex to show buttons in a row */
}

.ai-preview-actions .apply-button,
.ai-preview-actions .download-button {
    flex: 1; /* Both buttons take equal space */
    border-radius: 12px; /* Same radius for both buttons */
    padding: 12px 16px; /* Same padding for both buttons */
    font-size: 0.9rem; /* Same font size */
    height: 45px; /* Fixed height for both buttons */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-align: center;
    cursor: pointer;
}

.ai-preview-actions .apply-button {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.ai-preview-actions .apply-button:hover,
.ai-preview-actions .download-button:hover {
    transform: translateY(-2px);
}

.ai-preview-actions .apply-button:hover {
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.4);
}

.ai-preview-actions .download-button {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-preview-actions .download-button:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

:root.light-theme .ai-preview-actions .download-button {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

:root.light-theme .ai-preview-actions .download-button:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Mobile styles for AI panel */
@media (max-width: 768px) {
    #ai-panel {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        max-width: 100%;
        border-radius: 30px 30px 0 0;
        transform: translateY(100%);
        margin: 0;
    }
    
    #ai-panel.active {
        transform: translateY(0);
        animation: ai-panel-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    @keyframes ai-panel-slide-up {
        0% {
            transform: translateY(100%);
        }
        70% {
            transform: translateY(-5%);
        }
        100% {
            transform: translateY(0);
        }
    }
}

#ai-panel .section-title {
    text-align: center;
    margin-bottom: 10px; /* Reduced from 15px */
    width: 100%;
    order: -2; /* Places it above the ai-preview */
}

#ai-panel .section-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: rgba(255, 255, 255, 0.9);
}

#ai-panel .section-title p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

:root.light-theme #ai-panel .section-title h3 {
    color: rgba(0, 0, 0, 0.9);
}

:root.light-theme #ai-panel .section-title p {
    color: rgba(0, 0, 0, 0.6);
}

/* Enhance AI prompt input */
#ai-panel #ai-prompt {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px;
    color: rgba(255, 255, 255, 0.9);
    resize: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
    line-height: 1.5;
    min-height: 80px; /* Reduced from 120px to save space */
    max-height: 20vh; /* Limit maximum height */
}

#ai-panel #ai-prompt:focus {
    outline: none;
    border-color: rgba(103, 82, 245, 0.4);
    box-shadow: 0 0 0 3px rgba(103, 82, 245, 0.15), 
                inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

:root.light-theme #ai-panel #ai-prompt {
    background: rgba(255, 255, 255, 0.6);
    color: rgba(0, 0, 0, 0.8);
    border-color: rgba(103, 82, 245, 0.1);
}

/* Enhance AI generate button */
#ai-panel .button.primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    color: white;
    font-weight: 600;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 5px 15px rgba(236, 72, 153, 0.3);
}

#ai-panel .button.primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 4s infinite;
    z-index: 1;
}

#ai-panel .button.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4);
}

#ai-panel .button.primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(236, 72, 153, 0.3);
}

/* AI preview container that holds both the preview and action buttons */
.ai-preview-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px; /* Ensures consistent spacing between preview and buttons */
    margin-bottom: 15px;
}

#ai-panel .ai-preview {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    position: relative;
    min-height: 250px;
    max-height: none; /* Remove max height restriction */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px; /* Add padding to ensure image has space */
    overflow: visible; /* Changed from hidden to visible to ensure image can maintain aspect ratio */
}

/* Action buttons under preview - ensure they appear after generation */
.ai-preview-actions {
    margin-top: 15px;
    width: 100%;
    display: none; /* Hidden by default, will be shown via JavaScript when needed */
    justify-content: space-between;
    gap: 12px;
    position: relative; /* Ensure proper positioning in the container */
}

.ai-preview-actions .button {
    flex: 1;
    padding: 12px;
    font-size: 0.9rem;
    text-align: center;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.ai-preview-actions .button.primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
}

.ai-preview-actions .button.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-preview-actions .button.primary:hover {
    background: linear-gradient(135deg, #5258f0, #7c4af5);
    transform: translateY(-2px);
}

.ai-preview-actions .button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

#ai-panel .ai-preview {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    position: relative;
    min-height: 250px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px; /* Add padding to ensure image has space */
    overflow: visible; /* Changed from hidden to visible to ensure image maintains aspect ratio */
}

#ai-panel .ai-preview img {
    max-width: 100%;
    width: auto; /* Changed from 100% to auto to preserve aspect ratio */
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 16px;
}

#ai-panel .ai-preview .ai-result {
    width: 100%;
    height: auto; /* Changed from 100% to auto */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-panel #ai-generate {
    margin-top: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    border: none;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 1;
    padding: 8px 16px; /* Reduced from 0.7rem 1.2rem */
    min-height: 36px; /* To match other buttons */
    font-size: 0.95rem; /* To match other buttons */
    border-radius: 40px; /* To match other buttons */
}

#ai-panel #ai-generate .sparkle-icon {
    margin-left: 8px;
    color: white !important;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
    animation: sparkle 6s infinite;
    background: white;
    background-clip: border-box;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: #fff0;
    font-size: 1.4rem;
}

#ai-panel #ai-generate:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(103, 82, 245, 0.3);
}

@keyframes shine {
    0% {
        left: -100%;
    }
    20% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes sparkle {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    }
    25% {
        opacity: 0.8;
        transform: scale(0.9) rotate(5deg);
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.3));
    }
    50% { 
        opacity: 0.7; 
        transform: scale(0.8) rotate(-5deg);
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
    }
    75% { 
        opacity: 0.9; 
        transform: scale(1.1) rotate(3deg);
        filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.8));
    }
}

.sparkle-icon {
    color: white !important;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5) !important;
}

/* Specific overrides for AI button sparkle */
#ai-generator-btn .sparkle-icon {
    position: relative;
    z-index: 2;
    font-size: 1.6rem;
    text-shadow: 0 0 8px rgba(255, 255, 255, 1), 0 0 15px rgba(255, 255, 255, 1);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 1)) brightness(2);
    color: white !important;
    display: inline-block;
    animation: sparkle 6s infinite;
    background: white;
    background-clip: border-box;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: #fff0;
}

/* Specific override for AI panel sparkle */
#ai-panel .panel-header h3::before {
    content: '✨';
    font-size: 1.8rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
    animation: sparkle 6s infinite;
    color: white !important;
}

/* Action buttons under preview - ensure they appear after generation */
.ai-preview-actions {
    margin: 15px 0;
    width: 100%;
    display: flex; /* Make visible by default */
    justify-content: space-between;
    gap: 12px;
    position: relative; /* Ensure proper positioning in the container */
}

#ai-panel {
    max-height: 95vh;
    height: auto; /* Allow panel to shrink to fit content */
    overflow: visible;
    scrollbar-width: none; /* Hide scrollbar by default for Firefox */
}

#ai-panel::-webkit-scrollbar {
    display: none; /* Hide scrollbar by default for Chrome/Safari/Edge */
}

#ai-panel .panel-content {
    max-height: calc(95vh - 60px);
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: center;
    overflow-y: visible; /* Changed from auto to visible */
    overflow-x: hidden;
    scrollbar-width: none;
    padding: 20px;
    gap: 12px;
}

#ai-panel .panel-content::-webkit-scrollbar {
    display: none;
}

/* Make placeholder text smaller */
#ai-panel #ai-prompt::placeholder {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

:root.light-theme #ai-panel #ai-prompt::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

/* Improve button styling to match UI */
.ai-preview-actions .apply-button,
.ai-preview-actions .download-button {
    flex: 1;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.9rem;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.ai-preview-actions .apply-button {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-preview-actions .download-button {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Perfect alignment for the entire panel */
.ai-preview-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 0 auto;
}

#ai-panel .section-title {
    text-align: center;
    margin-bottom: 10px;
    width: 100%;
    padding: 0 10px;
}

.ai-input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-top: 5px;
}

/* Fix display issue with .ai-preview-actions */
.ai-preview-actions {
    margin-top: 10px;
    width: 100%;
    display: none;
    justify-content: center;
    gap: 10px;
    padding: 0 5px;
}

.ai-preview-actions.visible {
    display: flex !important;
}

/* Reduce minimum height of preview area */
#ai-panel .ai-preview {
    min-height: 150px; /* Reduced from 180px */
    max-height: 30vh; /* Slightly smaller */
}

/* Reduce minimum height of input textarea */
#ai-panel #ai-prompt {
    min-height: 60px; /* Reduced from 80px */
    max-height: 15vh;
}

#ai-panel .ai-preview {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    position: relative;
    min-height: 150px;
    max-height: 30vh;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden !important; /* Force hidden to prevent image from overflowing */
}

#ai-panel .ai-preview img {
    max-width: 100%;
    max-height: 28vh !important; /* Slightly less than container to ensure it fits */
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 16px;
}

#ai-panel .ai-preview .ai-result {
    width: 100%;
    max-height: 28vh !important;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden !important; /* Ensure image stays within container */
}

#ai-panel .ai-preview .ai-result img {
    max-width: 100%;
    max-height: 28vh !important;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 16px;
}

#ai-panel .ai-preview {
    width: 100%;
    aspect-ratio: 16/9; /* Maintain consistent aspect ratio */
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    position: relative;
    min-height: 0; /* Remove min-height to respect aspect ratio */
    max-height: none; /* Let aspect ratio control the height */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden !important; /* Force hidden to prevent image from overflowing */
}

#ai-panel .ai-preview img,
#ai-panel .ai-preview .ai-result img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 12px;
}

#ai-panel .ai-preview .ai-result {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden !important;
}

/* Make apply and download buttons match generate button */
.ai-preview-actions .apply-button,
.ai-preview-actions .download-button {
    flex: 1;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    height: 48px; /* Match generate button height */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.01em;
}

.ai-preview-actions .apply-button {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-preview-actions .download-button {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px; /* Match apply button */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Style the button icons consistently */
.ai-preview-actions .apply-button i,
.ai-preview-actions .download-button i {
    margin-right: 8px;
    font-size: 1.1rem;
}

/* Update loading indicator to match new UI */
#ai-panel .ai-preview .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

#ai-panel .ai-preview .empty-state i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 0 15px rgba(103, 82, 245, 0.6);
    animation: pulse 2s infinite ease-in-out;
}

#ai-panel .ai-preview .empty-state p {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    max-width: 80%;
    line-height: 1.4;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.7;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.1);
        text-shadow: 0 0 20px rgba(103, 82, 245, 0.8);
    }
}

#ai-panel .ai-preview {
    width: 100%;
    aspect-ratio: 1/1; /* Changed to 1:1 aspect ratio */
    max-width: 1024px; /* Set maximum width to 1024px */
    height: auto; /* Height will be controlled by aspect ratio */
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    position: relative;
    min-height: 0; /* Remove min-height to respect aspect ratio */
    max-height: none; /* Let aspect ratio control the height */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden !important; /* Force hidden to prevent image from overflowing */
    margin: 0 auto; /* Center the container */
}

/* Make apply and download buttons match generate button */
.ai-preview-actions .apply-button,
.ai-preview-actions .download-button {
    flex: 1;
    border-radius: 50px; /* Match generate button border-radius */
    padding: 12px 24px; /* Match generate button padding */
    font-size: 1.1rem; /* Match generate button font size */
    font-weight: 600; /* Match generate button font weight */
    height: auto; /* Auto height to match content */
    min-height: 48px; /* Minimum height to match generate button */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); /* Match generate button transition */
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.01em;
}

.ai-preview-actions .apply-button {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.ai-preview-actions .download-button {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px; /* Match apply button and generate button */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Style the button icons consistently */
.ai-preview-actions .apply-button i,
.ai-preview-actions .download-button i {
    margin-right: 8px;
    font-size: 1.1rem; /* Match generate button icon size */
}

/* Hover effects to match generate button */
.ai-preview-actions .apply-button:hover,
.ai-preview-actions .download-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.ai-preview-actions .apply-button:active,
.ai-preview-actions .download-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* Update loading indicator to match new UI */
#ai-panel .ai-preview .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    width: 100%;
    height: 100%;
}

#ai-panel .ai-preview .empty-state i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 0 20px rgba(103, 82, 245, 0.8);
    animation: pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#ai-panel .ai-preview .empty-state p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    max-width: 80%;
    line-height: 1.5;
    font-weight: 500;
}

/* Update loading animation to match AI panel */
#ai-panel .ai-preview .loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    width: 100%;
    height: 100%;
}

#ai-panel .ai-preview .loading i {
    font-size: 2.5rem !important; /* Reduced from 3.5rem to match empty state */
    margin-bottom: 15px !important; /* Reduced from 20px to match empty state */
    color: rgba(255, 255, 255, 0.95);
    animation: spin-pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(103, 82, 245, 0.7));
}

#ai-panel .ai-preview .loading p {
    font-size: 0.9rem !important; /* Reduced from 1.2rem to match empty state */
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@keyframes spin-pulse {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: rotate(180deg) scale(1.2);
        opacity: 1;
        filter: drop-shadow(0 0 20px rgba(103, 82, 245, 0.8));
    }
    100% {
        transform: rotate(360deg) scale(1);
        opacity: 0.8;
    }
}

/* Match photo container to AI preview size */
.preview-container, 
#photo-preview,
#ai-panel .ai-preview {
    width: 100%;
    max-width: 1024px;
    aspect-ratio: 1/1; /* 1:1 square aspect ratio */
    height: auto;
    margin: 0 auto;
    border-radius: 16px;
    overflow: auto !important;
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Unified styling for images in both containers */
#photo-preview,
#ai-panel .ai-preview img,
#ai-panel .ai-preview .ai-result img {
    width: 100%;
    height: 100%;
    max-width: 1024px;
    max-height: 1024px;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

/* Ensure the AI result container has correct dimensions */
#ai-panel .ai-preview .ai-result {
    width: 100%;
    height: 100%;
    max-width: 1024px;
    max-height: 1024px;
}

/* Make sure the loading and empty states still display properly */
#ai-panel .ai-preview .empty-state,
#ai-panel .ai-preview .loading {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Make apply and download buttons match generate button but smaller */
.ai-preview-actions .apply-button,
.ai-preview-actions .download-button {
    flex: 1;
    border-radius: 40px; /* Slightly reduced from 50px */
    padding: 8px 16px; /* Reduced from 12px 24px */
    font-size: 0.95rem; /* Reduced from 1.1rem */
    font-weight: 600; 
    height: auto;
    min-height: 36px; /* Reduced from 48px */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.01em;
}

/* Make the AI generate button smaller to match */
#ai-panel #ai-generate {
    margin-top: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    border: none;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 1;
    padding: 8px 16px; /* Reduced from 0.7rem 1.2rem */
    min-height: 36px; /* To match other buttons */
    font-size: 0.95rem; /* To match other buttons */
    border-radius: 40px; /* To match other buttons */
}

/* Make AI prompt input bigger */
#ai-panel #ai-prompt {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px;
    color: rgba(255, 255, 255, 0.9);
    resize: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    font-size: 1rem; /* Increased from 0.95rem */
    line-height: 1.5;
    min-height: 90px; /* Increased from 80px */
    max-height: 25vh; /* Increased from 20vh */
    width: 100%;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
#ai-panel #ai-prompt::-webkit-scrollbar {
    display: none;
}

/* Ensure AI preview shows full image */
#ai-panel .ai-preview {
    width: 100%;
    aspect-ratio: 1/1; /* Maintain square aspect ratio */
    max-width: 1024px;
    height: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    position: relative;
    min-height: 0; /* Remove min-height to respect aspect ratio */
    max-height: none; /* Let aspect ratio control the height */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px; /* Reduced padding to maximize image space */
    overflow: hidden !important; /* Force hidden to prevent image from overflowing */
    margin: 0 auto; /* Center the container */
}

/* When section-title is hidden, allow the preview to be taller */
#ai-panel .section-title[style*="display: none"] ~ .ai-preview-container .ai-preview {
    max-height: calc(50vh - 100px); /* Larger max-height when section-title is hidden */
    aspect-ratio: auto; /* Allow natural aspect ratio */
    transition: max-height 0.3s ease;
}

/* Ensure image fits perfectly within the preview */
#ai-panel .ai-preview img,
#ai-panel .ai-preview .ai-result img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 12px;
}

/* When section-title is hidden, make the image larger */
#ai-panel .section-title[style*="display: none"] ~ .ai-preview-container .ai-preview img,
#ai-panel .section-title[style*="display: none"] ~ .ai-preview-container .ai-preview .ai-result img {
    max-height: calc(50vh - 100px);
}

#ai-panel .ai-preview {
    width: 100%;
    max-width: none; /* Remove max-width to allow flexible sizing */
    aspect-ratio: auto; /* Allow natural aspect ratio instead of forcing 1:1 */
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    position: relative;
    min-height: 0; /* Remove min-height constraint */
    max-height: 80vh; /* Maximize height while keeping some space for UI */
    height: auto;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Remove padding to maximize image space */
    overflow: hidden !important; 
    margin: 0 auto; /* Center the container */
}

#ai-panel .ai-preview img,
#ai-panel .ai-preview .ai-result img {
    max-width: 100%;
    max-height: 80vh; /* Match container max-height */
    width: auto; /* Allow natural width */
    height: auto; /* Allow natural height */
    object-fit: contain;
    display: block;
    border-radius: 12px;
}

#ai-panel .ai-preview .ai-result {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible !important; /* Allow image to determine the size */
}

/* When section-title is hidden, make the image even larger */
#ai-panel .section-title[style*="display: none"] ~ .ai-preview-container .ai-preview {
    max-height: 90vh; /* Even larger when section title is hidden */
    transition: max-height 0.3s ease;
}

/* When section-title is hidden, make the image larger */
#ai-panel .section-title[style*="display: none"] ~ .ai-preview-container .ai-preview img,
#ai-panel .section-title[style*="display: none"] ~ .ai-preview-container .ai-preview .ai-result img {
    max-height: 90vh; /* Match the larger container height */
}

/* Ensure the AI preview container adapts to the image size after generation */
.ai-preview-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

/* Make sure the ai-result container adapts to the image dimensions */
#ai-panel .ai-preview .ai-result:has(img) {
    width: auto;
    height: auto;
}

.ai-preview-actions .button.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(40%);
    transform: none !important;
    box-shadow: none !important;
}

/* Enhanced empty state appearance for better UI */
#ai-panel .ai-preview .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
}

#ai-panel .ai-preview .empty-state i {
    font-size: 3.5rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 0 20px rgba(103, 82, 245, 0.8);
    animation: pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-preview-container {
    width: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    min-height: 200px; /* Reduced minimum height */
}

#ai-panel .ai-preview {
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    position: relative;
    min-height: 300px; /* Increased from 200px for bigger display */
    max-height: 90vh; /* Maximum height when showing generated image */
    height: auto;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden !important;
    margin: 0 auto;
}

/* Smaller size for empty state and generating state */
#ai-panel .ai-preview:has(.empty-state),
#ai-panel .ai-preview:has(.loading) {
    min-height: 250px; /* Increased from 200px */
    max-height: 300px; /* Increased from 250px */
}

/* Normal size for result state */
#ai-panel .ai-preview:has(.ai-result img) {
    min-height: unset !important;
    height: auto !important;
    max-height: none !important;
    width: auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#ai-panel .ai-preview .ai-result {
    width: auto !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 auto !important;
}

#ai-panel .ai-preview .ai-result img {
    max-width: 230px !important;
    min-width: 230px !important;
    width: 230px !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
    border-radius: 8px !important;
    transform: none !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35) !important;
}

/* Make empty state match loading state */
#ai-panel .ai-preview .empty-state {
    padding: 20px;
    min-height: 250px;
    width: 100%;
    height: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    position: absolute !important;
    inset: 0 !important;
    z-index: 10;
    border: none;
    text-align: center;
}

#ai-panel .ai-preview .empty-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(103, 82, 245, 0.1), rgba(236, 72, 153, 0.1));
    border-radius: 16px;
    z-index: -1;
    animation: pulse-loading 2s infinite; /* Match loading animation timing */
}

#ai-panel .ai-preview .empty-state i {
    font-size: 2.5rem !important; /* Keep consistent size */
    margin-bottom: 15px !important; /* Keep consistent margin */
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 20px rgba(103, 82, 245, 0.8);
    animation: pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(103, 82, 245, 0.7));
}

#ai-panel .ai-preview .empty-state p {
    font-size: 0.9rem !important; /* Keep consistent size */
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    line-height: 1.5;
}

/* Make robot icon animation smoother */
#ai-panel .ai-preview .empty-state i {
    font-size: 3.5rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.95);
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(103, 82, 245, 0.7));
    animation: robot-float 4s ease-in-out infinite;
}

@keyframes robot-float {
    0% {
        transform: translateY(0) rotate(0deg);
        filter: drop-shadow(0 0 10px rgba(103, 82, 245, 0.6));
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
        filter: drop-shadow(0 0 20px rgba(103, 82, 245, 0.8));
    }
    100% {
        transform: translateY(0) rotate(0deg);
        filter: drop-shadow(0 0 10px rgba(103, 82, 245, 0.6));
    }
}

#ai-panel .ai-preview .empty-state p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Enhanced empty state appearance */
#ai-panel .ai-preview .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
}

#ai-panel .ai-preview .empty-state i {
    font-size: 2.5rem; /* Smaller icon for empty state */
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 0 20px rgba(103, 82, 245, 0.8);
    animation: pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#ai-panel .ai-preview .empty-state p {
    font-size: 0.9rem; /* Smaller text for empty state */
    color: rgba(255, 255, 255, 0.8);
    max-width: 90%;
    line-height: 1.4;
}

/* Loading state should also be smaller */
#ai-panel .ai-preview .loading {
    padding: 15px;
    max-height: 250px; /* Increased for better visibility */
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#ai-panel .ai-preview .loading i {
    font-size: 3.5rem; /* Match robot icon size */
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.95);
    animation: spin-pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(103, 82, 245, 0.7));
}

#ai-panel .ai-preview .loading p {
    font-size: 1.2rem; /* Match robot text size */
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Fix container sizing to accommodate larger images */
.ai-preview-container {
    width: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    min-height: 250px; /* Increased from 200px */
}

#ai-panel .ai-preview .loading {
    padding: 15px;
    max-height: 250px; /* Increased from 200px */
    width: 100%;
    height: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 16px;
}

#ai-panel .ai-preview .loading i {
    font-size: 3rem; /* Increased from 2.5rem */
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.9);
    animation: spin-pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#ai-panel .ai-preview .loading p {
    font-size: 1rem; /* Increased from 0.9rem */
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    max-width: 90%;
}

#ai-panel .ai-preview .loading {
    padding: 20px;
    min-height: 250px;
    width: 100%;
    height: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    position: relative;
    z-index: 10;
    text-align: center;
}

#ai-panel .ai-preview .loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(103, 82, 245, 0.1), rgba(236, 72, 153, 0.1));
    border-radius: 16px;
    z-index: -1;
    animation: pulse-loading 2s infinite;
}

@keyframes pulse-loading {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

#ai-panel .ai-preview .loading i {
    font-size: 3.5rem; /* Larger icon */
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.95);
    animation: spin-pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(103, 82, 245, 0.7));
}

#ai-panel .ai-preview .loading p {
    font-size: 1.2rem; /* Larger text */
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#ai-panel .ai-preview .loading i {
    /* Styling handled by more specific rule below */
    font-size: 3.5rem;
    margin-bottom: 20px;
}

#ai-panel .ai-preview .loading p {
    /* Styling handled by more specific rule below */
    font-size: 1.2rem;
    margin-bottom: 0;
}

#ai-panel .ai-preview .loading i {
    font-size: 3.5rem !important; /* Force consistent size */
    margin-bottom: 20px !important;
    color: rgba(255, 255, 255, 0.95);
    animation: spin-pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#ai-panel .ai-preview .loading p {
    font-size: 1.2rem !important; /* Force consistent size */
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
}

#ai-panel .ai-preview .empty-state i {
    font-size: 2.5rem !important; /* Keep consistent size */
    margin-bottom: 15px !important; /* Keep consistent margin */
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 0 20px rgba(103, 82, 245, 0.8);
    animation: pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#ai-panel .ai-preview .empty-state p {
    font-size: 0.9rem !important; /* Keep consistent size */
    color: rgba(255, 255, 255, 0.8);
    max-width: 90%;
    line-height: 1.4;
}

#ai-panel .ai-preview .loading i {
    font-size: 2.5rem !important; /* Match empty state icon size */
    margin-bottom: 15px !important; /* Match empty state margin */
    color: rgba(255, 255, 255, 0.95);
    animation: spin-pulse 2s infinite ease-in-out;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(103, 82, 245, 0.7));
}

#ai-panel .ai-preview .loading p {
    font-size: 0.9rem !important; /* Match empty state text size */
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Force AI generated image to be exactly 230px */
#ai-panel .panel-content .ai-preview-container .ai-preview .ai-result img {
    max-width: 230px !important;
    min-width: 230px !important;
    width: 230px !important;
    height: 230px !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
    border-radius: 8px !important;
    transform: none !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35) !important;
}

#ai-panel .ai-preview .empty-state {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    position: absolute !important;
    inset: 0 !important;
    z-index: 10;
}

/* Fix empty state positioning to fill container */
#ai-panel .panel-content .ai-preview-container .ai-preview .ai-result .empty-state {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(0, 0, 0, 0.15) !important;
    border-radius: 16px !important;
    z-index: 10 !important;
    text-align: center !important;
    padding: 15px !important;
}

/* Fix loading state positioning to fill container */
#ai-panel .panel-content .ai-preview-container .ai-preview .ai-result .loading {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(0, 0, 0, 0.15) !important;
    border-radius: 16px !important;
    z-index: 10 !important;
    text-align: center !important;
    padding: 15px !important;
}

#ai-panel .ai-preview .ai-result {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#ai-panel .ai-preview .empty-state {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
}

#ai-panel .ai-preview .empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    z-index: 10;
}

#ai-panel .ai-preview .empty-state {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 15px !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    border-radius: 16px !important;
    z-index: 10 !important;
}

#ai-panel .ai-preview .empty-state {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 15px !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.15) !important;
    border-radius: 16px !important;
    z-index: 10 !important;
    position: relative !important;
}

#ai-panel .ai-preview .empty-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(103, 82, 245, 0.1), rgba(236, 72, 153, 0.1));
    border-radius: 16px;
    z-index: -1;
    animation: pulse-loading 2s infinite;
}

/* Advanced Upload Panel Styling */
#photo-panel .upload-methods {
    display: flex;
    flex-direction: column;
    width: 100%;
}

#photo-panel .method-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

#photo-panel .method-tab {
    flex: 1;
    padding: 0.75rem 0.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#photo-panel .method-tab i {
    font-size: 1rem;
}

#photo-panel .method-tab.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

#photo-panel .upload-tab {
    display: none;
    width: 100%;
}

#photo-panel .upload-tab.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

#photo-panel .drag-area {
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-secondary);
}

#photo-panel .drag-area.active {
    border-color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.05);
}

#photo-panel .drag-area .icon {
    font-size: 3rem;
    color: var(--primary-color);
}

#photo-panel .upload-button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

#photo-panel .upload-button:hover {
    background-color: var(--primary-color-dark);
    transform: translateY(-2px);
}

#photo-panel .upload-info {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* URL Tab Styles */
#photo-panel .url-input-container {
    display: flex;
    margin-bottom: 1rem;
}

#photo-panel .url-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

#photo-panel .url-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

#photo-panel .fetch-button {
    padding: 0.75rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

#photo-panel .fetch-button:hover {
    background-color: var(--primary-color-dark);
}

#photo-panel .url-preview {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    min-height: 200px;
}

#photo-panel .preview-placeholder {
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

#photo-panel .preview-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

#photo-panel .preview-image-container {
    position: relative;
}

#photo-panel #url-preview-image {
    width: 100%;
    display: block;
}

#photo-panel .use-image-button {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}

#photo-panel .use-image-button:hover {
    background-color: var(--primary-color-dark);
    transform: translateY(-2px);
}

/* Camera Tab Styles */
#photo-panel .camera-container {
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: #000;
    position: relative;
}

#photo-panel #camera-feed-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
}

#photo-panel #camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#photo-panel .camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#photo-panel .camera-guide {
    width: 80%;
    height: 80%;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}

#photo-panel .camera-controls {
    display: flex;
    padding: 1rem;
    background-color: #000;
    justify-content: space-around;
}

#photo-panel .camera-control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#photo-panel .camera-control-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

#photo-panel .capture-btn {
    width: 60px;
    height: 60px;
    background-color: white;
    color: #000;
    border: 4px solid rgba(255, 255, 255, 0.3);
}

#photo-panel .capture-btn:hover {
    background-color: #f1f1f1;
    transform: scale(1.05);
}

#photo-panel #camera-preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background-color: #000;
}

#photo-panel #camera-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#photo-panel .camera-preview-controls {
    display: flex;
    padding: 1rem;
    background-color: #000;
    justify-content: space-between;
}

#photo-panel .preview-control-btn {
    padding: 0.75rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#photo-panel .preview-control-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

#photo-panel .use-btn {
    background-color: var(--primary-color);
}

#photo-panel .use-btn:hover {
    background-color: var(--primary-color-dark);
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    #photo-panel {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    
    #photo-panel .camera-control-btn {
        width: 40px;
        height: 40px;
    }
    
    #photo-panel .capture-btn {
        width: 50px;
        height: 50px;
    }
}

#text-panel {
    position: fixed;
    left: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 380px;
    max-width: 95%;
    height: auto;
    max-height: 90vh;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.2),
            0 0 30px rgba(0, 0, 0, 0.1),
            inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    z-index: 1000;
    overflow: hidden;
    display: none;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#text-panel.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
}

#text-panel .panel-content {
    padding: 15px;
    overflow: visible;
    max-height: none;
    display: flex;
    flex-direction: column;
}

#text-panel h2 {
    margin: 0 0 5px 0;
    font-size: 18px;
}

#text-panel p {
    margin: 0 0 10px 0;
    font-size: 14px;
    opacity: 0.8;
}

#text-panel .text-edit-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 5px;
}

#text-panel .text-edit-input {
    padding: 10px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 15px;
    width: 100%;
    min-height: 50px;
    max-height: 70px;
    border: none;
    transition: background-color 0.2s ease;
    resize: none;
}

.font-select-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.font-select-container label {
    font-size: 14px;
    font-weight: 500;
    color: #a2a8d3;
    min-width: 40px;
}

.font-select {
    border-radius: 8px;
    padding: 8px 10px;
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: none;
    width: 100%;
    appearance: none;
    cursor: pointer;
    font-size: 14px;
}

#text-panel .text-edit-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
}

.text-edit-save, 
.text-edit-cancel {
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

@media (max-width: 768px) {
    #text-panel {
        left: 50%;
        top: auto;
        bottom: 80px;
        transform: translateX(-50%);
        width: 95%;
        max-width: 400px;
        max-height: 75%;
        border-radius: 24px 24px 0 0;
    }
    
    #text-panel .panel-content {
        padding: 15px 15px 25px 15px;
    }
}

#text-panel .shadow-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    color: #a2a8d3;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: flex-start;
    font-size: 14px;
}

#text-panel .shadow-button:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

#text-panel .shadow-button i {
    font-size: 14px;
    color: #6d78c7;
}

/* Color selection area */
#text-panel .text-edit-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

#text-panel .color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    position: relative;
}

#text-panel .color-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

#text-panel .color-option.active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

#text-panel .color-picker-container {
    display: flex;
    align-items: center;
    position: relative;
}

#text-panel .custom-color {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ff5b99, #ff5f57, #ffbd2e, #38d9a9, #30c5ff, #6c5ce7);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#text-panel .custom-color i {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

#text-panel .custom-color:hover {
    transform: scale(1.1);
}

#text-panel .hidden-color-picker {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}

.text-edit-save {
    background-color: rgba(108, 99, 255, 0.9);
    color: #fff;
    flex-grow: 2;
    width: 65%;
}

.text-edit-save:hover {
    background-color: rgba(108, 99, 255, 1);
    transform: translateY(-2px);
}

.text-edit-cancel {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    flex-grow: 1;
    width: 30%;
}

.text-edit-cancel:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

#color-panel .panel-content {
    overflow: hidden;
    max-height: none;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#color-panel .color-wheel-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 5px;
}

#color-panel .color-wheel-wrapper {
    width: 180px;
    height: 180px;
    margin: 0 auto 10px;
}

#color-panel .color-info {
    text-align: center;
    margin-bottom: 5px;
}

#color-panel .preset-colors {
    margin-top: 0;
}

#color-panel .preset-colors h4 {
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
}

#color-panel .colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

#color-panel .color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background-color: transparent;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

#color-panel .color-btn:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

#color-panel .color-btn.active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Adjust for white color button */
#color-panel .color-btn[data-color="#FFFFFF"] {
    border: 2px solid rgba(0, 0, 0, 0.2);
}

#color-panel .color-btn[data-color="#FFFFFF"].active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Toggle Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border-radius: 20px;
    transition: .4s;
}

.slider-thumb {
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background-color: var(--primary-color);
}

.switch input:checked + .slider .slider-thumb {
    transform: translateX(20px);
}

/* Focus styles for accessibility */
.switch input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

/* Hover effect */
.slider:hover {
    background-color: rgba(108, 99, 255, 0.2);
}

/* Shadow modal and controls */
#shadow-selection-modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background-color: var(--bg-primary);
    z-index: 9999;
    display: none;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
}

#shadow-selection-modal.active {
    display: block;
}

#shadow-selection-modal > div {
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    padding: 20px;
    overflow-y: auto;
}

/* Light Theme for Shadow Modal */
:root.light-theme #shadow-selection-modal {
    background-color: #ffffff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

:root.light-theme #shadow-selection-modal > div {
    background-color: #ffffff;
}

#shadow-custom-controls {
    display: none;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
}

#shadow-custom-controls.active {
    display: block;
}

.shadow-previews {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.shadow-preview {
    text-align: center;
    padding: 15px 10px;
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.shadow-preview.active {
    border-color: var(--primary-color);
}

.shadow-preview[data-shadow-type="custom"].active + #shadow-custom-controls {
    display: block;
}

/* Shadow Effects Button */
.shadow-effects-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
    padding: 10px 15px;
    width: auto;
    max-width: 160px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, var(--primary-color), rgba(var(--primary-color-rgb), 0.8));
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.3);
    position: relative;
    overflow: hidden;
}

.shadow-effects-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.shadow-effects-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.4);
}

.shadow-effects-btn:hover::before {
    left: 100%;
}

.shadow-effects-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(var(--primary-color-rgb), 0.3);
}

.shadow-effects-btn i {
    font-size: 16px;
}

/* End Shadow Effects Button */

.shadow-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.shadow-modal.active {
    display: flex;
}

.shadow-modal-content {
    background-color: var(--bg-primary);
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.shadow-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.shadow-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.shadow-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 100px);
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-tertiary);
}

.shadow-modal-body::-webkit-scrollbar {
    width: 8px;
}

.shadow-modal-body::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.shadow-modal-body::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 4px;
    border: 2px solid var(--bg-tertiary);
}

#close-shadow-modal {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

#close-shadow-modal:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

#close-shadow-modal:active {
    transform: rotate(90deg) scale(0.9);
}

.shadow-color-main {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 12px 15px;
    margin-bottom: 10px;
}

.shadow-color-main label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--bg-tertiary);
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #000000;
    border: 2px solid var(--bg-tertiary);
    position: absolute;
    left: 0;
    pointer-events: none;
}

#color-value {
    font-family: monospace;
    font-size: 14px;
    color: var(--text-secondary);
}

.shadow-preview-text {
    text-align: center;
    padding: 25px 20px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    font-size: 28px;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 2;
    margin-bottom: 5px;
}

.shadow-previews {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.shadow-preview {
    text-align: center;
    padding: 15px 10px;
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.shadow-preview:hover {
    background-color: var(--bg-tertiary);
}

.shadow-preview.active {
    border-color: var(--primary-color);
    background-color: var(--bg-tertiary);
}

.shadow-custom-controls {
    display: none;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px;
}

.shadow-custom-controls.active {
    display: block;
}

.shadow-control-group {
    margin-bottom: 15px;
}

.shadow-control-group:last-child {
    margin-bottom: 0;
}

.shadow-control-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
}

.shadow-control-group input[type="range"] {
    width: 100%;
    margin: 5px 0;
    cursor: grab;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.shadow-control-group input[type="range"]:active {
    cursor: grabbing;
}

.shadow-control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.shadow-control-group input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
    width: 18px;
    height: 18px;
}

.shadow-control-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: none;
}

.shadow-control-group input[type="range"]:active::-moz-range-thumb {
    cursor: grabbing;
    width: 18px;
    height: 18px;
}

.shadow-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.shadow-modal-actions button {
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.shadow-modal-actions .cancel-button {
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.shadow-modal-actions .apply-button {
    border: none;
    background-color: var(--primary-color);
    color: white;
}

.shadow-modal-actions button:hover {
    opacity: 0.9;
}

.shadow-modal-actions button:active {
    transform: scale(0.98);
}

/* Light Theme for Text Panel */
:root.light-theme #text-panel {
    background-color: #ffffff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

:root.light-theme #text-panel .panel-header {
    background-color: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
}

:root.light-theme #text-panel .panel-header h3 {
    color: #333333;
}

:root.light-theme #text-panel .panel-close {
    color: #555555;
}

:root.light-theme #text-panel .panel-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

:root.light-theme #text-panel .text-edit-input {
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    color: #333333;
}

:root.light-theme #text-panel .text-edit-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

:root.light-theme #text-panel .font-select {
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    color: #333333;
}

:root.light-theme #text-panel .font-select:focus {
    border-color: var(--primary-color);
}

:root.light-theme #text-panel .text-edit-buttons .text-edit-save,
:root.light-theme #text-panel .text-edit-buttons .text-edit-cancel {
    background-color: #f8f8f8;
    border: 1px solid #d0d0d0;
    color: #333333;
}

:root.light-theme #text-panel .text-edit-buttons .text-edit-save:hover,
:root.light-theme #text-panel .text-edit-buttons .text-edit-cancel:hover {
    background-color: #e8e8e8;
}

:root.light-theme #text-panel .text-edit-buttons .text-edit-save {
    background-color: var(--primary-color);
    color: white;
    border: none;
}

:root.light-theme #text-panel .shadow-effects-btn {
    background: linear-gradient(to right, #f2f2f2, #f8f8f8);
    color: #333333;
    border: 1px solid #d0d0d0;
}

:root.light-theme #text-panel .shadow-effects-btn:hover {
    background: linear-gradient(to right, #e8e8e8, #f2f2f2);
}

/* Light Theme for Text Panel Color Options */
:root.light-theme #text-panel .text-edit-colors {
    background-color: #f8f8f8;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

:root.light-theme #text-panel .color-option {
    border: 2px solid #e8e8e8;
}

:root.light-theme #text-panel .color-option:hover {
    border-color: #c0c0c0;
}

:root.light-theme #text-panel .color-option.active {
    border-color: var(--primary-color);
}

:root.light-theme #text-panel .color-picker-container {
    background-color: #f0f0f0;
}

:root.light-theme #text-panel .custom-color {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Light Theme for Shadow Modal */
:root.light-theme .shadow-modal-content {
    background-color: #ffffff;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12);
}

:root.light-theme .shadow-modal-header {
    border-bottom: 1px solid #e0e0e0;
}

:root.light-theme .shadow-modal-header h3 {
    color: #333333;
}

:root.light-theme #close-shadow-modal {
    color: #555555;
}

:root.light-theme #close-shadow-modal:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

:root.light-theme .shadow-preview-text {
    background-color: #f0f0f0;
    color: #333333;
}

:root.light-theme .shadow-preview {
    background-color: #f5f5f5;
    border: 2px solid transparent;
}

:root.light-theme .shadow-preview:hover {
    background-color: #e8e8e8;
}

:root.light-theme .shadow-preview.active {
    border-color: var(--primary-color);
    background-color: #e8e8e8;
}

:root.light-theme .shadow-custom-controls {
    background-color: #f5f5f5;
}

:root.light-theme .shadow-control-group label {
    color: #333333;
}

:root.light-theme .shadow-control-group input[type="range"] {
    background: #e0e0e0;
}

:root.light-theme .shadow-control-group input[type="range"]::-webkit-slider-thumb {
    background: var(--primary-color);
}

:root.light-theme .shadow-modal-actions .cancel-button {
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    color: #333333;
}

:root.light-theme .shadow-modal-actions .apply-button {
    background-color: var(--primary-color);
}

:root.light-theme .shadow-color-main {
    background-color: #f5f5f5;
}

:root.light-theme .shadow-color-main label {
    color: #333333;
}

:root.light-theme #color-value {
    color: #555555;
}

/* Simplified color selector for text panel */
.simplified-color-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
}

.color-preview-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    background-color: #ffffff;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-preview-circle:hover {
    transform: scale(1.1);
}

.color-picker-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-picker-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.color-picker-btn i {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
}

/* Modern Color Picker Styles */
.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.color-option.active {
    transform: scale(1.15);
    box-shadow: 0 0 0 2px var(--primary-color), 0 6px 16px rgba(0, 0, 0, 0.2);
}

.color-picker-container {
    position: relative;
}

.color-option.custom-color-option {
    border-radius: 12px;
    background: linear-gradient(135deg, #f5515f, #9f041b 30%, #f48e21 50%, #7fc400 70%, #0096ff 90%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.color-option.custom-color-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shine 2s infinite;
}

.selected-color-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 2;
    transition: background-color 0.3s ease;
}

.text-edit-colors {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

/* Animation keyframes */
@keyframes shine {
    0% {
        left: -100%;
    }
    20% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(93, 157, 245, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(93, 157, 245, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(93, 157, 245, 0);
    }
}

.color-option.active {
    animation: pulse 1.5s infinite;
}

/* Hidden color picker styling */
.hidden-color-picker {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}