/* CKEditor 5 Custom Styles */

/* Hide CKEditor branding/watermark */
.ck.ck-balloon-panel.ck-powered-by-balloon {
  display: none !important;
}

.ck-powered-by {
  display: none !important;
}

.ck.ck-balloon-panel[class*="ck-powered-by"] {
  display: none !important;
}

/* Fix double layer - hide textarea completely and remove duplicate borders */
[data-shared--ckeditor-target="editor"] {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  opacity: 0 !important;
  height: 0 !important;
  width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

/* Editor wrapper - ONLY outer border, no inner borders */
.ck-editor {
  width: 100%;
  border: 1px solid #14b8a6 !important;
  border-radius: 0.375rem !important;
  overflow: hidden !important;
  box-shadow: none !important;
  background-color: #ffffff !important;
}

.ck-editor:focus-within {
  border-color: #0d9488 !important;
  box-shadow: none !important;
}

/* Main editor container - NO borders at all */
.ck-editor__editable_inline {
  min-height: 260px;
  max-height: 500px;
  overflow-y: auto;
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  border-radius: 0 !important;
  padding: 0.75rem !important;
  font-family: Figtree, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.625;
  background-color: #ffffff !important;
  margin: 0 !important;
  outline: none !important;
}

/* Focus state - teal color (handled by parent wrapper) */
.ck-editor__editable_inline:focus {
  outline: none !important;
  border: none !important;
}

/* Toolbar styling - teal theme - NO borders */
.ck.ck-toolbar {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  border-radius: 0 !important;
  background-color: #f0fdfa !important;
  padding: 0.5rem !important;
  margin: 0 !important;
  outline: none !important;
}

/* Toolbar buttons */
.ck.ck-toolbar .ck-toolbar__items {
  gap: 0.25rem;
}

.ck.ck-button {
  border-radius: 0.25rem !important;
  color: #374151 !important;
  box-shadow: none !important;
  outline: none !important;
}

.ck.ck-button:not(.ck-color-grid__tile):not(.ck-color-grid__button):hover {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

.ck.ck-button.ck-on:not(.ck-color-grid__tile):not(.ck-color-grid__button) {
  background-color: #ccfbf1 !important; /* teal-100 */
  color: #0f766e !important;
}

.ck.ck-button.ck-on:not(.ck-color-grid__tile):not(.ck-color-grid__button):hover {
  background-color: #99f6e4 !important; /* teal-200 */
  color: #0d9488 !important;
}

/* Editor wrapper */
.ck-editor {
  width: 100%;
}

/* Content styles */
.ck-editor__editable_inline p {
  margin-bottom: 0.75rem;
}

.ck-editor__editable_inline h1,
.ck-editor__editable_inline h2,
.ck-editor__editable_inline h3,
.ck-editor__editable_inline h4 {
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.ck-editor__editable_inline h1 {
  font-size: 2rem;
  line-height: 2.5rem;
}

.ck-editor__editable_inline h2 {
  font-size: 1.5rem;
  line-height: 2rem;
}

.ck-editor__editable_inline h3 {
  font-size: 1.25rem;
  line-height: 1.75rem;
}

.ck-editor__editable_inline h4 {
  font-size: 1.125rem;
  line-height: 1.5rem;
}

.ck-editor__editable_inline ul,
.ck-editor__editable_inline ol {
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.ck-editor__editable_inline blockquote {
  border-left: 4px solid #14b8a6;
  padding-left: 1rem;
  margin-left: 0;
  margin-bottom: 0.75rem;
  color: #0d9488;
  font-style: italic;
  background-color: #f0fdfa;
}

.ck-editor__editable_inline table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 0.75rem;
}

.ck-editor__editable_inline table td,
.ck-editor__editable_inline table th {
  border: 1px solid #d1d5db;
  padding: 0.5rem;
}

.ck-editor__editable_inline table th {
  background-color: #f9fafb;
  font-weight: 600;
}

.ck-editor__editable_inline a {
  color: #14b8a6;
  text-decoration: underline;
}

.ck-editor__editable_inline a:hover {
  color: #0d9488;
}

/* Placeholder styling */
.ck-editor__editable_inline.ck-placeholder::before {
  color: #9ca3af !important;
}

/* Dropdown styling - neutral gray theme */
.ck.ck-dropdown__panel {
  border-radius: 0.375rem !important;
  border-color: #d1d5db !important;
  background-color: #ffffff !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

/* Font size and font family dropdowns - shorter height with scroll */
/* Apply same pattern as color dropdowns - only style the list, not the panel */
/* Target dropdowns that contain many list items (font size has 10-50, font family has 10 options) */
.ck.ck-dropdown__panel:has(.ck-list__item:nth-child(10) .ck-button:not([class*="color"])) .ck-list {
  max-height: 200px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* Smooth scrolling for font size and font family dropdowns */
.ck.ck-dropdown__panel:has(.ck-list__item:nth-child(10) .ck-button:not([class*="color"])) .ck-list {
  scrollbar-width: thin !important;
  scrollbar-color: #d1d5db #f3f4f6 !important;
}

/* Webkit scrollbar styling for font size and font family dropdowns */
.ck.ck-dropdown__panel:has(.ck-list__item:nth-child(10) .ck-button:not([class*="color"])) .ck-list::-webkit-scrollbar {
  width: 8px !important;
}

.ck.ck-dropdown__panel:has(.ck-list__item:nth-child(10) .ck-button:not([class*="color"])) .ck-list::-webkit-scrollbar-track {
  background: #f3f4f6 !important;
  border-radius: 4px !important;
}

.ck.ck-dropdown__panel:has(.ck-list__item:nth-child(10) .ck-button:not([class*="color"])) .ck-list::-webkit-scrollbar-thumb {
  background: #d1d5db !important;
  border-radius: 4px !important;
}

.ck.ck-dropdown__panel:has(.ck-list__item:nth-child(10) .ck-button:not([class*="color"])) .ck-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af !important;
}

.ck.ck-dropdown__panel .ck-button {
  box-shadow: none !important;
  border-color: transparent !important;
  outline: none !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ck.ck-dropdown__panel .ck-button:focus {
  box-shadow: none !important;
  border-color: transparent !important;
  outline: none !important;
}

.ck.ck-dropdown__panel .ck-button:not(.ck-color-grid__tile).ck-on {
  background-color: #e5e7eb !important;
  color: #111827 !important;
}

.ck.ck-dropdown__panel .ck-button:not(.ck-color-grid__tile):hover {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

/* Color grid tiles */
.ck.ck-color-grid__tile,
.ck.ck-color-grid__button {
  border-radius: 0.5rem !important;
  border: 2px solid transparent !important;
  box-shadow: none !important;
  outline: none !important;
  background-image: none !important;
  transition: border-color 0.15s ease !important;
}

.ck.ck-color-grid__tile:focus,
.ck.ck-color-grid__button:focus {
  border-color: #93c5fd !important; /* focus ring */
  filter: none !important;
  opacity: 1 !important;
}

.ck.ck-color-grid__tile.ck-on,
.ck.ck-color-grid__button.ck-on {
  border-color: #3b82f6 !important; /* blue-500 */
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
}

.ck.ck-color-grid__tile:hover > * {
  opacity: 1 !important;
}

/* Balloon panel styling (for link editing, etc.) - neutral gray theme */
.ck.ck-balloon-panel {
  border-radius: 0.375rem !important;
  border-color: #d1d5db !important;
  background-color: #ffffff !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

.ck.ck-balloon-panel .ck-button.ck-on,
.ck.ck-balloon-panel .ck-button:hover {
  background-color: #f3f4f6 !important;
  color: #374151 !important;
}

.ck.ck-balloon-panel .ck-button.ck-on {
  background-color: #e5e7eb !important;
  color: #1f2937 !important;
}

/* Input styling inside editor - teal theme */
.ck.ck-input {
  border-radius: 0.375rem !important;
  border-color: #d1d5db !important;
}

.ck.ck-input:focus {
  border-color: #0d9488 !important;
  box-shadow: none !important;
}

/* Ensure proper spacing and alignment in the container */
[data-controller="shared--ckeditor"] {
  position: relative;
  display: block;
  width: 100%;
}

/* Single outer border on editor wrapper - ONLY border */
[data-controller="shared--ckeditor"] .ck.ck-editor {
  border: 1px solid #14b8a6 !important;
  border-radius: 0.375rem !important;
  overflow: hidden !important;
  margin: 0 !important;
  background-color: #ffffff !important;
}

[data-controller="shared--ckeditor"] .ck.ck-editor:focus-within {
  border-color: #0d9488 !important;
  box-shadow: none !important;
}

/* Remove ALL borders from ALL inner elements */
[data-controller="shared--ckeditor"] .ck.ck-editor__top {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  outline: none !important;
}

[data-controller="shared--ckeditor"] .ck.ck-editor__main {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  margin: 0 !important;
  padding: 0 !important;
  outline: none !important;
}

[data-controller="shared--ckeditor"] .ck.ck-editor__main > .ck-editor__editable {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  outline: none !important;
}

[data-controller="shared--ckeditor"] .ck.ck-editor__main > .ck-editor__editable:focus {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Ensure toolbar has NO borders */
[data-controller="shared--ckeditor"] .ck.ck-toolbar {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  outline: none !important;
}

/* Sticky panel content - only bottom border */
.ck.ck-sticky-panel__content {
  border: none !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid #d1d5db !important;
  outline: none !important;
}

[data-controller="shared--ckeditor"] .ck.ck-sticky-panel__content {
  border: none !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid #d1d5db !important;
  outline: none !important;
}

/* Tooltip styling for visibility */
.ck.ck-tooltip {
  background-color: #111827 !important;
  color: #f9fafb !important;
  border-radius: 0.375rem !important;
  padding: 0.25rem 0.5rem !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2) !important;
}

.ck.ck-tooltip .ck-tooltip__text {
  color: #f9fafb !important;
  font-size: 0.75rem !important;
}

.ck.ck-tooltip .ck-tooltip__arrow::before {
  border-top-color: #111827 !important;
}

/* Loading state indicator - teal theme */
[data-controller="shared--ckeditor"]::before {
  content: '';
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f4f6;
  border-top-color: #14b8a6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ck.ck-toolbar {
    flex-wrap: wrap;
  }
  
  .ck-editor__editable_inline {
    min-height: 150px;
  }
}

