/* WYSIWYG Editor Styles */

/* Editor Toolbar */
.wysiwyg-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 0.5rem;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.5rem;
    border-right: 1px solid rgba(75, 85, 99, 0.5);
}

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

/* Toolbar Buttons */
.toolbar-btn {
    background: none;
    border: none;
    color: #9CA3AF;
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    position: relative;
}

.toolbar-btn:hover {
    background: rgba(55, 65, 81, 0.8);
    color: #E5E7EB;
}

.toolbar-btn:active,
.toolbar-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60A5FA;
}

/* Color Picker Buttons */
.color-btn {
    position: relative;
    overflow: hidden;
}

.color-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Toolbar Select */
.toolbar-select {
    background: rgba(31, 41, 55, 0.8);
    border: 1px solid rgba(75, 85, 99, 0.5);
    color: #9CA3AF;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    height: 2rem;
}

.toolbar-select:hover {
    border-color: rgba(107, 114, 128, 0.8);
    color: #E5E7EB;
}

/* Editor Content Area */
.wysiwyg-editor {
    background: rgba(17, 24, 39, 0.95);
    color: #E5E7EB;
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 1rem;
    min-height: 300px;
    outline: none;
    overflow-y: auto;
}

.wysiwyg-editor:focus {
    outline: none;
}

/* Editor placeholder */
.editor-placeholder {
    color: rgba(156, 163, 175, 0.6);
    font-style: italic;
}

/* Editor content styling */
.wysiwyg-editor p {
    margin-bottom: 0.75rem;
}

.wysiwyg-editor ul,
.wysiwyg-editor ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.wysiwyg-editor li {
    margin-bottom: 0.25rem;
}

.wysiwyg-editor strong {
    font-weight: 600;
    color: #F3F4F6;
}

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

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

/* Highlighted text */
.wysiwyg-editor mark {
    background-color: rgba(251, 191, 36, 0.3);
    color: inherit;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
}

/* Twinkle Popup */
.twinkle-popup {
    position: absolute;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.twinkle-popup.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.twinkle-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.9) 0%, rgba(59, 130, 246, 0.9) 100%);
    border: 1px solid rgba(139, 92, 246, 0.5);
    color: white;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
    transition: all 0.2s;
}

.twinkle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.twinkle-btn i {
    font-size: 1rem;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(0.95); }
}

/* AI Context Menu */
.ai-context-menu {
    position: absolute;
    background: rgba(31, 41, 55, 0.98);
    border: 1px solid rgba(75, 85, 99, 0.8);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    min-width: 200px;
    backdrop-filter: blur(10px);
}

.context-menu-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(75, 85, 99, 0.5);
    font-weight: 600;
    color: #E5E7EB;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

.context-menu-items {
    padding: 0.5rem;
}

.context-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    color: #D1D5DB;
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s;
    text-align: left;
}

.context-menu-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #60A5FA;
}

.context-menu-item i {
    width: 1.25rem;
    text-align: center;
}

/* Custom scrollbar for editor */
.wysiwyg-editor::-webkit-scrollbar {
    width: 10px;
}

.wysiwyg-editor::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.5);
    border-radius: 5px;
}

.wysiwyg-editor::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.8);
    border-radius: 5px;
}

.wysiwyg-editor::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.8);
}

/* Firefox scrollbar */
.wysiwyg-editor {
    scrollbar-width: thin;
    scrollbar-color: rgba(75, 85, 99, 0.8) rgba(31, 41, 55, 0.5);
}

/* Selection styling */
.wysiwyg-editor::selection {
    background: rgba(59, 130, 246, 0.3);
    color: #F3F4F6;
}

.wysiwyg-editor ::-moz-selection {
    background: rgba(59, 130, 246, 0.3);
    color: #F3F4F6;
}

/* Ensure proper text contrast */
.wysiwyg-editor h1,
.wysiwyg-editor h2,
.wysiwyg-editor h3,
.wysiwyg-editor h4,
.wysiwyg-editor h5,
.wysiwyg-editor h6 {
    color: #F9FAFB;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.wysiwyg-editor h1 { font-size: 1.5rem; }
.wysiwyg-editor h2 { font-size: 1.25rem; }
.wysiwyg-editor h3 { font-size: 1.125rem; }
.wysiwyg-editor h4 { font-size: 1rem; }
.wysiwyg-editor h5 { font-size: 0.875rem; }
.wysiwyg-editor h6 { font-size: 0.75rem; }

/* Links in editor */
.wysiwyg-editor a {
    color: #60A5FA;
    text-decoration: underline;
}

.wysiwyg-editor a:hover {
    color: #93BBFC;
}

/* Blockquote styling */
.wysiwyg-editor blockquote {
    border-left: 3px solid rgba(59, 130, 246, 0.5);
    padding-left: 1rem;
    margin-left: 0;
    color: rgba(209, 213, 219, 0.9);
    font-style: italic;
}

/* Code styling */
.wysiwyg-editor code {
    background: rgba(55, 65, 81, 0.5);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875em;
}

/* Pre-formatted text */
.wysiwyg-editor pre {
    background: rgba(31, 41, 55, 0.8);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 0.375rem;
    padding: 0.75rem;
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.wysiwyg-editor pre code {
    background: none;
    padding: 0;
}