/* Tiptap Editor Styles */

.tiptap-toolbar {
    border: 1px solid #dee2e6;
    border-bottom: none;
    background-color: #f8f9fa;
    padding: 8px;
    border-radius: 0.25rem 0.25rem 0 0;
}

.tiptap-toolbar .btn {
    padding: 4px 8px;
}

.tiptap-toolbar .btn.active {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.tiptap-editor-container {
    border: 1px solid #dee2e6;
    border-radius: 0 0 0.25rem 0.25rem;
    background-color: white;
}

/* Tiptap content styles */
.tiptap-content {
    outline: none;
    border: none !important;
    box-shadow: none !important;
}

.tiptap-content:focus {
    outline: none;
    border: none !important;
    box-shadow: none !important;
}

/* Prosemirror specific styles */
.ProseMirror {
    min-height: 300px;
    padding: 12px;
}

.ProseMirror:focus {
    outline: none;
}

.ProseMirror > * + * {
    margin-top: 0.75em;
}

.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3 {
    line-height: 1.2;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.ProseMirror h1 {
    font-size: 2rem;
}

.ProseMirror h2 {
    font-size: 1.5rem;
}

.ProseMirror h3 {
    font-size: 1.25rem;
}

.ProseMirror ul,
.ProseMirror ol {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.ProseMirror ul {
    list-style-type: disc;
}

.ProseMirror ol {
    list-style-type: decimal;
}

.ProseMirror li {
    margin-bottom: 0.25rem;
}

.ProseMirror li p {
    margin: 0;
}

.ProseMirror blockquote {
    border-left: 4px solid #dee2e6;
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    font-style: italic;
    color: #6c757d;
}

.ProseMirror hr {
    border: none;
    border-top: 2px solid #dee2e6;
    margin: 2rem 0;
}

.ProseMirror code {
    background-color: #f8f9fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Courier New', Courier, monospace;
}

.ProseMirror pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.25rem;
    overflow-x: auto;
}

.ProseMirror pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
}

/* Placeholder */
.ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: #adb5bd;
    pointer-events: none;
    height: 0;
}

/* Strong/Bold */
.ProseMirror strong {
    font-weight: 600;
}

/* Italic */
.ProseMirror em {
    font-style: italic;
}

/* Selection */
.ProseMirror ::selection {
    background-color: rgba(13, 110, 253, 0.2);
}

/* Links */
.ProseMirror a.tiptap-link {
    color: #0d6efd;
    text-decoration: underline;
    cursor: pointer;
}

.ProseMirror a.tiptap-link:hover {
    color: #0a58ca;
}

/* Highlight/Mark */
.ProseMirror mark {
    background-color: #fff3cd;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Tables */
.ProseMirror table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    margin: 1rem 0;
    overflow: hidden;
}

.ProseMirror table td,
.ProseMirror table th {
    min-width: 1em;
    border: 1px solid #dee2e6;
    padding: 0.5rem;
    vertical-align: top;
    box-sizing: border-box;
    position: relative;
}

.ProseMirror table th {
    font-weight: bold;
    text-align: left;
    background-color: #f8f9fa;
}

.ProseMirror table .selectedCell {
    background-color: #e7f3ff;
}

.ProseMirror table .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: -2px;
    width: 4px;
    background-color: #0d6efd;
    pointer-events: none;
}

/* Text alignment */
.ProseMirror [style*="text-align: left"] {
    text-align: left;
}

.ProseMirror [style*="text-align: center"] {
    text-align: center;
}

.ProseMirror [style*="text-align: right"] {
    text-align: right;
}

.ProseMirror [style*="text-align: justify"] {
    text-align: justify;
}

/* Disabled toolbar buttons */
.tiptap-toolbar .btn.disabled,
.tiptap-toolbar .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Character count */
#tiptap-character-count {
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    background-color: #f8f9fa;
}

/* Full-Screen Mode */
.tiptap-fullscreen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background-color: white;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.tiptap-fullscreen-wrapper .tiptap-toolbar {
    flex-shrink: 0;
}

.tiptap-fullscreen-wrapper .tiptap-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

.tiptap-fullscreen-wrapper .ProseMirror {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.tiptap-fullscreen-wrapper #tiptap-character-count {
    flex-shrink: 0;
    border-radius: 0;
}

/* Full-screen exit hint */
.tiptap-fullscreen-hint {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    z-index: 10000;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* Focus Mode */
.tiptap-focus-mode .tiptap-toolbar {
    opacity: 0.1;
    transition: opacity 0.3s ease;
}

.tiptap-focus-mode .tiptap-toolbar:hover,
.tiptap-focus-mode .tiptap-toolbar:focus-within {
    opacity: 1;
}

/* Focus mode hint bar */
.tiptap-focus-mode-hint {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to bottom, rgba(13, 110, 253, 0.3), transparent);
    pointer-events: none;
    z-index: 10;
}

.tiptap-focus-mode #tiptap-character-count {
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.tiptap-focus-mode #tiptap-character-count:hover {
    opacity: 1;
}

/* Print Preview Modal */
.tiptap-print-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.tiptap-print-preview-modal {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.tiptap-print-preview-header {
    padding: 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tiptap-print-preview-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.tiptap-print-preview-actions {
    display: flex;
    gap: 0.5rem;
}

.tiptap-print-preview-content {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    background-color: #f8f9fa;
}

.tiptap-print-preview-paper {
    background-color: white;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 11in;
    max-width: 8.5in;
    margin: 0 auto;
}

/* Print styles for preview content */
.tiptap-print-preview-paper h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.tiptap-print-preview-paper h2 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.tiptap-print-preview-paper h3 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.tiptap-print-preview-paper p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.tiptap-print-preview-paper ul,
.tiptap-print-preview-paper ol {
    margin-bottom: 1rem;
}

.tiptap-print-preview-paper table {
    width: 100%;
    margin-bottom: 1rem;
}

/* Print media query for actual printing */
@media print {
    .tiptap-print-preview-header,
    .tiptap-print-preview-actions {
        display: none !important;
    }

    .tiptap-print-preview-content {
        padding: 0;
        background-color: white;
    }

    .tiptap-print-preview-paper {
        box-shadow: none;
        padding: 0;
    }
}

/* Button states for mode toggles */
.tiptap-toolbar .btn-mode-active {
    background-color: #198754;
    border-color: #198754;
    color: white;
}

.tiptap-toolbar .btn-mode-active:hover {
    background-color: #157347;
    border-color: #146c43;
}
