/**
 * Rich Text Styles
 * Estilos para visualizacion y edicion de texto enriquecido con TinyMCE/DOMPurify
 * Creado: 2025-12-18
 * Actualizado: 2025-12-19 - Migracion de Quill a TinyMCE
 */

/* ========================================
   VISUALIZACION DE CONTENIDO RICH TEXT
   ======================================== */

.rich-text-container {
	word-wrap: break-word;
	overflow-wrap: break-word;
	max-width: 100%;
	line-height: 1.6;
	font-size: 14px;
	color: #333;
}

.rich-text-container p {
	margin: 0 0 10px 0;
}

.rich-text-container p:last-child {
	margin-bottom: 0;
}

.rich-text-container img {
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	margin: 8px 0;
	cursor: pointer;
}

.rich-text-container img:hover {
	opacity: 0.9;
}

.rich-text-container a {
	color: #007bff;
	text-decoration: underline;
}

.rich-text-container a:hover {
	color: #0056b3;
}

.rich-text-container table {
	border-collapse: collapse;
	width: 100%;
	margin: 10px 0;
}

.rich-text-container table td,
.rich-text-container table th {
	border: 1px solid #ddd;
	padding: 8px;
	text-align: left;
}

.rich-text-container table th {
	background-color: #f8f9fa;
	font-weight: 600;
}

.rich-text-container pre {
	background-color: #f4f4f4;
	padding: 12px;
	border-radius: 4px;
	overflow-x: auto;
	font-family: 'Courier New', Courier, monospace;
	font-size: 13px;
	margin: 10px 0;
	border: 1px solid #e0e0e0;
}

.rich-text-container code {
	background-color: #f4f4f4;
	padding: 2px 6px;
	border-radius: 3px;
	font-family: 'Courier New', Courier, monospace;
	font-size: 13px;
}

.rich-text-container pre code {
	background: none;
	padding: 0;
}

.rich-text-container blockquote {
	border-left: 4px solid #ccc;
	margin: 10px 0;
	padding: 8px 15px;
	color: #666;
	background-color: #f9f9f9;
}

.rich-text-container ul,
.rich-text-container ol {
	margin: 10px 0;
	padding-left: 30px;
}

.rich-text-container li {
	margin-bottom: 5px;
}

.rich-text-container h1,
.rich-text-container h2,
.rich-text-container h3,
.rich-text-container h4,
.rich-text-container h5,
.rich-text-container h6 {
	margin-top: 15px;
	margin-bottom: 10px;
	font-weight: 600;
	line-height: 1.3;
}

.rich-text-container h1 { font-size: 1.8em; }
.rich-text-container h2 { font-size: 1.5em; }
.rich-text-container h3 { font-size: 1.3em; }
.rich-text-container h4 { font-size: 1.1em; }
.rich-text-container h5 { font-size: 1em; }
.rich-text-container h6 { font-size: 0.9em; }

/* Clases de Quill que pueden venir del backend */
.rich-text-container .ql-align-center {
	text-align: center;
}

.rich-text-container .ql-align-right {
	text-align: right;
}

.rich-text-container .ql-align-justify {
	text-align: justify;
}

.rich-text-container .ql-indent-1 { padding-left: 3em; }
.rich-text-container .ql-indent-2 { padding-left: 6em; }
.rich-text-container .ql-indent-3 { padding-left: 9em; }

/* ========================================
   FORMULARIO DE COMENTARIO
   ======================================== */

.comentario-form-container {
	width: 100%;
}

.comentario-label {
	display: block;
	font-weight: 600;
	color: #333;
	margin-bottom: 8px;
	font-size: 14px;
}

/* ========================================
   EDITOR TINYMCE
   ======================================== */

/* Contenedor de TinyMCE */
.tox-tinymce {
	border: 1px solid #ccc !important;
	border-radius: 4px !important;
}

/* Toolbar de TinyMCE */
.tox .tox-toolbar-overlord {
	background-color: #f8f9fa !important;
}

.tox .tox-toolbar__primary {
	background-color: #f8f9fa !important;
}

/* Aviso de limite de archivos */
.editor-file-hint {
	font-size: 11px;
	color: #888;
	margin-top: 6px;
	display: flex;
	align-items: center;
	gap: 5px;
}

.editor-file-hint i {
	font-size: 12px;
}

/* Textarea base para TinyMCE */
.tinymce-editor {
	width: 100%;
	min-height: 300px;
}

/* Compatibilidad con estilos Quill legacy del backend */
.quill-editor-container {
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	margin-bottom: 10px;
}

.quill-file-hint {
	font-size: 11px;
	color: #888;
	margin-top: 6px;
	display: flex;
	align-items: center;
	gap: 5px;
}

/* ========================================
   MODAL PARA VER IMAGENES GRANDES
   ======================================== */

.rich-img-modal-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0,0,0,0.85);
	z-index: 20000;
	justify-content: center;
	align-items: center;
	cursor: zoom-out;
}

.rich-img-modal-overlay.active {
	display: flex;
}

.rich-img-modal-overlay img {
	max-width: 90%;
	max-height: 90%;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.rich-img-modal-close {
	position: fixed;
	top: 20px;
	right: 30px;
	color: #fff;
	font-size: 40px;
	font-weight: bold;
	cursor: pointer;
	z-index: 20001;
}

.rich-img-modal-close:hover {
	color: #ddd;
}

/* Modal para PDF */
.rich-img-modal-overlay iframe {
	width: 90%;
	height: 90%;
	border: none;
	border-radius: 4px;
	background: #fff;
}

/* ========================================
   PREVISUALIZACION DE ARCHIVOS ADJUNTOS
   ======================================== */

/* Contenedor de adjuntos en comentarios */
.comment-attachments {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: flex-end;
	align-items: center;
}

.attach-preview-link {
	cursor: pointer;
	transition: opacity 0.2s, transform 0.2s;
}

.attach-preview-link:hover {
	opacity: 0.9;
}

/* Thumbnails de imagenes en adjuntos */
.attach-thumb {
	max-width: 80px;
	max-height: 60px;
	border-radius: 4px;
	border: 1px solid #ddd;
	margin-right: 8px;
	vertical-align: middle;
	cursor: pointer;
	transition: transform 0.2s, box-shadow 0.2s;
}

.attach-thumb:hover {
	transform: scale(1.05);
	box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Icono de PDF clickeable */
.attach-pdf-icon {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	background: #f8f9fa;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.2s;
}

.attach-pdf-icon:hover {
	background: #e9ecef;
}

.attach-pdf-icon i {
	color: #dc3545;
	font-size: 16px;
}

/* ========================================
   INDICADOR DE CARGA DE IMAGEN
   ======================================== */

.image-uploading {
	position: relative;
	opacity: 0.6;
	pointer-events: none;
}

.image-uploading::after {
	content: 'Subiendo...';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(0,0,0,0.7);
	color: #fff;
	padding: 8px 16px;
	border-radius: 4px;
	font-size: 12px;
}

/* ========================================
   COMPATIBILIDAD CON TEXTO PLANO LEGADO
   ======================================== */

/* Los mensajes legacy usan <pre class="str_pre"> */
.str_pre.rich-text-container {
	white-space: pre-wrap;
	font-family: inherit;
	background: transparent;
	border: none;
	padding: 0;
	margin: 0;
}

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

@media (max-width: 768px) {
	.rich-text-container img {
		max-width: 100%;
	}

	/* TinyMCE responsive */
	.tox-tinymce {
		min-height: 200px !important;
	}

	.tox .tox-toolbar__primary {
		flex-wrap: wrap;
	}

	.tinymce-editor {
		min-height: 200px;
	}
}
