/* Online Text Editor Styles */

/* Quill Editor Customizations */
.ql-editor {
    min-height: 400px;
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 16px;
    line-height: 1.6;
    color: #374151;
}

.ql-editor.ql-blank::before {
    color: #9ca3af;
    font-style: normal;
    font-size: 16px;
    left: 24px;
    right: 24px;
}

/* Toolbar Customizations */
.ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid #e5e7eb;
    padding: 16px 24px;
    background: #fafafa;
    border-radius: 0;
}

.ql-toolbar .ql-formats {
    margin-right: 16px;
}

.ql-toolbar .ql-picker-label {
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.ql-toolbar .ql-picker-label:hover {
    background: #e5e7eb;
}

.ql-toolbar button {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    margin: 0 1px;
    transition: all 0.2s;
}

.ql-toolbar button:hover {
    background: #e5e7eb;
}

.ql-toolbar button.ql-active {
    background: #3b82f6;
    color: white;
}

/* Container Customizations */
.ql-container.ql-snow {
    border: none;
    font-family: inherit;
}

/* Editor Content Area */
#quillEditor {
    border-radius: 0;
    background: white;
}

#quillEditor .ql-editor {
    padding: 24px;
}

/* Split View Styles */
#editorContainer.grid {
    grid-template-columns: 1fr 1fr;
}

#editorContainer.grid #previewPane {
    border-left: 1px solid #e5e7eb;
}

/* Preview Pane Styles */
#previewPane {
    background: white;
    overflow-y: auto;
}

#previewContent {
    font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
    line-height: 1.6;
    color: #374151;
}

#previewContent h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #111827;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

#previewContent h2 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #1f2937;
}

#previewContent h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #374151;
}

#previewContent h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #4b5563;
}

#previewContent h5 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #6b7280;
}

#previewContent h6 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #9ca3af;
}

#previewContent p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

#previewContent blockquote {
    border-left: 4px solid #e5e7eb;
    margin: 1.5rem 0;
    padding-left: 1rem;
    color: #6b7280;
    font-style: italic;
}

#previewContent code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, "Cascadia Code", "Roboto Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    color: #dc2626;
}

#previewContent pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

#previewContent pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

#previewContent ul,
#previewContent ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

#previewContent li {
    margin: 0.5rem 0;
}

#previewContent a {
    color: #3b82f6;
    text-decoration: underline;
    transition: color 0.2s;
}

#previewContent a:hover {
    color: #1d4ed8;
}

#previewContent img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#previewContent table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
}

#previewContent th,
#previewContent td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

#previewContent th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

#previewContent tr:hover {
    background: #f9fafb;
}

/* Responsive Design */
@media (max-width: 1024px) {
    #editorContainer.grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    #editorContainer.grid #previewPane {
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }
}

@media (max-width: 768px) {
    .ql-toolbar.ql-snow {
        padding: 12px 16px;
    }

    .ql-toolbar .ql-formats {
        margin-right: 8px;
        margin-bottom: 8px;
    }

    #quillEditor .ql-editor {
        padding: 16px;
        min-height: 300px;
        font-size: 14px;
    }

    #previewPane {
        padding: 16px;
    }

    #previewContent h1 {
        font-size: 1.875rem;
    }

    #previewContent h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 640px) {
    .ql-toolbar.ql-snow {
        padding: 8px;
        flex-wrap: wrap;
    }

    .ql-toolbar .ql-formats {
        margin-right: 4px;
        margin-bottom: 4px;
    }

    .ql-toolbar button {
        width: 28px;
        height: 28px;
    }

    #quillEditor .ql-editor {
        padding: 12px;
        min-height: 250px;
        font-size: 14px;
    }

    .ql-editor.ql-blank::before {
        left: 12px;
        right: 12px;
        font-size: 14px;
    }
}

/* Menu Animations */
#importMenu,
#exportMenu,
#viewMenu {
    transform: translateY(-8px);
    opacity: 0;
    transition: all 0.2s ease-out;
}

#importMenu:not(.hidden),
#exportMenu:not(.hidden),
#viewMenu:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
}

/* Scroll Enhancements */
#previewPane,
.ql-editor {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

#previewPane::-webkit-scrollbar,
.ql-editor::-webkit-scrollbar {
    width: 6px;
}

#previewPane::-webkit-scrollbar-track,
.ql-editor::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#previewPane::-webkit-scrollbar-thumb,
.ql-editor::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#previewPane::-webkit-scrollbar-thumb:hover,
.ql-editor::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Focus States */
.ql-editor:focus {
    outline: none;
}

.ql-toolbar button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .ql-toolbar,
    #saveStatus,
    .flex.flex-wrap,
    .bg-gray-50 {
        display: none !important;
    }

    .ql-container {
        border: none;
    }

    .ql-editor {
        padding: 0;
        font-size: 12pt;
        line-height: 1.5;
    }
}

/* Loading States */
.editor-loading {
    opacity: 0.6;
    pointer-events: none;
}

.editor-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Custom Formula Styles */
.ql-formula {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 2px;
    display: inline-block;
}

/* Custom Video Embed Styles */
.ql-video {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

/* Accessibility Improvements */
.ql-toolbar button[title],
.ql-picker-label[title] {
    position: relative;
}

.ql-toolbar button:focus-visible,
.ql-picker-label:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .ql-editor {
        color: #000000;
    }

    .ql-toolbar button {
        border: 1px solid #000000;
    }

    .ql-toolbar button.ql-active {
        background: #000000;
        color: #ffffff;
    }
}
