/* Tiptap Editor Styles */

/* Enhanced Context Panel Styles */
.context-panel {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
  flex-shrink: 0; /* Prevent shrinking */
  width: 320px; /* Fixed width */
  max-height: 100vh; /* Max height constraint */
  overflow-y: auto; /* Allow scrolling */
}

.context-panel::-webkit-scrollbar {
  width: 6px;
}

.context-panel::-webkit-scrollbar-track {
  background: transparent;
}

.context-panel::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}

.data-card {
  transition: all 0.2s ease-in-out;
}

.data-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Toolbar button styles */
.toolbar-button {
  @apply p-2 rounded transition-colors duration-150;
}

.toolbar-button:hover {
  @apply bg-lavender/20;
}

.toolbar-button.active {
  @apply bg-blue/20 text-blue;
}

/* Editor container */
.ProseMirror {
  outline: none;
  word-wrap: break-word;
  min-height: 150px;
}

/* Editor content styles for Stimulus controller */
[data-tiptap-editor-target="editor"] {
  @apply px-6 py-4;
}

[data-tiptap-editor-target="editor"]:focus {
  @apply outline-none ring-2 ring-blue ring-offset-2;
}

/* Basic typography */
.ProseMirror h1 {
  font-size: 1.75rem;
  font-weight: bold;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.ProseMirror h2 {
  font-size: 1.5rem;
  font-weight: bold;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.ProseMirror p {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* Lists */
.ProseMirror ul,
.ProseMirror ol {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.ProseMirror ul {
  list-style-type: disc;
}

.ProseMirror ol {
  list-style-type: decimal;
}

.ProseMirror li {
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.ProseMirror li > h1,
.ProseMirror li > h2 {
  display: inline;
  margin: 0;
}

/* Fix for nested headings and lists */
.ProseMirror li h1,
.ProseMirror li h2 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  display: inline;
}

/* Toolbar */
.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 0.5rem;
  background-color: #f9fafb;
}

/* Toolbar buttons */
.tiptap-button {
  padding: 0.375rem;
  border-radius: 0.25rem;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: background-color 0.2s;
}

.tiptap-button:hover {
  background-color: #e5e7eb;
}

.tiptap-button.active,
.tiptap-button.bg-lavender/20 {
  @apply bg-blue/20;
}

/* RTL support */
[dir="rtl"] .ProseMirror ul,
[dir="rtl"] .ProseMirror ol {
  padding-right: 1.5rem;
  padding-left: 0;
}

/* RTL lists in editor */
.ProseMirror ul[dir="rtl"],
.ProseMirror ol[dir="rtl"] {
  direction: rtl;
  padding-left: 0;
  padding-right: 2.5rem;
  margin-left: 0;
  margin-right: 0;
}

.ProseMirror ul[dir="rtl"] li,
.ProseMirror ol[dir="rtl"] li {
  direction: rtl;
  text-align: right;
}

/* For Webkit browsers (Chrome, Safari) */
.ProseMirror ul[dir="rtl"] {
  list-style-type: disc;
}

.ProseMirror ol[dir="rtl"] {
  list-style-type: decimal;
}

/* RTL paragraphs and headings */
.ProseMirror p[dir="rtl"],
.ProseMirror h1[dir="rtl"],
.ProseMirror h2[dir="rtl"],
.ProseMirror h3[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* Placeholder Styling with Prominent Amber/Orange Gradients */
.placeholder-highlight {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  display: inline-block;
  margin: 0 2px;
  animation: placeholderPulse 2s ease-in-out infinite;
}

@keyframes placeholderPulse {
  0%, 100% {
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
    transform: translateY(-1px);
  }
}

/* Template Preview Modal Styles */
.template-preview-content .placeholder-highlight {
  background: linear-gradient(135deg, #fde68a 0%, #fbbf24 50%, #f59e0b 100%);
  color: #92400e;
  text-shadow: none;
  font-weight: 500;
}

/* Template Item Hover Effects */
.template-item {
  position: relative;
  overflow: hidden;
}

.template-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
  transition: left 0.5s;
}

.template-item:hover::before {
  left: 100%;
}

/* Quick Insert Panel Styles */
#quick-insert-panel {
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.95);
}

/* Quick Add Form Styles */
#quick-add-form {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 0;
  animation: slideDown 0.3s ease-out;
}

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

#quick-add-form input,
#quick-add-form select,
#quick-add-form textarea {
  background-color: white;
  transition: all 0.2s ease;
}

#quick-add-form input:focus,
#quick-add-form select:focus,
#quick-add-form textarea:focus {
  background-color: #fefefe;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.template-category h4 {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  z-index: 10;
  padding: 8px 0;
  margin: 0 -16px 12px -16px;
  padding-left: 16px;
  border-bottom: 1px solid #f3f4f6;
}

/* Search Input Enhancement */
#template-search:focus {
  background-color: #fefefe;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}


/* Success Feedback Animation */
.insert-success-feedback {
  animation: slideInRight 0.3s ease-out, slideOutRight 0.3s ease-in 2s forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Modal Entrance Animation */
#template-preview-modal.show {
  animation: modalFadeIn 0.2s ease-out;
}

#template-preview-modal.show > div {
  animation: modalSlideIn 0.3s ease-out;
}

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

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

/* Editor Layout Fixes */
.report-editor-container {
  min-height: 100vh;
  display: flex;
  flex-direction: row; /* Ensure horizontal layout */
}

.report-editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Ensure editor content has enough bottom padding */
.ProseMirror {
  min-height: 400px;
  padding-bottom: 4rem; /* Increased bottom padding */
}

/* Footer overlap fix */
body.report-editor-page {
  overflow-x: hidden; /* Only hide horizontal overflow */
  position: relative;
}

.report-editor-page footer {
  display: none; /* Hide footer on report editor page */
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  #quick-insert-panel {
    right: 1rem;
    left: 1rem;
    width: auto;
  }
  
  #template-preview-modal .max-w-2xl {
    max-width: calc(100vw - 2rem);
  }
  
  .context-panel {
    width: 280px; /* Slightly narrower on mobile */
  }
  
  /* Make header button smaller on mobile */
  .report-editor-main .bg-blue-600 {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
}