/* =========================================================
   Writing Editor & Editor Page Shared Styles
   ========================================================= */

/* --- Editor Container --- */
.writing-editor {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
}

/* --- Toolbar --- */
.writing-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.writing-editor__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #495057;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.writing-editor__btn:hover {
  background: #e9ecef;
}

.writing-editor__btn.is-active {
  background: #0586eb;
  color: #fff;
}

.writing-editor__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.writing-editor__btn--heading {
  width: auto;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
}

.writing-editor__separator {
  width: 1px;
  height: 24px;
  margin: 0 6px;
  background: #dee2e6;
}

/* --- Upload Button --- */
.writing-editor__upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px dashed #adb5bd;
  border-radius: 6px;
  background: transparent;
  color: #495057;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.writing-editor__upload-btn:hover {
  border-color: #0586eb;
  background: rgba(5, 134, 235, 0.05);
  color: #0586eb;
}

.writing-editor__upload-btn input[type="file"] {
  display: none;
}

/* --- Content Area Typography --- */
.writing-editor__content .tiptap {
  min-height: 300px;
  padding: 16px 20px;
  line-height: 1.7;
  font-size: 0.95rem;
  outline: none;
}

.writing-editor__content .tiptap > *:first-child {
  margin-top: 0;
}

.writing-editor__content .tiptap > *:last-child {
  margin-bottom: 0;
}

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

/* Headings */
.writing-editor__content .tiptap h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 1.5em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid #e9ecef;
}

.writing-editor__content .tiptap h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 1.3em 0 0.5em;
}

.writing-editor__content .tiptap h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.2em 0 0.4em;
}

/* Blockquote */
.writing-editor__content .tiptap blockquote {
  border-left: 4px solid #0586eb;
  background: rgba(5, 134, 235, 0.05);
  margin: 1em 0;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
}

/* Code Block */
.writing-editor__content .tiptap pre {
  background: #1e293b;
  color: #e2e8f0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875rem;
  padding: 16px 20px;
  border-radius: 8px;
  margin: 1em 0;
  overflow-x: auto;
}

/* Inline Code */
.writing-editor__content .tiptap code {
  background: #f1f3f5;
  color: #e83e8c;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 4px;
}

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

/* Lists */
.writing-editor__content .tiptap ul {
  padding-left: 1.5em;
  list-style: disc;
}

.writing-editor__content .tiptap ol {
  padding-left: 1.5em;
  list-style: decimal;
}

.writing-editor__content .tiptap li {
  margin: 0.25em 0;
}

/* Horizontal Rule */
.writing-editor__content .tiptap hr {
  border: none;
  border-top: 2px solid #e9ecef;
  margin: 1.5em 0;
}

/* Highlight */
.writing-editor__content .tiptap mark {
  background: #fff3cd;
  padding: 1px 2px;
  border-radius: 2px;
}

/* Image */
.writing-editor__content .tiptap img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
  border-radius: 6px;
}

/* --- Editor Page Form Shared Styles --- */
.editor-page__form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #344054;
  margin-bottom: 8px;
}

.editor-page__form-label i {
  color: #0586eb;
  font-size: 0.85rem;
}

.editor-page__form-input {
  border-radius: 8px !important;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-page__form-input:focus {
  border-color: #0586eb !important;
  box-shadow: 0 0 0 3px rgba(5, 134, 235, 0.15) !important;
}

.editor-page__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e9ecef;
}

.editor-page__btn-submit {
  transition: all 0.2s ease;
}

.editor-page__btn-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* =========================================================
   Dark Mode (.dark-only)
   ========================================================= */

/* Editor Container */
.dark-only .writing-editor {
  border-color: #4a5568;
}

/* Toolbar */
.dark-only .writing-editor__toolbar {
  background: #2d3748;
  border-bottom-color: #4a5568;
}

.dark-only .writing-editor__btn {
  color: #cbd5e0;
}

.dark-only .writing-editor__btn:hover {
  background: #4a5568;
}

.dark-only .writing-editor__btn.is-active {
  background: #0586eb;
  color: #fff;
}

.dark-only .writing-editor__separator {
  background: #4a5568;
}

/* Upload Button */
.dark-only .writing-editor__upload-btn {
  border-color: #4a5568;
  color: #cbd5e0;
}

.dark-only .writing-editor__upload-btn:hover {
  border-color: #0586eb;
  background: rgba(5, 134, 235, 0.1);
  color: #63b3ed;
}

/* Content Area */
.dark-only .writing-editor__content .tiptap {
  color: #e2e8f0;
}

.dark-only .writing-editor__content .tiptap p.is-editor-empty:first-child::before {
  color: #718096;
}

.dark-only .writing-editor__content .tiptap h1 {
  border-bottom-color: #4a5568;
}

.dark-only .writing-editor__content .tiptap blockquote {
  background: rgba(5, 134, 235, 0.1);
  border-left-color: #63b3ed;
}

.dark-only .writing-editor__content .tiptap pre {
  background: #0f172a;
}

.dark-only .writing-editor__content .tiptap code {
  background: #2d3748;
  color: #f687b3;
}

.dark-only .writing-editor__content .tiptap pre code {
  background: none;
  color: inherit;
}

.dark-only .writing-editor__content .tiptap hr {
  border-top-color: #4a5568;
}

.dark-only .writing-editor__content .tiptap mark {
  background: rgba(255, 243, 205, 0.2);
  color: #fefcbf;
}

/* Form Labels */
.dark-only .editor-page__form-label {
  color: #e2e8f0;
}

.dark-only .editor-page__form-label i {
  color: #63b3ed;
}

/* Form Inputs */
.dark-only .editor-page__form-input {
  background-color: #2d3748;
  color: #e2e8f0;
  border-color: #4a5568;
}

.dark-only .editor-page__form-input:focus {
  border-color: #0586eb !important;
  box-shadow: 0 0 0 3px rgba(5, 134, 235, 0.25) !important;
}

/* Actions */
.dark-only .editor-page__actions {
  border-top-color: #4a5568;
}

.dark-only .editor-page__btn-submit:hover:not(:disabled) {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Select dark mode */
.dark-only select.editor-page__form-input {
  background-color: #2d3748;
  color: #e2e8f0;
  border-color: #4a5568;
}

.dark-only select.editor-page__form-input option {
  background-color: #2d3748;
  color: #e2e8f0;
}
