/* ==========================================
   TipTap Editor Styles
   ========================================== */

/* Editor Container */
.tiptap-editor-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ==========================================
   Toolbar
   ========================================== */

.tiptap-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.tiptap-toolbar-group {
    display: flex;
    gap: 2px;
    padding-right: 8px;
    border-right: 1px solid var(--border-color);
    margin-right: 8px;
    align-items: center;
}

.tiptap-toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.tiptap-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 16px;
}

.tiptap-toolbar button:hover {
    background: var(--bg-surface-hover, rgba(255,255,255,0.1));
    color: var(--text-primary);
}

.tiptap-toolbar button.is-active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tiptap-toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tiptap-toolbar select {
    height: 32px;
    padding: 4px 24px 4px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.tiptap-toolbar select:hover {
    border-color: var(--border-color-hover, #6b7280);
}

.tiptap-toolbar select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Specific select widths */
.tiptap-toolbar .heading-select {
    min-width: 110px;
}

.tiptap-toolbar .font-size-select {
    min-width: 65px;
}

.tiptap-toolbar .line-spacing-select {
    min-width: 80px;
}

.tiptap-toolbar input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}

.tiptap-toolbar input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.tiptap-toolbar input[type="color"]::-webkit-color-swatch {
    border-radius: 2px;
    border: none;
}

/* Color picker wrapper (legacy) */
.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.color-picker-wrapper .color-indicator {
    position: absolute;
    bottom: 2px;
    left: 4px;
    right: 4px;
    height: 3px;
    border-radius: 1px;
    pointer-events: none;
}

/* ==========================================
   Color Split Buttons (Word-style)
   ========================================== */

.color-split-button {
    display: flex;
    position: relative;
}

.color-split-button .color-apply-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px 0 0 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    gap: 2px;
}

.color-split-button .color-apply-btn:hover {
    background: var(--bg-surface-hover, rgba(255,255,255,0.1));
    color: var(--text-primary);
}

.color-split-button .color-apply-btn .color-indicator {
    display: block;
    width: 16px;
    height: 3px;
    border-radius: 1px;
}

.color-split-button .color-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-left: none;
    border-radius: 0 4px 4px 0;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 8px;
}

.color-split-button .color-dropdown-btn:hover {
    background: var(--bg-surface-hover, rgba(255,255,255,0.1));
    color: var(--text-primary);
}

.color-split-button .color-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 140px;
}

.color-split-button .color-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.color-split-button .color-swatch {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.color-split-button .color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.color-split-button .color-swatch.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--primary-color);
}

.color-split-button .color-remove-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-split-button .color-remove-btn:hover {
    background: var(--bg-surface-hover, rgba(255,255,255,0.1));
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

/* ==========================================
   Editor Content Area
   ========================================== */

.tiptap-content {
    padding: 16px 20px;
    min-height: 350px;
    max-height: 600px;
    overflow-y: auto;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.7;
    flex: 1;
}

.tiptap-content:focus {
    outline: none;
}

/* ProseMirror base styles */
.tiptap-content .ProseMirror {
    outline: none;
    min-height: 300px;
}

.tiptap-content .ProseMirror > * + * {
    margin-top: 0.75em;
}

/* ==========================================
   Placeholder
   ========================================== */

.tiptap-content .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: var(--text-tertiary);
    pointer-events: none;
    height: 0;
}

/* ==========================================
   Typography
   ========================================== */

.tiptap-content h1 {
    font-size: 2em;
    font-weight: 700;
    margin: 1em 0 0.5em;
    line-height: 1.2;
}

.tiptap-content h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 1em 0 0.5em;
    line-height: 1.3;
}

.tiptap-content h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 1em 0 0.5em;
    line-height: 1.3;
}

.tiptap-content h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 1em 0 0.5em;
}

.tiptap-content h5 {
    font-size: 1em;
    font-weight: 600;
    margin: 1em 0 0.5em;
}

.tiptap-content h6 {
    font-size: 0.9em;
    font-weight: 600;
    margin: 1em 0 0.5em;
    color: var(--text-secondary);
}

.tiptap-content p {
    margin: 0;
}

/* ==========================================
   Lists
   ========================================== */

.tiptap-content ul {
    list-style-type: disc !important;
    padding-left: 24px;
    margin: 0.5em 0;
}

.tiptap-content ol {
    list-style-type: decimal !important;
    padding-left: 24px;
    margin: 0.5em 0;
}

.tiptap-content li {
    display: list-item !important;
    margin: 0.25em 0;
}

.tiptap-content li p {
    margin: 0;
}

/* Nested list styles */
.tiptap-content ul ul {
    list-style-type: circle !important;
    margin: 0.25em 0;
}

.tiptap-content ul ul ul {
    list-style-type: square !important;
}

.tiptap-content ol ol {
    list-style-type: lower-alpha !important;
    margin: 0.25em 0;
}

.tiptap-content ol ol ol {
    list-style-type: lower-roman !important;
}

.tiptap-content ul ol,
.tiptap-content ol ul {
    margin: 0.25em 0;
}

/* Ensure list markers are visible */
.tiptap-content ol li::marker,
.tiptap-content ul li::marker {
    color: var(--text-primary);
}

/* ==========================================
   Links
   ========================================== */

.tiptap-content a {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
}

.tiptap-content a:hover {
    text-decoration: none;
}

/* ==========================================
   Images - Resizable with Drag Handles
   ========================================== */

/* Image resizer container */
.tiptap-content .image-resizer {
    display: inline-block;
    position: relative;
    max-width: 100%;
    margin: 0.5em 0;
    line-height: 0;
}

.tiptap-content .image-resizer img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: default;
}

/* Selected state */
.tiptap-content .image-resizer.ProseMirror-selectednode {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Resize handles - hidden by default */
.tiptap-content .resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

/* Show handles on hover or when selected */
.tiptap-content .image-resizer:hover .resize-handle,
.tiptap-content .image-resizer.ProseMirror-selectednode .resize-handle,
.tiptap-content .image-resizer.resizing .resize-handle {
    opacity: 1;
}

/* Handle positions */
.tiptap-content .resize-handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.tiptap-content .resize-handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.tiptap-content .resize-handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.tiptap-content .resize-handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

/* Size indicator (shown during resize) */
.tiptap-content .size-indicator {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.tiptap-content .image-resizer.resizing .size-indicator {
    opacity: 1;
}

/* Prevent text selection during resize */
.tiptap-content .image-resizer.resizing {
    user-select: none;
}

.tiptap-content .image-resizer.resizing img {
    pointer-events: none;
}

/* Fallback for non-resizable images (e.g., in rendered content) */
.tiptap-content img:not(.image-resizer img) {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1em 0;
    display: block;
}

.tiptap-content img.ProseMirror-selectednode {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==========================================
   Tables
   ========================================== */

.tiptap-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    table-layout: fixed;
    overflow: hidden;
}

.tiptap-content th,
.tiptap-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
    position: relative;
}

.tiptap-content th {
    background: var(--bg-app);
    font-weight: 600;
}

.tiptap-content td {
    background: var(--bg-surface);
}

.tiptap-content .selectedCell {
    background: rgba(var(--primary-rgb, 79, 70, 229), 0.15) !important;
}

.tiptap-content .selectedCell::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 2px solid var(--primary-color);
}

/* Table resize handle */
.tiptap-content .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary-color);
    pointer-events: none;
}

.tiptap-content .tableWrapper {
    overflow-x: auto;
    margin: 1em 0;
}

/* ==========================================
   Code Blocks
   ========================================== */

.tiptap-content pre {
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin: 1em 0;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.tiptap-content pre code {
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
}

.tiptap-content code {
    background: var(--bg-app);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--primary-color);
}

/* Syntax Highlighting (lowlight) */
.tiptap-content pre .hljs-comment,
.tiptap-content pre .hljs-quote {
    color: #6a737d;
}

.tiptap-content pre .hljs-variable,
.tiptap-content pre .hljs-template-variable,
.tiptap-content pre .hljs-tag,
.tiptap-content pre .hljs-name,
.tiptap-content pre .hljs-selector-id,
.tiptap-content pre .hljs-selector-class,
.tiptap-content pre .hljs-regexp,
.tiptap-content pre .hljs-deletion {
    color: #e06c75;
}

.tiptap-content pre .hljs-number,
.tiptap-content pre .hljs-built_in,
.tiptap-content pre .hljs-literal,
.tiptap-content pre .hljs-type,
.tiptap-content pre .hljs-params,
.tiptap-content pre .hljs-meta,
.tiptap-content pre .hljs-link {
    color: #d19a66;
}

.tiptap-content pre .hljs-attribute {
    color: #e6c07b;
}

.tiptap-content pre .hljs-string,
.tiptap-content pre .hljs-symbol,
.tiptap-content pre .hljs-bullet,
.tiptap-content pre .hljs-addition {
    color: #98c379;
}

.tiptap-content pre .hljs-title,
.tiptap-content pre .hljs-section {
    color: #61afef;
}

.tiptap-content pre .hljs-keyword,
.tiptap-content pre .hljs-selector-tag {
    color: #c678dd;
}

/* ==========================================
   Callouts
   ========================================== */

.tiptap-content .callout {
    padding: 16px;
    border-radius: 6px;
    margin: 1em 0;
    border-left: 4px solid;
}

.tiptap-content .callout p {
    margin: 0;
}

.tiptap-content .callout-info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}

.tiptap-content .callout-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
}

.tiptap-content .callout-tip {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
}

.tiptap-content .callout-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: #ef4444;
}

/* ==========================================
   Blockquote
   ========================================== */

.tiptap-content blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 16px;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

.tiptap-content blockquote p {
    margin: 0;
}

/* ==========================================
   Horizontal Rule
   ========================================== */

.tiptap-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* ==========================================
   YouTube Embed
   ========================================== */

.tiptap-content iframe {
    width: 100%;
    max-width: 640px;
    aspect-ratio: 16/9;
    border-radius: 6px;
    margin: 1em 0;
    border: none;
}

.tiptap-content div[data-youtube-video] {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    max-width: 640px;
    margin: 1em 0;
    border-radius: 6px;
}

.tiptap-content div[data-youtube-video] iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
}

/* ==========================================
   Status Bar
   ========================================== */

.tiptap-status-bar {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-app);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-tertiary);
}

.tiptap-status-bar span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================
   Modal Dialogs
   ========================================== */

.tiptap-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.tiptap-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    width: 90%;
    max-width: 480px;
    overflow: hidden;
}

.tiptap-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tiptap-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.tiptap-modal-header .close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
}

.tiptap-modal-header .close-btn:hover {
    color: var(--text-primary);
}

.tiptap-modal-body {
    padding: 20px;
}

.tiptap-modal-body .form-group {
    margin-bottom: 16px;
}

.tiptap-modal-body .form-group:last-child {
    margin-bottom: 0;
}

.tiptap-modal-body label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tiptap-modal-body input[type="text"],
.tiptap-modal-body input[type="url"],
.tiptap-modal-body input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
}

.tiptap-modal-body input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tiptap-modal-body .image-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-app);
    border-radius: 6px;
    text-align: center;
}

.tiptap-modal-body .image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
}

.tiptap-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--bg-app);
}

.tiptap-modal-footer button {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tiptap-modal-footer .btn-cancel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.tiptap-modal-footer .btn-cancel:hover {
    background: var(--bg-surface-hover);
}

.tiptap-modal-footer .btn-primary {
    background: var(--primary-color);
    border: none;
    color: white;
}

.tiptap-modal-footer .btn-primary:hover {
    opacity: 0.9;
}

.tiptap-modal-footer .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   Table Context Menu (for toolbar when in table)
   ========================================== */

.tiptap-table-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.tiptap-table-menu-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-right: 8px;
}

/* ==========================================
   Responsive
   ========================================== */

/* ==========================================
   Layout Blocks
   ========================================== */

.tiptap-content .layout-block {
    display: flex;
    gap: 16px;
    margin: 1em 0;
    padding: 8px;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    min-height: 80px;
}

.tiptap-content .layout-column {
    padding: 8px;
    background: var(--bg-app);
    border-radius: 4px;
    min-height: 60px;
}

.tiptap-content .layout-column > *:first-child {
    margin-top: 0;
}

.tiptap-content .layout-column > *:last-child {
    margin-bottom: 0;
}

/* Layout Dialog Options */
.layout-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.layout-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-app);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.layout-option:hover {
    border-color: var(--primary-color);
}

.layout-option.selected {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb, 79, 70, 229), 0.1);
}

.layout-option span {
    font-size: 12px;
    color: var(--text-secondary);
}

.layout-preview {
    display: flex;
    gap: 4px;
    width: 100%;
    height: 40px;
}

.layout-preview > div {
    background: var(--border-color);
    border-radius: 2px;
}

.layout-50-50 > div { flex: 1; }
.layout-70-30 > div:first-child { flex: 7; }
.layout-70-30 > div:last-child { flex: 3; }
.layout-30-70 > div:first-child { flex: 3; }
.layout-30-70 > div:last-child { flex: 7; }
.layout-33-33-33 > div { flex: 1; }

/* ==========================================
   Table of Contents
   ========================================== */

.tiptap-content .table-of-contents {
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 1em 0;
}

.tiptap-content .table-of-contents .toc-placeholder {
    color: var(--text-tertiary);
    font-style: italic;
    margin: 0;
}

.tiptap-content .table-of-contents .toc-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tiptap-content .table-of-contents .toc-list {
    list-style: none !important;
    padding: 0;
    margin: 0;
}

.tiptap-content .table-of-contents .toc-item {
    display: block !important;
    margin: 4px 0;
}

.tiptap-content .table-of-contents .toc-item a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.tiptap-content .table-of-contents .toc-item a:hover {
    background: var(--bg-surface-hover, rgba(255,255,255,0.1));
    color: var(--primary-color);
}

.tiptap-content .table-of-contents .toc-level-1 { padding-left: 0; }
.tiptap-content .table-of-contents .toc-level-2 { padding-left: 16px; }
.tiptap-content .table-of-contents .toc-level-3 { padding-left: 32px; }
.tiptap-content .table-of-contents .toc-level-4 { padding-left: 48px; }
.tiptap-content .table-of-contents .toc-level-5 { padding-left: 64px; }
.tiptap-content .table-of-contents .toc-level-6 { padding-left: 80px; }

/* ==========================================
   File Attachments
   ========================================== */

.tiptap-content .file-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 1em 0;
    cursor: default;
}

.tiptap-content .file-attachment-icon {
    font-size: 24px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.tiptap-content .file-attachment-info {
    flex: 1;
    min-width: 0;
}

.tiptap-content .file-attachment-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tiptap-content .file-attachment-size {
    font-size: 12px;
    color: var(--text-tertiary);
}

.tiptap-content .file-attachment-download,
.tiptap-content .file-attachment-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.tiptap-content .file-attachment-download {
    background: var(--primary-color);
    color: white;
}

.tiptap-content .file-attachment-download:hover {
    opacity: 0.85;
}

.tiptap-content .file-attachment-delete {
    background: transparent;
    color: var(--text-tertiary);
}

.tiptap-content .file-attachment-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Attachment Preview in Dialog */
.attachment-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-app);
    border-radius: 6px;
    margin-top: 12px;
}

.attachment-preview i {
    font-size: 20px;
    color: var(--primary-color);
}

.attachment-preview span {
    color: var(--text-primary);
}

.attachment-preview .attachment-size {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ==========================================
   Find & Replace Panel
   ========================================== */

.tiptap-find-replace-panel {
    background: var(--bg-app);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
}

.find-replace-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.find-replace-row:last-child {
    margin-bottom: 0;
}

.find-input-group {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.find-input-group:focus-within {
    border-color: var(--primary-color);
}

.find-input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.find-count {
    padding: 0 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.tiptap-find-replace-panel button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 4px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
}

.tiptap-find-replace-panel button:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.tiptap-find-replace-panel button.is-active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tiptap-find-replace-panel button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Search highlight styling */
.search-highlight {
    background: rgba(255, 255, 0, 0.3);
}

.search-highlight-current {
    background: rgba(255, 165, 0, 0.5);
    outline: 2px solid orange;
}

/* ==========================================
   Import/Export Button Styles
   ========================================== */

.tiptap-toolbar .import-btn i {
    color: #22c55e;
}

.tiptap-toolbar .export-pdf-btn i {
    color: #ef4444;
}

.tiptap-toolbar .export-docx-btn i {
    color: #3b82f6;
}

.tiptap-toolbar .import-btn:hover,
.tiptap-toolbar .export-pdf-btn:hover,
.tiptap-toolbar .export-docx-btn:hover {
    background: var(--bg-surface-hover, rgba(255, 255, 255, 0.1));
}

/* ==========================================
   Import Dialog
   ========================================== */

.import-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(2px);
}

.import-dialog {
    background: var(--bg-surface, #1f2937);
    border: 1px solid var(--border-color, #374151);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    min-width: 400px;
    max-width: 90%;
    overflow: hidden;
}

.import-dialog-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #374151);
}

.import-dialog-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
}

.import-dialog-body {
    padding: 20px;
}

.import-dialog-body p {
    margin: 0;
    color: var(--text-secondary, #d1d5db);
    font-size: 14px;
    line-height: 1.5;
}

.import-dialog-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #374151);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.import-dialog-footer button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.import-dialog-footer .btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color, #4b5563);
    color: var(--text-secondary, #d1d5db);
}

.import-dialog-footer .btn-cancel:hover {
    background: var(--bg-surface-hover, #374151);
}

.import-dialog-footer .btn-append {
    background: var(--bg-surface-hover, #374151);
    border: 1px solid var(--border-color, #4b5563);
    color: var(--text-primary, #f3f4f6);
}

.import-dialog-footer .btn-append:hover {
    background: #4b5563;
}

.import-dialog-footer .btn-replace {
    background: var(--primary-color, #4f46e5);
    border: 1px solid var(--primary-color, #4f46e5);
    color: #ffffff;
}

.import-dialog-footer .btn-replace:hover {
    background: #4338ca;
}

/* ==========================================
   Import Progress Overlay
   ========================================== */

.import-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    backdrop-filter: blur(4px);
}

.import-progress-content {
    background: var(--bg-surface, #1f2937);
    border: 1px solid var(--border-color, #374151);
    border-radius: 12px;
    padding: 32px 48px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.import-progress-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color, #374151);
    border-top-color: var(--primary-color, #4f46e5);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.import-progress-message {
    color: var(--text-secondary, #e5e7eb);
    font-size: 14px;
    font-weight: 500;
}

/* ==========================================
   Import Error Modal
   ========================================== */

.import-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    backdrop-filter: blur(4px);
}

.import-error-content {
    background: var(--bg-surface, #1f2937);
    border: 1px solid var(--border-color, #374151);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.import-error-icon {
    margin-bottom: 16px;
}

.import-error-title {
    color: var(--text-primary, #f3f4f6);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.import-error-message {
    color: var(--text-secondary, #d1d5db);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 24px;
}

.import-error-button {
    background: var(--primary-color, #4f46e5);
    color: white;
    border: none;
    padding: 10px 32px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.import-error-button:hover {
    background: #4338ca;
}

/* ==========================================
   Size Warning/Error Styles
   ========================================== */

.content-size-warning {
    background-color: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 8px;
}

.content-size-error {
    background-color: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 8px;
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 768px) {
    .tiptap-toolbar {
        padding: 6px 8px;
    }

    .tiptap-toolbar-group {
        padding-right: 6px;
        margin-right: 6px;
    }

    .tiptap-toolbar button {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .tiptap-toolbar select {
        min-width: 80px;
        font-size: 12px;
    }

    .tiptap-content {
        padding: 12px 14px;
        min-height: 250px;
    }

    .tiptap-modal {
        width: 95%;
        max-width: none;
    }

    .layout-options {
        grid-template-columns: 1fr;
    }

    .tiptap-content .layout-block {
        flex-direction: column;
    }

    .tiptap-content .layout-column {
        width: 100% !important;
        flex: none !important;
    }
}
