/* Variáveis do Tema (Dark & Gold) */
:root {
	--ai-bg-color: #0f172a;
	--ai-surface: rgba(30, 41, 59, 0.7);
	--ai-border: rgba(255, 255, 255, 0.1);
	--ai-text-primary: #f8fafc;
	--ai-text-secondary: #94a3b8;
	--ai-accent: #fbbf24;
	--ai-accent-hover: #f59e0b;
	--ai-radius: 16px;
	--ai-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Container Principal (App Full Screen) */
.ai-saas-wrapper {
	font-family: var(--ai-font);
	background: var(--ai-bg-color);
	color: var(--ai-text-primary);
	
	/* Full Screen Override */
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh; /* Fallback */
	height: 100dvh;
	z-index: 9999999;
	overflow-y: auto;
	padding: 24px;
	padding-bottom: 80px; /* Espaço extra para navegadores mobile */
	box-sizing: border-box;
}

/* Container interno para limitar largura no desktop */
.ai-saas-inner {
	max-width: 600px;
	margin: 0 auto;
	width: 100%;
}

@media (max-width: 640px) {
	.ai-saas-wrapper {
		padding: 16px;
		padding-bottom: 90px;
	}
}

.ai-saas-wrapper * {
	box-sizing: border-box;
}

/* Abas de Navegação */
.ai-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 24px;
	background: rgba(15, 23, 42, 0.8);
	padding: 6px;
	border-radius: 12px;
	border: 1px solid var(--ai-border);
}

.ai-tab-btn {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--ai-text-secondary);
	padding: 10px;
	font-size: 14px;
	font-weight: 500;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.3s ease;
}

.ai-tab-btn.active {
	background: var(--ai-surface);
	color: var(--ai-text-primary);
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Glassmorphism Panels */
.ai-panel {
	background: var(--ai-surface);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid var(--ai-border);
	border-radius: var(--ai-radius);
	padding: 24px;
	display: none;
	animation: aiFadeIn 0.4s ease forwards;
}

.ai-panel.active {
	display: block;
}

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

/* Upload Zone */
.ai-upload-zone {
	display: block;
	border: 2px dashed var(--ai-border);
	border-radius: 12px;
	padding: 30px 20px;
	text-align: center;
	cursor: pointer;
	transition: border-color 0.3s ease, background-color 0.3s ease;
	margin-bottom: 20px;
	background: rgba(255, 255, 255, 0.02);
}

.ai-upload-zone:hover {
	border-color: var(--ai-accent);
	background: rgba(251, 191, 36, 0.05);
}

.ai-upload-icon {
	font-size: 32px;
	margin-bottom: 10px;
}

.ai-upload-zone p {
	margin: 0;
	color: var(--ai-text-secondary);
	font-size: 15px;
	font-weight: 500;
}

.ai-file-input {
	display: none;
}

.ai-preview-thumb {
	cursor: pointer;
	transition: transform 0.2s, opacity 0.2s;
}

.ai-preview-thumb:hover {
	transform: scale(1.05);
	opacity: 0.8;
}

/* Grids de Opções (Estilo e Proporção) */
.ai-styles-grid, .ai-aspect-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.ai-style-option, .ai-aspect-option {
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid var(--ai-border);
	border-radius: 8px;
	padding: 8px 14px;
	font-size: 13px;
	cursor: pointer;
	transition: all 0.2s;
	color: var(--ai-text-secondary);
}

.ai-style-option:hover, .ai-aspect-option:hover {
	background: rgba(255, 255, 255, 0.1);
	color: var(--ai-text-primary);
}

.ai-style-option.active, .ai-aspect-option.active {
	background: rgba(251, 191, 36, 0.15);
	border-color: var(--ai-accent);
	color: var(--ai-accent);
	font-weight: 600;
}

/* Seletor de Famosos (Grid com Avatares) */
.ai-famosos-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.ai-famoso-card {
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid var(--ai-border);
	border-radius: 12px;
	padding: 12px;
	text-align: center;
	cursor: pointer;
	transition: all 0.3s ease;
}

.ai-famoso-card:hover {
	background: rgba(255, 255, 255, 0.1);
}

.ai-famoso-card.selected {
	border-color: var(--ai-accent);
	background: rgba(251, 191, 36, 0.1);
}

.ai-famoso-avatar {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	object-fit: cover;
	margin-bottom: 8px;
	border: 2px solid transparent;
}

.ai-famoso-card.selected .ai-famoso-avatar {
	border-color: var(--ai-accent);
}

.ai-famoso-name {
	font-size: 13px;
	font-weight: 500;
	margin: 0;
}

.ai-btn-primary {
	display: block;
	width: 100%;
	background: linear-gradient(135deg, var(--ai-accent), var(--ai-accent-hover));
	color: #000;
	border: none;
	padding: 14px 24px;
	font-size: 16px;
	font-weight: 700;
	border-radius: 12px;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	text-align: center;
}

.ai-btn-primary:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 15px -3px rgba(251, 191, 36, 0.4);
}

.ai-btn-primary:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	animation: none;
}

.ai-pulse:not(:disabled) {
	animation: aiPulseAnim 2s infinite;
}

@keyframes aiPulseAnim {
	0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
	70% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); }
	100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* Tela de Loading IA */
.ai-loading-state {
	text-align: center;
	padding: 40px 0;
}

.ai-spinner {
	width: 50px;
	height: 50px;
	border: 4px solid var(--ai-border);
	border-top-color: var(--ai-accent);
	border-radius: 50%;
	animation: aiSpin 1s linear infinite;
	margin: 0 auto 20px auto;
}

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

/* Tela de Preview & Pix */
.ai-previews-multi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 12px;
	margin-bottom: 24px;
}

@media (max-width: 480px) {
	.ai-previews-multi-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

.ai-previews-single-grid {
	display: flex;
	justify-content: center;
	align-items: center;
	margin-bottom: 24px;
}

.ai-previews-single-grid .ai-preview-img {
	max-width: 300px;
	height: auto;
	max-height: 450px;
}

.ai-preview-img {
	width: 100%;
	height: 200px;
	object-fit: cover;
	border-radius: 12px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
	background: rgba(0,0,0,0.3);
	transition: transform 0.3s;
}

.ai-preview-img:hover {
	transform: scale(1.02);
}

.ai-no-save {
	pointer-events: none;
	user-select: none;
	-webkit-user-drag: none;
}

.ai-preview-locked {
	position: relative;
	width: 100%;
	height: 200px;
	background: rgba(0, 0, 0, 0.4);
	border: 1px dashed var(--ai-border);
	border-radius: 12px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: var(--ai-text-secondary);
	font-size: 12px;
	text-align: center;
	padding: 10px;
}

.ai-preview-locked::before {
	content: '🔒';
	font-size: 24px;
	margin-bottom: 8px;
}

/* Modais (Auth e Alerts) */
.ai-modal-overlay {
	position: fixed;
	top: 0; left: 0; width: 100%; height: 100%;
	background: rgba(0,0,0,0.8);
	backdrop-filter: blur(5px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
}

.ai-modal-content {
	background: rgba(15, 23, 42, 0.95);
	border: 1px solid rgba(255, 255, 255, 0.1);
	padding: 40px;
	border-radius: 20px;
	width: 90%;
	max-width: 420px;
	text-align: center;
	box-shadow: 0 25px 50px -12px rgba(0,0,0,0.7);
	color: var(--ai-text);
}

.ai-modal-content h3 {
	font-size: 24px;
	font-weight: 600;
}

.ai-auth-tabs {
	display: flex;
	margin-bottom: 20px;
	border-bottom: 1px solid var(--ai-border);
}

.ai-auth-tab {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--ai-text-secondary);
	padding: 10px;
	cursor: pointer;
}

.ai-auth-tab.active {
	color: var(--ai-accent);
	border-bottom: 2px solid var(--ai-accent);
}

.ai-auth-input {
	width: 100%;
	padding: 12px;
	margin-bottom: 15px;
	background: rgba(0,0,0,0.3);
	border: 1px solid var(--ai-border);
	border-radius: 8px;
	color: var(--ai-text);
	box-sizing: border-box;
}

.ai-auth-input:focus {
	border-color: var(--ai-accent);
	outline: none;
}

.ai-pix-area {
	text-align: center;
	background: rgba(0, 0, 0, 0.2);
	padding: 20px;
	border-radius: 12px;
	border: 1px solid var(--ai-border);
}

.ai-qrcode {
	width: 200px;
	height: 200px;
	margin: 0 auto 16px auto;
	background: #fff;
	padding: 10px;
	border-radius: 8px;
}

.ai-copia-cola {
	width: 100%;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid var(--ai-border);
	color: var(--ai-text-primary);
	padding: 10px;
	border-radius: 6px;
	font-size: 12px;
	margin-bottom: 12px;
	word-break: break-all;
	resize: none;
}
