/* =============================================================================
   ESTILOS PARA INTEGRACIÓN DE CHAT CON APIS
   Archivo: /css/chat-integration.css
   ============================================================================= */

/* =============================================================================
   ESTILOS BASE DEL CHAT (mantener compatibilidad con tu código actual)
   ============================================================================= */

.chat-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.85);
	z-index: 9999;
	overflow-y: auto;
}

.chat-box {
	display: flex;
	flex-direction: row;
	width: 95%;
	max-width: 1024px;
	margin: 30px auto;
	background: #1a1a1a;
	border-radius: 10px;
	overflow: hidden;
	color: #fff;
	height: 90vh;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.chat-sidebar {
	width: 260px;
	background: #111;
	padding: 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	border-right: 1px solid #333;
}

.chat-sidebar img {
	width: 100px;
	height: 100px;
	border-radius: 50%;
	object-fit: cover;
	border: 3px solid #FC768A;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.chat-sidebar h3 {
	margin: 0;
	font-size: 1.2rem;
	text-align: center;
	color: #FC768A;
}

.chat-sidebar .btn {
	background: #FC768A;
	color: white;
	border: none;
	padding: 8px 12px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	text-align: left;
	width: 100%;
	transition: all 0.3s ease;
	display: flex;
	align-items: center;
	gap: 8px;
}

.chat-sidebar .btn:hover {
	background: #E65073;
	transform: translateY(-1px);
}

.chat-sidebar .btn.comprar {
	background: linear-gradient(45deg, #4CAF50, #45a049);
}

.chat-sidebar .btn.comprar:hover {
	background: linear-gradient(45deg, #45a049, #4CAF50);
}

.chat-sidebar .btn .label {
	display: none;
}

@media (min-width: 769px) {
	.chat-sidebar .btn .label {
		display: inline;
		font-size: 12px;
	}
}

.chat-main {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.chat-header {
	background: #E65073;
	padding: 15px 20px;
	font-weight: bold;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid #333;
}

.chat-header h2 {
	margin: 0;
	font-size: 1.3rem;
}

.chat-header .btn.cerrar {
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: white;
	padding: 8px 12px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 16px;
}

.chat-content {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #1a1a1a;
	scrollbar-width: thin;
	scrollbar-color: #FC768A #333;
}

.chat-content::-webkit-scrollbar {
	width: 8px;
}

.chat-content::-webkit-scrollbar-track {
	background: #333;
}

.chat-content::-webkit-scrollbar-thumb {
	background: #FC768A;
	border-radius: 4px;
}

.chat-input {
	display: flex;
	padding: 15px 20px;
	background: #222;
	border-top: 1px solid #333;
	gap: 10px;
}

.chat-input input {
	flex: 1;
	padding: 12px 16px;
	border: 1px solid #444;
	border-radius: 25px;
	background: #333;
	color: white;
	font-size: 14px;
	outline: none;
	transition: border-color 0.3s ease;
}

.chat-input input:focus {
	border-color: #FC768A;
}

.chat-input button {
	background: #FC768A;
	color: #fff;
	border: none;
	padding: 12px 16px;
	border-radius: 25px;
	cursor: pointer;
	font-size: 16px;
	transition: all 0.3s ease;
	min-width: 50px;
}

.chat-input button:hover {
	background: #E65073;
	transform: scale(1.05);
}

.chat-input button:disabled {
	background: #666;
	cursor: not-allowed;
	transform: none;
}

/* =============================================================================
   ESTILOS DE MENSAJES
   ============================================================================= */

.message {
	position: relative;
	padding: 12px 16px;
	background: #2a2a2a;
	border-radius: 15px;
	max-width: 75%;
	word-wrap: break-word;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
	animation: messageSlide 0.3s ease-out;
}

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

.message.user {
	align-self: flex-end;
	background: linear-gradient(135deg, #FC768A, #E65073);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.message.ai {
	align-self: flex-start;
	background: linear-gradient(135deg, #667eea, #764ba2);
	color: #fff;
	border-bottom-left-radius: 5px;
}

.message-content {
	line-height: 1.4;
	margin-bottom: 5px;
}

.timestamp {
	font-size: 11px;
	opacity: 0.7;
	text-align: right;
	margin-top: 5px;
}

.message.user .timestamp {
	text-align: left;
}

.delete-msg {
	position: absolute;
	top: 5px;
	right: 8px;
	display: none;
	cursor: pointer;
	font-size: 12px;
	opacity: 0.7;
	transition: opacity 0.3s ease;
}

.message:hover .delete-msg {
	display: block;
}

.delete-msg:hover {
	opacity: 1;
}

/* =============================================================================
   INDICADORES DE ESTADO
   ============================================================================= */

.typing-indicator {
	opacity: 0.8;
	background: linear-gradient(135deg, #667eea, #764ba2);
}

.typing-animation {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 5px 0;
}

.typing-animation span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
	animation: typing 1.4s infinite ease-in-out;
}

.typing-animation span:nth-child(1) { animation-delay: -0.32s; }
.typing-animation span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
	0%, 80%, 100% { 
		transform: scale(0.8);
		opacity: 0.5;
	}
	40% { 
		transform: scale(1);
		opacity: 1;
	}
}

/* =============================================================================
   TOKENS DISPLAY
   ============================================================================= */

.tokens-display {
	background: linear-gradient(135deg, #333, #444);
	padding: 12px;
	margin: 10px 0;
	border-radius: 10px;
	text-align: center;
	border: 1px solid #555;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tokens-display i {
	color: #FFD700;
	margin-right: 5px;
}

#userTokens {
	font-weight: bold;
	font-size: 1.1rem;
	color: #4CAF50;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* =============================================================================
   GENERACIÓN DE MEDIA
   ============================================================================= */

.image-generation-loading {
	text-align: center;
	padding: 25px;
	background: linear-gradient(135deg, #667eea, #764ba2);
	border-radius: 15px;
	color: white;
}

.loading-spinner {
	font-size: 2.5rem;
	margin-bottom: 15px;
	color: #FFD700;
}

.loading-bar {
	width: 200px;
	height: 6px;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 3px;
	overflow: hidden;
	margin: 15px auto;
}

.loading-progress {
	width: 0%;
	height: 100%;
	background: linear-gradient(90deg, #FFD700, #FF6B9D);
	animation: loadingProgress 3s ease-in-out infinite;
}

@keyframes loadingProgress {
	0% { width: 0%; }
	50% { width: 70%; }
	100% { width: 100%; }
}

.generated-image img {
	transition: transform 0.3s ease;
	border-radius: 10px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.generated-image img:hover {
	transform: scale(1.02);
}

.audio-player {
	background: linear-gradient(135deg, #667eea, #764ba2);
	padding: 15px;
	border-radius: 15px;
	color: white;
	text-align: center;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.audio-player audio {
	width: 100%;
	margin-bottom: 10px;
	border-radius: 5px;
}

.audio-text {
	font-style: italic;
	margin-top: 5px;
	opacity: 0.9;
	font-size: 14px;
}

/* =============================================================================
   MODAL DE PAQUETES DE TOKENS
   ============================================================================= */

.modal-content {
	background: white;
	color: #333;
	padding: 30px;
	border-radius: 15px;
	max-width: 500px;
	margin: 50px auto;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
	animation: modalSlide 0.3s ease-out;
}

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

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
	padding-bottom: 15px;
	border-bottom: 2px solid #f0f0f0;
}

.modal-header h3 {
	margin: 0;
	color: #764ba2;
	font-size: 1.5rem;
}

.modal-header button {
	background: none;
	border: none;
	font-size: 28px;
	cursor: pointer;
	color: #999;
	transition: color 0.3s ease;
}

.modal-header button:hover {
	color: #333;
}

.token-packages {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 15px;
	margin-bottom: 20px;
}

.package-card {
	padding: 20px 15px;
	border-radius: 12px;
	text-align: center;
	cursor: pointer;
	transition: all 0.3s ease;
	color: #000;
	font-weight: bold;
	border: none;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.package-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.package-card:active {
	transform: translateY(-1px);
}

/* =============================================================================
   LIGHTBOX PARA IMÁGENES
   ============================================================================= */

#lightbox {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.9);
	z-index: 99999;
	justify-content: center;
	align-items: center;
}

#lightbox img {
	max-width: 90%;
	max-height: 90%;
	border-radius: 12px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#lightbox button {
	position: absolute;
	top: 20px;
	right: 20px;
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: white;
	font-size: 24px;
	padding: 10px 15px;
	border-radius: 50%;
	cursor: pointer;
	transition: background 0.3s ease;
}

#lightbox button:hover {
	background: rgba(255, 255, 255, 0.3);
}

/* =============================================================================
   INDICADORES DE ESTADO DE API
   ============================================================================= */

.api-status {
	position: fixed;
	top: 10px;
	right: 10px;
	padding: 8px 12px;
	border-radius: 6px;
	font-size: 12px;
	z-index: 1000;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.api-status.online {
	background: #4CAF50;
	color: white;
}

.api-status.offline {
	background: #f44336;
	color: white;
}

.api-status::before {
	content: "●";
	margin-right: 5px;
	animation: pulse 2s infinite;
}

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

/* =============================================================================
   HELP SECTION
   ============================================================================= */

#chatHelp {
	padding: 15px 20px;
	background: #333;
	color: #fff;
	font-size: 14px;
	line-height: 1.6;
	border-bottom: 1px solid #444;
}

#chatHelp strong {
	color: #FFD700;
}

#chatHelp em {
	color: #FF6B9D;
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
	.chat-box {
		flex-direction: column;
		height: 100vh;
		width: 100vw;
		border-radius: 0;
		margin: 0;
	}
	
	.chat-sidebar {
		flex-direction: row;
		width: 100%;
		justify-content: space-around;
		padding: 10px;
		height: auto;
		border-right: none;
		border-bottom: 1px solid #333;
	}
	
	.chat-sidebar img {
		width: 60px;
		height: 60px;
	}
	
	.chat-sidebar h3 {
		font-size: 1rem;
	}
	
	.chat-sidebar .btn {
		padding: 6px 8px;
		font-size: 12px;
		min-width: 40px;
	}
	
	.chat-sidebar .btn .label {
		display: none;
	}
	
	.chat-content {
		padding: 15px;
	}
	
	.message {
		max-width: 90%;
		font-size: 14px;
	}
	
	.tokens-display {
		padding: 8px;
		font-size: 12px;
	}
	
	.token-packages {
		grid-template-columns: repeat(2, 1fr);
	}
	
	.package-card {
		padding: 15px 10px;
		font-size: 14px;
	}
}

@media (max-width: 480px) {
	.chat-input {
		padding: 10px;
	}
	
	.chat-input input {
		font-size: 14px;
		padding: 10px 14px;
	}
	
	.chat-input button {
		padding: 10px 12px;
		font-size: 14px;
	}
	
	.modal-content {
		margin: 20px;
		padding: 20px;
	}
	
	.token-packages {
		grid-template-columns: 1fr;
	}
	
	#lightbox img {
		max-width: 95%;
		max-height: 95%;
	}
}

/* =============================================================================
   ANIMACIONES Y EFECTOS ESPECIALES
   ============================================================================= */

.tokens-display {
	animation: tokenGlow 3s ease-in-out infinite alternate;
}

@keyframes tokenGlow {
	0% {
		box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
	}
	100% {
		box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 10px rgba(255, 215, 0, 0.3);
	}
}

.message.ai {
	animation: messageSlide 0.3s ease-out, aiGlow 0.5s ease-out 0.3s;
}

@keyframes aiGlow {
	0% {
		box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
	}
	50% {
		box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), 0 0 15px rgba(102, 126, 234, 0.4);
	}
	100% {
		box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
	}
}

/* =============================================================================
   MODO OSCURO MEJORADO
   ============================================================================= */

body.dark-mode .chat-modal {
	background: rgba(0, 0, 0, 0.95);
}

body.dark-mode .modal-content {
	background: #2a2a2a;
	color: #fff;
}

body.dark-mode .modal-header {
	border-bottom-color: #444;
}

body.dark-mode .modal-header h3 {
	color: #FC768A;
}

/* =============================================================================
   ESTILOS PARA CONTENIDO ESPECÍFICO
   ============================================================================= */

.message img {
	max-width: 100%;
	border-radius: 8px;
	margin: 5px 0;
	cursor: pointer;
	transition: transform 0.3s ease;
}

.message img:hover {
	transform: scale(1.02);
}

.message video {
	max-width: 100%;
	border-radius: 8px;
	margin: 5px 0;
}

.message a {
	color: #FFD700;
	text-decoration: none;
	transition: color 0.3s ease;
}

.message a:hover {
	color: #FF6B9D;
	text-decoration: underline;
}

/* =============================================================================
   UTILIDADES
   ============================================================================= */

.text-gradient {
	background: linear-gradient(135deg, #667eea, #764ba2);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.loading {
	opacity: 0.7;
	pointer-events: none;
}

.hidden {
	display: none !important;
}

.fade-in {
	animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
	animation: slideUp 0.3s ease-out;
}

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