/**
 * Summernote Rich Text Editor Styles
 * Modern and beautiful WYSIWYG editor
 */

/* Editor Container */
.tiptap-editor,
#editor {
    min-height: 500px;
}

/* Summernote Custom Styling */
.note-editor {
    border: 2px solid var(--gray-200, #E5E7EB) !important;
    border-radius: 8px !important;
}

.note-editor.note-frame {
    border-radius: 8px !important;
}

.note-toolbar {
    background: var(--gray-50, #F9FAFB) !important;
    border-bottom: 1px solid var(--gray-200, #E5E7EB) !important;
    border-radius: 8px 8px 0 0 !important;
    padding: 10px !important;
}

.note-btn-group .note-btn {
    background: white !important;
    border-color: var(--gray-200, #E5E7EB) !important;
    color: var(--gray-700, #374151) !important;
}

.note-btn-group .note-btn:hover {
    background: var(--gray-200, #E5E7EB) !important;
}

.note-btn-group .note-btn.active,
.note-btn-group .note-btn:active {
    background: var(--brand-primary, #6366F1) !important;
    border-color: var(--brand-primary, #6366F1) !important;
    color: white !important;
}

.note-editable {
    min-height: 400px !important;
    padding: 1.5rem !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 16px !important;
    line-height: 1.6 !important;
    background: white !important;
}

.note-editable:focus {
    border-color: var(--brand-primary, #6366F1) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* Image styling */
.note-editable img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Table styling */
.note-editable table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.note-editable table td,
.note-editable table th {
    border: 1px solid var(--gray-300, #D1D5DB);
    padding: 0.5rem;
}

.note-editable table th {
    background: var(--gray-50, #F9FAFB);
    font-weight: 600;
}

/* Links */
.note-editable a {
    color: var(--brand-primary, #6366F1);
    text-decoration: underline;
}

/* Blockquote */
.note-editable blockquote {
    border-left: 4px solid var(--brand-primary, #6366F1);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--gray-700, #374151);
    font-style: italic;
}

.editor-toolbar-group {
    display: flex;
    gap: 2px;
    padding: 0 4px;
    border-right: 1px solid var(--gray-300, #D1D5DB);
}

.editor-toolbar-group:last-child {
    border-right: none;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--gray-600, #4B5563);
    font-size: 16px;
    font-weight: 600;
}

.toolbar-btn:hover {
    background: var(--gray-100, #F3F4F6);
    color: var(--gray-900, #111827);
}

.toolbar-btn.is-active {
    background: var(--brand-primary, #6366F1);
    color: white;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--gray-300, #D1D5DB);
    margin: 0 4px;
}

/* Tiptap Content Styles */
.tiptap-editor .ProseMirror {
    outline: none;
    min-height: 350px;
}

.tiptap-editor .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: var(--gray-400, #9CA3AF);
    pointer-events: none;
    height: 0;
}

/* Typography */
.tiptap-editor h1 {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.2;
    margin: 1.5rem 0 1rem;
    color: var(--gray-900, #111827);
}

.tiptap-editor h2 {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 1.25rem 0 0.875rem;
    color: var(--gray-900, #111827);
}

.tiptap-editor h3 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 1rem 0 0.75rem;
    color: var(--gray-800, #1F2937);
}

.tiptap-editor h4 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.5;
    margin: 0.875rem 0 0.625rem;
    color: var(--gray-800, #1F2937);
}

.tiptap-editor p {
    margin: 0.75rem 0;
}

.tiptap-editor strong {
    font-weight: 700;
    color: var(--gray-900, #111827);
}

.tiptap-editor em {
    font-style: italic;
}

.tiptap-editor u {
    text-decoration: underline;
}

.tiptap-editor s {
    text-decoration: line-through;
}

.tiptap-editor code {
    background: var(--gray-100, #F3F4F6);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
    color: var(--gray-800, #1F2937);
}

.tiptap-editor pre {
    background: var(--gray-900, #111827);
    color: var(--gray-100, #F3F4F6);
    font-family: 'JetBrains Mono', monospace;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.tiptap-editor pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 0.875rem;
}

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

.tiptap-editor ul {
    list-style-type: disc;
}

.tiptap-editor ol {
    list-style-type: decimal;
}

.tiptap-editor li {
    margin: 0.5rem 0;
}

.tiptap-editor li p {
    margin: 0.25rem 0;
}

/* Blockquote */
.tiptap-editor blockquote {
    border-left: 4px solid var(--brand-primary, #6366F1);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--gray-700, #374151);
    font-style: italic;
    background: var(--gray-50, #F9FAFB);
    padding: 1rem 1.5rem;
    border-radius: 0 8px 8px 0;
}

/* Horizontal Rule */
.tiptap-editor hr {
    border: none;
    border-top: 2px solid var(--gray-200, #E5E7EB);
    margin: 2rem 0;
}

/* Links */
.tiptap-editor a {
    color: var(--brand-primary, #6366F1);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.tiptap-editor a:hover {
    color: var(--brand-secondary, #8B5CF6);
}

/* Images */
.tiptap-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tiptap-editor img.ProseMirror-selectednode {
    outline: 3px solid var(--brand-primary, #6366F1);
    outline-offset: 2px;
}

/* Highlight */
.tiptap-editor mark {
    background-color: #FEF08A;
    padding: 2px 4px;
    border-radius: 3px;
    color: var(--gray-900, #111827);
}

/* Text Alignment */
.tiptap-editor [style*="text-align: left"] {
    text-align: left;
}

.tiptap-editor [style*="text-align: center"] {
    text-align: center;
}

.tiptap-editor [style*="text-align: right"] {
    text-align: right;
}

.tiptap-editor [style*="text-align: justify"] {
    text-align: justify;
}

/* Image Upload Button */
.image-upload-btn {
    position: relative;
    overflow: hidden;
}

.image-upload-btn input[type="file"] {
    position: absolute;
    left: -9999px;
}

/* Loading Indicator */
.editor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--gray-500, #6B7280);
}

.editor-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    margin-left: 0.5rem;
    border: 3px solid var(--gray-200, #E5E7EB);
    border-top-color: var(--brand-primary, #6366F1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Image Upload Modal */
.image-modal {
    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;
    animation: fadeIn 0.2s;
}

.image-modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.image-modal h3 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    color: var(--gray-900, #111827);
}

.image-modal-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-200, #E5E7EB);
}

.image-modal-tab {
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-600, #4B5563);
    transition: all 0.2s;
}

.image-modal-tab.active {
    color: var(--brand-primary, #6366F1);
    border-bottom-color: var(--brand-primary, #6366F1);
}

.image-modal-body {
    margin-bottom: 1.5rem;
}

.image-upload-zone {
    border: 2px dashed var(--gray-300, #D1D5DB);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.image-upload-zone:hover {
    border-color: var(--brand-primary, #6366F1);
    background: var(--gray-50, #F9FAFB);
}

.image-upload-zone.dragover {
    border-color: var(--brand-primary, #6366F1);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--gray-400, #9CA3AF);
}

.image-url-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-200, #E5E7EB);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.image-url-input:focus {
    outline: none;
    border-color: var(--brand-primary, #6366F1);
}

.image-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.editor-help {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600, #4B5563);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .editor-toolbar {
        gap: 2px;
        padding: 6px;
    }
    
    .toolbar-btn {
        width: 32px;
        height: 32px;
    }
    
    .tiptap-editor {
        padding: 1rem;
        min-height: 300px;
    }
}
