/* Custom Word-like Rich Text Editor Styles */

.custom-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid #d1d5db;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: #d1d5db;
  margin: 0 0.25rem;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.toolbar-btn:active {
  background: #d1d5db;
  transform: scale(0.95);
}

.toolbar-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #2563eb;
}

.color-picker {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
  border: none;
  border-radius: 3px;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.custom-editor {
  min-height: 400px;
  padding: 1rem;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 6px 6px;
  background: white;
  font-size: 14px;
  line-height: 1.6;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  outline: none;
  overflow-y: auto;
}

/* Proper paragraph spacing in editor */
.custom-editor p {
  margin: 0 0 1em 0;
  line-height: 1.6;
}

.custom-editor p:last-child {
  margin-bottom: 0;
}

/* Ensure line breaks are visible */
.custom-editor br {
  line-height: 1.6;
}

/* Better spacing for headings in editor */
.custom-editor h1, .custom-editor h2, .custom-editor h3, 
.custom-editor h4, .custom-editor h5, .custom-editor h6 {
  margin: 1.2em 0 0.8em 0;
  line-height: 1.3;
}

.custom-editor h1:first-child, .custom-editor h2:first-child, 
.custom-editor h3:first-child, .custom-editor h4:first-child,
.custom-editor h5:first-child, .custom-editor h6:first-child {
  margin-top: 0;
}

.custom-editor:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-editor[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-style: italic;
}

/* Custom header styles */
.custom-header-1 {
  font-size: 2em !important;
  font-weight: bold !important;
  color: #1e40af !important;
  line-height: 1.2 !important;
}

.custom-header-2 {
  font-size: 1.5em !important;
  font-weight: bold !important;
  color: #1e40af !important;
  line-height: 1.3 !important;
}

.custom-header-3 {
  font-size: 1.25em !important;
  font-weight: bold !important;
  color: #1e40af !important;
  line-height: 1.4 !important;
}

.custom-header-4 {
  font-size: 1.1em !important;
  font-weight: bold !important;
  color: #1e40af !important;
  line-height: 1.4 !important;
}

.custom-header-5 {
  font-size: 1em !important;
  font-weight: bold !important;
  color: #1e40af !important;
  line-height: 1.4 !important;
}

.custom-header-6 {
  font-size: 0.9em !important;
  font-weight: bold !important;
  color: #1e40af !important;
  line-height: 1.4 !important;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
  .custom-toolbar {
    padding: 0.5rem;
    gap: 0.25rem;
  }
  
  .toolbar-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .color-picker {
    width: 28px;
    height: 28px;
  }
  
  .custom-editor {
    min-height: 300px;
    padding: 0.75rem;
    font-size: 13px;
  }
}

/* Selection highlight */
.custom-editor ::selection {
  background: rgba(59, 130, 246, 0.2);
}

/* Focus styles for better accessibility */
.toolbar-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.color-picker:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Extended formatting styles */

/* Blockquote styling */
.custom-editor blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid #3b82f6;
  background: #f8fafc;
  font-style: italic;
  color: #4b5563;
}

.custom-editor blockquote p {
  margin: 0;
}

/* Code formatting */
.custom-editor code {
  background: #f1f5f9;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
  color: #dc2626;
}

.custom-editor pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
}

.custom-editor pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* List styling */
.custom-editor ul, .custom-editor ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.custom-editor ul {
  list-style-type: disc;
}

.custom-editor ol {
  list-style-type: decimal;
}

.custom-editor li {
  margin: 0.25rem 0;
  line-height: 1.6;
}

/* Checklist styling */
.custom-editor .checklist {
  list-style: none;
  padding-left: 0;
}

.custom-editor .checklist li {
  position: relative;
  padding-left: 1.5rem;
}

.custom-editor .checklist li::before {
  content: '☐';
  position: absolute;
  left: 0;
  color: #6b7280;
  font-weight: bold;
}

.custom-editor .checklist li.checked::before {
  content: '☑';
  color: #059669;
}

/* Text alignment */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-justify { text-align: justify !important; }

/* Advanced text formatting */
.custom-editor .strikethrough {
  text-decoration: line-through;
}

.custom-editor .underline {
  text-decoration: underline;
}

.custom-editor .subscript {
  vertical-align: sub;
  font-size: 0.8em;
}

.custom-editor .superscript {
  vertical-align: super;
  font-size: 0.8em;
}

.custom-editor .highlight {
  background-color: #fef08a;
  padding: 0.125rem;
  border-radius: 2px;
}

/* Link styling */
.custom-editor a {
  color: #3b82f6;
  text-decoration: underline;
  cursor: pointer;
}

.custom-editor a:hover {
  color: #1d4ed8;
  text-decoration: none;
}

/* Image styling */
.custom-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.custom-editor img.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Dropdown styling for toolbar selectors */
.toolbar-select {
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: white;
  padding: 0 0.5rem;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  min-width: 80px;
}

.toolbar-select:hover {
  border-color: #9ca3af;
}

.toolbar-select:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  border-color: #3b82f6;
}

/* Font family and size styling */
.font-serif { font-family: Georgia, 'Times New Roman', Times, serif !important; }
.font-sans { font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; }
.font-mono { font-family: 'Courier New', Courier, monospace !important; }

.text-xs { font-size: 0.75em !important; }
.text-sm { font-size: 0.875em !important; }
.text-base { font-size: 1em !important; }
.text-lg { font-size: 1.125em !important; }
.text-xl { font-size: 1.25em !important; }
.text-2xl { font-size: 1.5em !important; }

/* Improved toolbar layout */
.custom-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #d1d5db;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0 0.25rem;
}

/* Button group styling */
.btn-group {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #d1d5db;
}

.btn-group .toolbar-btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid #d1d5db;
}

.btn-group .toolbar-btn:last-child {
  border-right: none;
}

/* Tooltip support */
.toolbar-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
}