/* Estilos principais do editor WYSIWYG baseado no Mises Portal */

/*
  Sticky Toolbar:
  A toolbar do editor agora acompanha o scroll da página, permanecendo sempre visível.
  
  Para ajustar a posição quando há uma navbar fixa, modifique a variável CSS:
  --wysiwyg-toolbar-sticky-top: 60px; (onde 60px é a altura da sua navbar)
*/

:root {
  --wysiwyg-toolbar-sticky-top: 0px; /* Ajuste esta variável se houver navbar fixa */
}

/* Container principal */
.wysiwyg-editor {
  border: 1px solid #d4d7e5;
  border-radius: 0.375rem;
  overflow: hidden;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  margin-bottom: 1rem;
  position: relative;
}

.wysiwyg-editor:focus-within {
  outline: 0;
  border-color: rgba(99, 102, 241, 0.35) !important;
  box-shadow: 0 0.5rem 1.125rem -0.5rem rgba(99, 102, 241, 0.2);
}

/* Toolbar */
.editor-toolbar {
  background-color: #f8f9fa;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #d4d7e5;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Toolbar quando fixada no topo */
.editor-toolbar.sticky {
  position: fixed;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-bottom-color: rgba(212, 215, 229, 0.8);
  backdrop-filter: blur(12px);
  background-color: rgba(248, 249, 250, 0.95);
  border-radius: 0.5rem;
  border: 1px solid rgba(212, 215, 229, 0.8);
  transform: translateY(0);
  animation: slideDown 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

/* Spacer para manter o layout quando toolbar fica sticky */
.toolbar-spacer {
  width: 100%;
  background-color: transparent;
}

/* Custom scrollbar for webkit browsers */
.editor-toolbar::-webkit-scrollbar {
  height: 6px;
}

.editor-toolbar::-webkit-scrollbar-track {
  background: transparent;
}

.editor-toolbar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.editor-toolbar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Ensure buttons don't shrink */
.editor-toolbar .btn,
.editor-toolbar .btn-group {
  flex-shrink: 0;
}

.btn.btn-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Editor content */
.tiptap.ProseMirror {
  padding: 3rem 3rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  min-height: 300px;
  outline: none;
  font-size: 1rem;
  line-height: 1.6;
  color: #333;
}

.tiptap.ProseMirror p {
  margin-bottom: 1rem;
}

.tiptap.ProseMirror h1,
.tiptap.ProseMirror h2,
.tiptap.ProseMirror h3,
.tiptap.ProseMirror h4,
.tiptap.ProseMirror h5,
.tiptap.ProseMirror h6 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.25;
}

.tiptap.ProseMirror h1 { font-size: 2.25rem; }
.tiptap.ProseMirror h2 { font-size: 1.875rem; }
.tiptap.ProseMirror h3 { font-size: 1.5rem; }
.tiptap.ProseMirror h4 { font-size: 1.25rem; }
.tiptap.ProseMirror h5 { font-size: 1.125rem; }
.tiptap.ProseMirror h6 { font-size: 1rem; }

.tiptap.ProseMirror blockquote {
  border-left: 4px solid #e5e7eb;
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: #6b7280;
}

.tiptap.ProseMirror ul,
.tiptap.ProseMirror ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.tiptap.ProseMirror li {
  margin-bottom: 0.5rem;
}

.tiptap.ProseMirror a {
  color: #3b82f6;
  text-decoration: underline;
}

.tiptap.ProseMirror a:hover {
  color: #1d4ed8;
}

.tiptap.ProseMirror strong {
  font-weight: 600;
}

.tiptap.ProseMirror em {
  font-style: italic;
}

.tiptap.ProseMirror s {
  text-decoration: line-through;
}

.tiptap.ProseMirror code {
  background-color: #f3f4f6;
  color: #374151;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.tiptap.ProseMirror pre {
  background-color: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.tiptap.ProseMirror pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.tiptap.ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.tiptap.ProseMirror table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
}

.tiptap.ProseMirror table td,
.tiptap.ProseMirror table th {
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.tiptap.ProseMirror table th {
  background-color: #f9fafb;
  font-weight: 600;
}

/* Bubble menu styles */
.bubble-menu {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 0.25rem;
  z-index: 1000;
}

.table-bubble-menu .btn-group {
  margin: 0 0.25rem;
}

/* Custom dropdown styles para evitar problemas de overflow */
.custom-dropdown-menu .dropdown-item {
  transition: all 0.15s ease-in-out;
}

.custom-dropdown-menu .dropdown-item:hover,
.custom-dropdown-menu .dropdown-item:focus {
  background-color: #f8f9fa !important;
  color: #495057 !important;
}

.custom-dropdown-menu .dropdown-item.active,
.custom-dropdown-menu .dropdown-item:active {
  background-color: #0d6efd !important;
  color: #fff !important;
}

/* Placeholder */
.tiptap.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: #9ca3af;
  pointer-events: none;
  height: 0;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  .tiptap.ProseMirror {
    padding: 2rem 1.5rem;
  }

  .editor-toolbar {
    padding: 0.5rem 0.75rem;
  }
}

@media screen and (max-width: 480px) {
  .tiptap.ProseMirror {
    padding: 1rem 1.5rem;
  }
}

/* Legacy support - mantém compatibilidade com estilos antigos */
.tiptap-editor .ProseMirror ul,
.tiptap-editor .ProseMirror ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.tiptap-editor .ProseMirror blockquote {
  border-left: 4px solid #e5e7eb;
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: #6b7280;
}

.tiptap-editor .ProseMirror pre {
  background: #f3f4f6;
  color: #374151;
  font-family: 'JetBrainsMono', 'Courier New', Courier, monospace;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.tiptap-editor .ProseMirror code {
  background: #f3f4f6;
  color: #374151;
  font-size: 0.9rem;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
}

.tiptap-editor .ProseMirror a {
  color: #3b82f6;
  text-decoration: underline;
}

.tiptap-editor .ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  margin: 1rem 0;
}

.tiptap-editor .ProseMirror strong {
  font-weight: bold;
}

.tiptap-editor .ProseMirror em {
  font-style: italic;
}

.tiptap-editor .ProseMirror s {
  text-decoration: line-through;
}

/* Media Upload Styles */
.media-upload-wrapper {
  .media-upload-dragger {
    transition: all 0.2s ease-in-out;

    &:hover {
      border-color: #6366f1 !important;
      background-color: rgba(99, 102, 241, 0.05);
    }

    &.media-upload-dragger-active {
      border-color: #6366f1 !important;
      background-color: rgba(99, 102, 241, 0.1);
      transform: scale(1.02);
    }
  }

  .media-upload-preview {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.2s ease-in-out;

    &:hover {
      box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }
  }
}

/* Video element styles */
.tiptap-editor .ProseMirror video {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  margin: 1rem 0;
}

.tiptap-editor .ProseMirror img {
  max-height: 80vh;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

/* Drag and Drop Styles */
.wysiwyg-editor {
  position: relative;
}

.wysiwyg-editor.drag-over {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

.drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(99, 102, 241, 0.05);
  border: 2px dashed #6366f1;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.drag-message {
  text-align: center;
  color: #6366f1;
  padding: 2rem;
}

.drag-message h5 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
  color: #374151;
}

.drag-message p {
  margin: 0;
  color: #6b7280;
  font-size: 0.875rem;
}

/* Media Upload Drag Area Styles */
.media-upload-dragger {
  transition: all 0.2s ease-in-out;
}

.media-upload-dragger-active {
  background-color: rgba(99, 102, 241, 0.05);
  border-color: #6366f1 !important;
}
