/**
 * Tiptap Editor Styles
 * Styling for the Tiptap rich text editor components
 */

/* Editor Wrapper */
.tiptap-editor-wrapper {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #fff;
    overflow: hidden;
}

/* Toolbar */
.tiptap-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 0.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.tiptap-toolbar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 0.25rem;
    background: transparent;
    color: #495057;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.tiptap-toolbar-button:hover {
    background: #e9ecef;
    color: #212529;
}

.tiptap-toolbar-button.is-active {
    background: #0d6efd;
    color: #fff;
}

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

.tiptap-toolbar-button i {
    font-size: 1rem;
}

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

/* Editor Area */
.tiptap-editor-area {
    padding: 1rem;
    overflow-y: auto;
}

/* Tiptap Content Styles */
.tiptap-content {
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #212529;
}

.tiptap-content:focus {
    outline: none;
}

/* Typography */
.tiptap-content p {
    margin: 0 0 1rem 0;
}

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

.tiptap-content h1,
.tiptap-content h2,
.tiptap-content h3,
.tiptap-content h4,
.tiptap-content h5,
.tiptap-content h6 {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    line-height: 1.2;
}

.tiptap-content h1 { font-size: 2rem; }
.tiptap-content h2 { font-size: 1.5rem; }
.tiptap-content h3 { font-size: 1.25rem; }
.tiptap-content h4 { font-size: 1rem; }

/* Lists */
.tiptap-content ul,
.tiptap-content ol {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
}

.tiptap-content li {
    margin-bottom: 0.25rem;
}

.tiptap-content li p {
    margin: 0;
}

/* Links */
.tiptap-content a {
    color: #0d6efd;
    text-decoration: underline;
}

.tiptap-content a:hover {
    color: #0a58ca;
}

/* Code */
.tiptap-content code {
    background: #f8f9fa;
    border-radius: 0.25rem;
    padding: 0.125rem 0.25rem;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875em;
    color: #d63384;
}

.tiptap-content pre {
    background: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1rem;
    overflow-x: auto;
    margin: 0 0 1rem 0;
}

.tiptap-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Blockquote */
.tiptap-content blockquote {
    border-left: 4px solid #dee2e6;
    margin: 0 0 1rem 0;
    padding-left: 1rem;
    color: #6c757d;
}

/* Images */
.tiptap-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

/* Tables */
.tiptap-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 1rem 0;
}

.tiptap-content th,
.tiptap-content td {
    border: 1px solid #dee2e6;
    padding: 0.5rem;
    text-align: left;
}

.tiptap-content th {
    background: #f8f9fa;
    font-weight: 600;
}

/* Highlight */
.tiptap-content mark {
    background: #fff3cd;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
}

/* Horizontal Rule */
.tiptap-content hr {
    border: none;
    border-top: 2px solid #dee2e6;
    margin: 1rem 0;
}

/* Text Alignment */
.tiptap-content .text-left { text-align: left; }
.tiptap-content .text-center { text-align: center; }
.tiptap-content .text-right { text-align: right; }
.tiptap-content .text-justify { text-align: justify; }

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

/* Selection */
.tiptap-content ::selection {
    background: #b4d5fe;
}

/* Focus state for wrapper */
.tiptap-editor-wrapper:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Compact Editor Variant */
.tiptap-editor-wrapper.tiptap-compact .tiptap-toolbar {
    padding: 0.375rem;
}

.tiptap-editor-wrapper.tiptap-compact .tiptap-toolbar-button {
    width: 28px;
    height: 28px;
}

.tiptap-editor-wrapper.tiptap-compact .tiptap-editor-area {
    padding: 0.75rem;
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .tiptap-editor-wrapper {
        background: #212529;
        border-color: #495057;
    }

    .tiptap-toolbar {
        background: #343a40;
        border-color: #495057;
    }

    .tiptap-toolbar-button {
        color: #adb5bd;
    }

    .tiptap-toolbar-button:hover {
        background: #495057;
        color: #f8f9fa;
    }

    .tiptap-toolbar-separator {
        background: #495057;
    }

    .tiptap-content {
        color: #f8f9fa;
    }

    .tiptap-content code {
        background: #343a40;
        color: #e685b5;
    }

    .tiptap-content pre {
        background: #343a40;
    }

    .tiptap-content th {
        background: #343a40;
    }

    .tiptap-content th,
    .tiptap-content td {
        border-color: #495057;
    }
}

/* Modal z-index handling */
.modal .tiptap-editor-wrapper {
    position: relative;
    z-index: 1;
}

/* Tailwind modal compatibility */
.tw-modal .tiptap-editor-wrapper {
    position: relative;
    z-index: 1;
}

/* Print styles */
@media print {
    .tiptap-toolbar {
        display: none;
    }

    .tiptap-editor-wrapper {
        border: none;
        box-shadow: none;
    }
}
