/* Enhanced Inline Editor Styles - Fixes visibility and editing issues */

/* Editor activation state */
.inline-editor.editor-active {
  /* Show all elements including hidden ones during editing */
  .is-hidden-element {
    opacity: 0.3;
    position: relative;
    pointer-events: auto;
  }
  
  .is-hidden-element:hover {
    opacity: 0.7;
  }
}

/* Block-level hidden state */
.block-hidden {
  opacity: 0.15;
  pointer-events: none;
}

.inline-editor.editor-active .block-hidden {
  opacity: 0.3;
  pointer-events: auto;
}

/* Editable element wrappers */
.editable-wrapper {
  position: relative;
  display: inline-block;
}

.editable-element {
  position: relative;
  display: block;
  margin: 2px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.editable-element-inline {
  position: relative;
  display: inline-block;
  margin: 1px;
  border-radius: 3px;
  transition: all 0.2s ease;
}

/* Hover states for editing */
.editable-wrapper:hover {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  background-color: rgba(59, 130, 246, 0.05);
}

.editable-wrapper:hover .visibility-toggle {
  opacity: 1;
}

/* Visibility toggle buttons */
.visibility-toggle {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #d1d5db;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editable-element .visibility-toggle {
  top: 4px;
  right: 4px;
}

.visibility-toggle:hover {
  background: #f3f4f6;
  transform: scale(1.1);
}

.visibility-toggle.is-hidden {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.visibility-toggle.is-hidden:hover {
  background: #fee2e2;
}

/* Block controls */
.block-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.editor-block:hover .block-controls {
  opacity: 1;
}

.block-control-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.block-control-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.block-control-btn.is-hidden {
  background: rgba(254, 242, 242, 0.95);
  border-color: #fca5a5;
  color: #dc2626;
}

/* Editable fields */
.editable-field {
  outline: none;
  cursor: text;
  transition: all 0.2s ease;
}

.editable-field:hover {
  background-color: rgba(59, 130, 246, 0.05);
}

.editable-field.editing {
  background-color: rgba(59, 130, 246, 0.1);
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.editable-field:focus {
  background-color: rgba(59, 130, 246, 0.1);
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Image and video editing */
.editable-image,
.editable-video {
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.editable-image:hover,
.editable-video:hover {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.editable-image::after,
.editable-video::after {
  content: 'Click para editar';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.editable-image:hover::after,
.editable-video:hover::after {
  opacity: 1;
}

/* Animation for visibility changes */
@keyframes fadeInOut {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 0.15; }
}

@keyframes fadeOutIn {
  0% { opacity: 0.15; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

.animating-hide {
  animation: fadeInOut 0.2s ease forwards;
}

.animating-show {
  animation: fadeOutIn 0.2s ease forwards;
}

/* Save indicator */
.save-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.save-indicator-saving {
  background: #fef3c7;
  color: #d97706;
}

.save-indicator-saved {
  background: #d1fae5;
  color: #065f46;
}

.save-indicator-error {
  background: #fee2e2;
  color: #dc2626;
}

.save-indicator-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .visibility-toggle {
    width: 20px;
    height: 20px;
    top: -6px;
    right: -6px;
  }
  
  .block-control-btn {
    width: 28px;
    height: 28px;
  }
}

/* Ensure proper z-index stacking */
.editor-block {
  position: relative;
}

/* Fix for inline elements */
.editable-element-inline .visibility-toggle {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
}

/* Group separators */
.group-separator {
  opacity: 0.5;
}

/* Hidden elements in editor mode */
.inline-editor:not(.editor-active) .is-hidden-element {
  display: none;
}
