/**
 * @file
 * Enhanced upload styles for CKEditor 5.
 *
 * Provides visual feedback during image upload processes.
 */

/* Upload progress indicator */
.ck-content .jda-uploading {
  position: relative;
  opacity: 0.7;
  pointer-events: none;
}

.ck-content .jda-uploading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top: 4px solid #0073aa;
  border-radius: 50%;
  animation: jda-upload-spinner 1s linear infinite;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ck-content .jda-temp-hidden {
  opacity: 0;
}

/* Editor overlay during upload */
.ck-editor__editable.jda-editor-uploading {
  position: relative;
}

.ck-editor__editable.jda-editor-uploading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 1000;
}

.ck-editor__editable.jda-editor-uploading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border: 4px solid rgba(0, 0, 0, 0.2);
  border-top: 4px solid #0073aa;
  border-radius: 50%;
  animation: jda-upload-spinner 0.9s linear infinite;
  z-index: 1001;
}

/* Ocultar de forma inmediata cualquier imagen en estado de subida */
.ck-content [data-upload-status="uploading"],
.ck-content .jda-temp-hidden {
  opacity: 0 !important;
}

.ck-content .jda-uploading::before {
  content: "Subiendo...";
  position: absolute;
  top: calc(50% + 30px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1001;
}

/* Spinner animation */
@keyframes jda-upload-spinner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Enhanced error notification styling */
.ck-notification.jda-upload-error {
  border-left: 4px solid #dc3232;
  background-color: #fff2f2;
  color: #dc3232;
}

.ck-notification.jda-upload-error .ck-notification__message {
  font-weight: 500;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .ck-content .jda-uploading::after {
    border-color: #000;
    border-top-color: #fff;
  }
  
  .ck-notification.jda-upload-error {
    border-left-color: #000;
    background-color: #fff;
    color: #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .ck-content .jda-uploading::after {
    animation: none;
  }
  
  .ck-content .jda-uploading::after {
    content: "⏳";
    border: none;
    background: none;
    font-size: 24px;
    width: auto;
    height: auto;
    margin: -12px 0 0 -12px;
  }
}

/* Focus management during upload */
.ck-content .jda-uploading:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* RTL support */
[dir="rtl"] .ck-notification.jda-upload-error {
  border-left: none;
  border-right: 4px solid #dc3232;
}

/* Drupal status messages for upload errors */
.messages.messages--error {
  border-left: 4px solid #dc3232;
  background-color: #fff2f2;
  padding: 15px 38px;
  margin: 10px 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  animation: jda-message-slide-in 0.3s ease-out;
}

.messages.messages--warning {
  border-left: 4px solid #f56500;
  background-color: #fffacd;
  padding: 15px 38px;
  margin: 10px 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  animation: jda-message-slide-in 0.3s ease-out;
}

.messages.messages--info {
  border-left: 4px solid #0073aa;
  background-color: #e6f7ff;
  padding: 15px 38px;
  margin: 10px 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  animation: jda-message-slide-in 0.3s ease-out;
}

.messages__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.messages__item {
  margin: 0;
  padding: 0;
  font-weight: 500;
  color: #333;
}

/* Close button */
.messages__close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: #666;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.messages {
  position: relative;
}

.messages--error .messages__item {
  color: #dc3232;
}

.messages--warning .messages__item {
  color: #f56500;
}

.messages--info .messages__item {
  color: #0073aa;
}

/* Message slide-in animation */
@keyframes jda-message-slide-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* High contrast mode for messages */
@media (prefers-contrast: high) {
  .messages.messages--error {
    border-left-color: #000;
    background-color: #fff;
    color: #000;
  }
  
  .messages.messages--warning {
    border-left-color: #000;
    background-color: #fff;
    color: #000;
  }
}

/* Reduced motion for messages */
@media (prefers-reduced-motion: reduce) {
  .messages.messages--error,
  .messages.messages--warning {
    animation: none;
  }
}
