/* app/assets/stylesheets/tiptap.css */

/* Main editor wrapper */
.tiptap-editor {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Toolbar */
.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.tiptap-toolbar-group {
  display: flex;
  gap: 2px;
  align-items: center;
}

.tiptap-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: #374151;
  transition: all 0.15s ease;
}

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

.tiptap-toolbar button.is-active {
  background: #3b82f6;
  color: white;
}

.tiptap-toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tiptap-toolbar button:disabled:hover {
  background: transparent;
  color: #374151;
}

.tiptap-toolbar button svg {
  width: 18px;
  height: 18px;
}

.tiptap-toolbar-separator {
  width: 1px;
  height: 24px;
  background: #d1d5db;
  margin: 0 4px;
}

/* Dropdown for headings */
.tiptap-dropdown {
  position: relative;
}

.tiptap-dropdown select {
  height: 32px;
  padding: 0 32px 0 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.tiptap-dropdown select:hover {
  border-color: #9ca3af;
}

/* Editor content area */
.tiptap-content {
  padding: 16px;
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
}

.tiptap {
  outline: none;
  font-size: 16px;
  line-height: 1.6;
  color: #1f2937;
}

/* Typography styles */
.tiptap p {
  margin: 0.75em 0;
}

.tiptap p:first-child {
  margin-top: 0;
}

.tiptap p:last-child {
  margin-bottom: 0;
}

.tiptap h1 {
  font-size: 2em;
  font-weight: 700;
  margin: 1.5em 0 0.75em;
  line-height: 1.2;
  color: #111827;
}

.tiptap h2 {
  font-size: 1.5em;
  font-weight: 600;
  margin: 1.25em 0 0.5em;
  line-height: 1.3;
  color: #111827;
}

.tiptap h3 {
  font-size: 1.25em;
  font-weight: 600;
  margin: 1em 0 0.5em;
  line-height: 1.4;
  color: #111827;
}

.tiptap ul,
.tiptap ol {
  padding-left: 2em;
  margin: 0.75em 0;
}

.tiptap ul {
  list-style: disc;
}

.tiptap ol {
  list-style: decimal;
}

.tiptap li {
  margin: 0.25em 0;
}

.tiptap li p {
  margin: 0;
}

.tiptap blockquote {
  border-left: 3px solid #3b82f6;
  padding-left: 1em;
  margin: 1em 0;
  font-style: italic;
  color: #6b7280;
}

.tiptap code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.875em;
  color: #dc2626;
}

.tiptap pre {
  background: #1f2937;
  color: #f9fafb;
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1em 0;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.875em;
  line-height: 1.5;
}

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

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

.tiptap a:hover {
  color: #2563eb;
}

.tiptap img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1em 0;
  display: block;
}

.tiptap strong {
  font-weight: 700;
}

.tiptap em {
  font-style: italic;
}

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

.tiptap hr {
  border: none;
  border-top: 2px solid #e5e7eb;
  margin: 2em 0;
}

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

/* Focus state */
.tiptap:focus {
  outline: none;
}

.tiptap-editor:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Responsive */
@media (max-width: 640px) {
  .tiptap-toolbar {
    padding: 4px;
  }
  
  .tiptap-toolbar button {
    width: 28px;
    height: 28px;
  }
  
  .tiptap-toolbar button svg {
    width: 16px;
    height: 16px;
  }
  
  .tiptap-content {
    padding: 12px;
  }
}
