/**
 * TipTap Editor & AI Text Rewriting Styles
 *
 * Styling for tone-of-voice selection bubble menu and diff comparison modal.
 */

/* ====== TipTap Editor Base Styles ====== */
.tiptap-editor-container {
    min-height: 400px;
    background: var(--bg-card);
    border-radius: 4px;
}

.ProseMirror {
    min-height: 400px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--transition-base);
}

.ProseMirror:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.ProseMirror p {
    margin-bottom: 1rem;
}

.ProseMirror h1, .ProseMirror h2, .ProseMirror h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.ProseMirror h1 { font-size: 1.8rem; }
.ProseMirror h2 { font-size: 1.5rem; }
.ProseMirror h3 { font-size: 1.25rem; }

.ProseMirror ul, .ProseMirror ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.ProseMirror li {
    margin-bottom: 0.5rem;
}

.ProseMirror strong {
    font-weight: 600;
}

.ProseMirror em {
    font-style: italic;
}

.ProseMirror code {
    background: var(--bg-secondary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.ProseMirror pre {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

/* Selection highlight */
.ProseMirror ::selection {
    background: rgba(22, 163, 74, 0.2);
}

/* Highlight mark (for accepted changes) */
.ProseMirror mark {
    background-color: rgba(144, 238, 144, 0.3);
    padding: 0.1em 0;
    border-radius: 2px;
    transition: background-color 2s ease-out;
}

/* ====== Bubble Menu Styles ====== */
/* ====== Bubble Menu Container ====== */
.tone-bubble-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.05);
    padding: 0.5rem;
    max-width: 600px;
    z-index: 1000;
    animation: bubbleMenuFadeIn 0.15s ease-out;
    backdrop-filter: blur(12px);
}

body > .tone-bubble-menu {
    position: fixed;
    top: -9999px;
    left: -9999px;
}

@keyframes bubbleMenuFadeIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ====== Pill Layout ====== */
.tone-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

.tone-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 100px;
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    font-size: 0.72rem;
    font-family: inherit;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all 0.15s ease;
    user-select: none;
}

.tone-pill:hover {
    background: rgba(22, 163, 74, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.15);
}

.tone-pill:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Custom pill - indigo accent */
.tone-pill--custom {
    border-color: rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.08);
}

.tone-pill--custom:hover {
    border-color: #818cf8;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* Utility pills (image, forbidden) */
.tone-pill--secondary {
    border-color: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    padding: 0.35rem 0.5rem;
}

.tone-pill--secondary:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
    color: var(--text-primary);
    box-shadow: none;
}

.tone-pill--danger {
    border-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 0.35rem 0.5rem;
}

.tone-pill--danger:hover {
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.08);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.15);
}

/* Close bubble menu button */
.tone-pill--close {
    border-color: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    padding: 0.35rem 0.5rem;
    margin-left: auto;
    font-size: 0.85rem;
    line-height: 1;
}

.tone-pill--close:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: var(--text-primary);
    box-shadow: none;
}

/* Submit button */
.tone-pill--submit {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    font-weight: 600;
    padding: 0.35rem 0.8rem;
}

.tone-pill--submit:hover {
    background: var(--accent-hover, #15803d);
    color: #fff;
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.3);
    transform: translateY(-1px);
}

/* Visual divider between tone pills and utility pills */
.tone-pill-divider {
    width: 1px;
    height: 1rem;
    background: rgba(255,255,255,0.1);
    margin: 0 0.15rem;
    flex-shrink: 0;
}

/* ====== LLM Model Selection Row ====== */
.llm-model-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
    padding: 0.4rem 0.5rem;
    background: rgba(99, 102, 241, 0.04);
    border-radius: 6px;
    align-items: center;
}

.llm-model-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.llm-model-select {
    flex: 1;
    padding: 0.35rem 0.6rem;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.llm-model-select:hover {
    border-color: rgba(99, 102, 241, 0.5);
}

.llm-model-select:focus {
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ====== Custom Instruction Row ====== */
.custom-instruction-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    align-items: center;
}

.custom-instruction-input {
    flex: 1;
    padding: 0.4rem 0.7rem;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.06);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.custom-instruction-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.custom-instruction-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
    font-size: 0.72rem;
}

/* ====== Diff Modal Styles ====== */
.diff-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.2s ease-out;
    backdrop-filter: blur(4px);
}

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

.diff-modal-content {
    background: var(--bg-card);
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.diff-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.diff-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.diff-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
}

.diff-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.diff-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.diff-text {
    padding: 1rem;
    border-radius: 4px;
    line-height: 1.6;
    font-size: 0.9rem;
    font-family: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.diff-text.original {
    background: rgba(220, 38, 38, 0.08);
    border-left: 3px solid #dc2626;
}

.diff-text.rewritten {
    background: rgba(16, 185, 129, 0.08);
    border-left: 3px solid #10b981;
}

/* Variant tabs */
.diff-variant-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
}

.diff-tab {
    padding: 0.4rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.diff-tab:hover {
    color: var(--text-primary, #111827);
}

.diff-tab.active {
    color: #10b981;
    border-bottom-color: #10b981;
    font-weight: 600;
}

.diff-variant-panel {
    display: none;
}

.diff-variant-panel.active {
    display: block;
}

.diff-variant-stats {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 0.4rem;
    padding: 0 0.25rem;
}

.diff-stats {
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1.5rem;
}

.diff-stats .stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.diff-custom-instruction {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 0.75rem;
}

.diff-custom-instruction label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.diff-custom-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    outline: none;
    transition: border-color 0.2s ease;
}

.diff-custom-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}

.diff-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem;
    justify-content: flex-end;
}

.diff-actions button {
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-family: inherit;
    border: none;
}

.btn-accept {
    background: var(--success-color);
    color: white;
}

.btn-accept:hover {
    background: #15803d;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-reject {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-reject:hover {
    background: var(--bg-secondary);
}

.btn-retry {
    background: var(--accent-primary);
    color: white;
}

.btn-retry:hover {
    background: #15803d;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

/* ====== Loading Overlay ====== */
#rewrite-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 3000;
    color: white;
    font-size: 1.1rem;
    backdrop-filter: blur(4px);
    animation: modalFadeIn 0.2s ease-out;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ====== Notification Styles ====== */
.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 4000;
    font-weight: 500;
    font-size: 0.9rem;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.success {
    background: var(--success-color);
    color: white;
}

.notification.error {
    background: var(--error-color);
    color: white;
}

.notification.info {
    background: var(--accent-secondary);
    color: white;
}

/* ====== Mobile Responsive ====== */
@media (max-width: 768px) {
    .tone-bubble-menu {
        max-width: 90vw;
    }

    .tone-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }

    .tone-btn {
        padding: 0.6rem 0.4rem;
        font-size: 0.8rem;
    }

    .tone-btn .icon {
        font-size: 1.3rem;
    }

    .diff-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .diff-comparison {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .diff-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .diff-actions button {
        width: 100%;
    }

    .notification {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

/* ====== Dark Mode Adjustments ====== */
[data-theme="dark"] .ProseMirror {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .tone-bubble-menu {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .diff-text.original {
    background: rgba(220, 38, 38, 0.15);
}

[data-theme="dark"] .diff-text.rewritten {
    background: rgba(16, 185, 129, 0.15);
}

[data-theme="dark"] .notification {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* ====== Floating Menu Styles (+ Button Next to Paragraphs) ====== */
.floating-menu-actions {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.floating-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.floating-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.floating-btn:active {
    transform: translateY(0);
}

/* ====== MenuBar Styles ====== */
.tiptap-menubar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    flex-wrap: wrap;
}

.menubar-group {
    display: flex;
    gap: 0.25rem;
}

.menubar-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

.menubar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.menubar-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.menubar-btn.is-active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.menubar-btn:active {
    transform: scale(0.95);
}

[data-theme="dark"] .menubar-btn {
    color: var(--text-primary);
}

[data-theme="dark"] .menubar-btn.is-active {
    background: var(--accent-primary);
    color: #0a0a0a;
}

/* ====== Word Counter Styles ====== */
.tiptap-word-counter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.counter-label {
    color: var(--text-muted);
}

.counter-value {
    color: var(--accent-primary);
    font-weight: 600;
    min-width: 3ch;
    text-align: right;
}

.counter-separator {
    color: var(--border-color);
}

/* ====== Placeholder Styles (Empty State Hint) ====== */
.ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
    height: 0;
    float: left;
}

/* ====== Link Styles ====== */
.ProseMirror .editor-link {
    color: var(--accent-primary);
    text-decoration: underline;
    cursor: pointer;
}

.ProseMirror .editor-link:hover {
    color: #15803d;
    text-decoration: none;
}

/* ====== Task List Styles (Checkboxes) ====== */
.ProseMirror ul[data-type="taskList"] {
    list-style: none;
    padding-left: 0;
}

.ProseMirror ul[data-type="taskList"] li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.ProseMirror ul[data-type="taskList"] li input[type="checkbox"] {
    margin-top: 0.4rem;
    cursor: pointer;
}

.ProseMirror ul[data-type="taskList"] li[data-checked="true"] > div {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ====== Table Styles ====== */
.ProseMirror table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    overflow: hidden;
}

.ProseMirror table td,
.ProseMirror table th {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.ProseMirror table th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.ProseMirror table .selectedCell {
    background: rgba(22, 163, 74, 0.1);
}

/* ====== Dark Mode Overrides ====== */
[data-theme="dark"] .floating-menu-actions {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .floating-btn:hover {
    background: var(--accent-primary);
    color: white;
}

[data-theme="dark"] .tiptap-word-counter {
    background: rgba(255, 255, 255, 0.05);
}

/* ====== Forbidden Words Button ====== */
.tone-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.75rem 0;
}

.forbidden-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #DC2626;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.forbidden-btn .icon {
    font-size: 16px;
}

.forbidden-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
    border-color: rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.forbidden-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .forbidden-btn {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.08) 100%);
    color: #F87171;
}

[data-theme="dark"] .forbidden-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(239, 68, 68, 0.15) 100%);
}

/* ====== Image Upload Section ====== */
.image-upload-section {
    margin-top: 0.3rem;
}

.image-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    width: 100%;
    padding: 0.3rem 0.4rem;
    font-size: 0.65rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    color: #2563EB;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-btn .icon {
    font-size: 12px;
}

.image-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.1) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.image-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .image-btn {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%);
    color: #60A5FA;
}

[data-theme="dark"] .image-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0.15) 100%);
}

.image-preview-container {
    position: relative;
    margin-top: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.image-preview {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    display: block;
    background: var(--bg-primary);
}

.remove-image-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.remove-image-btn:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.1);
}

.remove-image-btn:active {
    transform: scale(0.95);
}

/* ====== Save Status Indicator ====== */
.save-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin-top: 0.75rem;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.save-status-indicator .save-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.save-status-indicator.status-idle {
    background: rgba(22, 163, 74, 0.1);
    border: 1px solid rgba(22, 163, 74, 0.2);
    color: #059669;
}

.save-status-indicator.status-pending {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.2);
    color: #D97706;
}

.save-status-indicator.status-pending .save-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

.save-status-indicator.status-saving {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #2563EB;
}

.save-status-indicator.status-saving .save-icon {
    animation: spin 1s linear infinite;
}

.save-status-indicator.status-saved {
    background: rgba(22, 163, 74, 0.15);
    border: 1px solid rgba(22, 163, 74, 0.3);
    color: #059669;
}

.save-status-indicator.status-saved .save-icon {
    animation: checkmark 0.5s ease-out;
}

.save-status-indicator.status-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #DC2626;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

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

@keyframes checkmark {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Dark theme adjustments */
[data-theme="dark"] .save-status-indicator.status-idle {
    background: rgba(22, 163, 74, 0.15);
    color: #10B981;
}

[data-theme="dark"] .save-status-indicator.status-pending {
    background: rgba(234, 179, 8, 0.15);
    color: #FBBF24;
}

[data-theme="dark"] .save-status-indicator.status-saving {
    background: rgba(59, 130, 246, 0.15);
    color: #3B82F6;
}

[data-theme="dark"] .save-status-indicator.status-saved {
    background: rgba(22, 163, 74, 0.2);
    color: #10B981;
}

[data-theme="dark"] .save-status-indicator.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: #F87171;
}

/* ====== Revision History Button ====== */
.revision-history-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin-left: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366F1;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.revision-history-button:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

[data-theme="dark"] .revision-history-button {
    background: rgba(99, 102, 241, 0.15);
    color: #818CF8;
    border-color: rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .revision-history-button:hover {
    background: rgba(99, 102, 241, 0.2);
}

/* ====== Revision History Modal ====== */
.revision-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

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

.revision-modal {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.revision-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.revision-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.revision-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.revision-modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

.revision-modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.revision-loading,
.revision-error,
.revision-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.revision-error {
    color: #EF4444;
}

.revision-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.revision-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.revision-item:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.2);
}

.revision-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.revision-number {
    font-weight: 600;
    color: #6366F1;
    font-size: 14px;
    min-width: 40px;
}

.revision-date {
    color: var(--text-secondary);
    font-size: 13px;
    min-width: 120px;
}

.revision-words {
    color: var(--text-tertiary);
    font-size: 13px;
    font-family: 'Fira Code', monospace;
}

.revision-restore-btn {
    padding: 6px 16px;
    background: #6366F1;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.revision-restore-btn:hover {
    background: #4F46E5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.revision-restore-btn:active {
    transform: translateY(0);
}

/* Dark theme adjustments */
[data-theme="dark"] .revision-item {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .revision-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .revision-modal {
        width: 95%;
        max-height: 90vh;
    }

    .revision-modal-header {
        padding: 16px;
    }

    .revision-modal-header h2 {
        font-size: 18px;
    }

    .revision-modal-body {
        padding: 12px;
    }

    .revision-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .revision-info {
        flex-wrap: wrap;
        gap: 8px;
    }

    .revision-restore-btn {
        width: 100%;
    }

    .revision-history-button {
        font-size: 12px;
        padding: 5px 10px;
    }
}

/* ====== Slash Command Menu ====== */
.slash-command-menu {
    position: fixed;
    display: none;
    min-width: 260px;
    max-width: 320px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.05);
    backdrop-filter: blur(12px);
    z-index: 1500;
    padding: 0.35rem;
    animation: slashMenuFadeIn 0.12s ease-out;
}

@keyframes slashMenuFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.slash-command-category {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 0.5rem 0.6rem 0.25rem;
    user-select: none;
}

.slash-command-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.1s ease;
}

.slash-command-item:hover {
    background: rgba(22, 163, 74, 0.08);
}

.slash-command-item.active {
    background: rgba(22, 163, 74, 0.12);
    border-left: 2px solid var(--accent-primary);
    padding-left: calc(0.6rem - 2px);
}

.slash-command-icon {
    font-size: 1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.slash-command-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.slash-command-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.slash-command-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ====== Context Picker (AI Command Level Selection) ====== */
.chat-context-picker {
    position: fixed;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
    backdrop-filter: blur(4px);
}

.chat-context-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    min-width: 300px;
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-context-header {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 1rem;
}

.chat-context-options {
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
}

.chat-context-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    font-family: inherit;
}

.chat-context-btn:hover {
    background: rgba(22, 163, 74, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.15);
}

.chat-context-btn .ctx-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.chat-context-btn .ctx-text {
    display: flex;
    flex-direction: column;
}

.chat-context-btn .ctx-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-context-btn .ctx-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ====== Context Badge in Diff Modal ====== */
.diff-context-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.diff-context-badge.article {
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.diff-context-badge.full {
    background: rgba(168, 85, 247, 0.15);
    color: #C084FC;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

/* ================================================================
   FACT-CHECK MODAL
   ================================================================ */

.tone-pill--factcheck {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #60A5FA !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
}
.tone-pill--factcheck:hover {
    background: rgba(59, 130, 246, 0.25) !important;
}

.factcheck-modal-content {
    max-width: 720px !important;
}

/* Header score badge */
.factcheck-score {
    font-size: 18px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-left: auto;
    margin-right: 12px;
}
.factcheck-score--verified { background: rgba(22, 163, 74, 0.15); color: #16a34a; }
.factcheck-score--uncertain { background: rgba(217, 119, 6, 0.15); color: #d97706; }
.factcheck-score--unverified { background: rgba(220, 38, 38, 0.15); color: #dc2626; }

/* Summary bar */
.factcheck-summary {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    margin: 0 0 12px 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.factcheck-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 8px 0;
    border-radius: 6px;
}
.factcheck-counter-number {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}
.factcheck-counter-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    opacity: 0.8;
}
.factcheck-counter--verified { background: rgba(22, 163, 74, 0.1); }
.factcheck-counter--verified .factcheck-counter-number { color: #16a34a; }
.factcheck-counter--uncertain { background: rgba(217, 119, 6, 0.1); }
.factcheck-counter--uncertain .factcheck-counter-number { color: #d97706; }
.factcheck-counter--unverified { background: rgba(220, 38, 38, 0.1); }
.factcheck-counter--unverified .factcheck-counter-number { color: #dc2626; }

/* Claims list */
.factcheck-claims {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 4px 12px 0;
}

/* Individual claim card */
.factcheck-claim {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.15s;
}
.factcheck-claim:hover {
    border-color: rgba(255, 255, 255, 0.15);
}
.factcheck-claim--verified { background: rgba(22, 163, 74, 0.05); border-left: 3px solid #16a34a; }
.factcheck-claim--uncertain { background: rgba(217, 119, 6, 0.05); border-left: 3px solid #d97706; }
.factcheck-claim--unverified { background: rgba(220, 38, 38, 0.05); border-left: 3px solid #dc2626; }

/* Confidence circle */
.factcheck-claim-confidence {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}
.factcheck-confidence-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid;
}
.factcheck-confidence-circle--verified { border-color: #16a34a; color: #16a34a; background: rgba(22, 163, 74, 0.1); }
.factcheck-confidence-circle--uncertain { border-color: #d97706; color: #d97706; background: rgba(217, 119, 6, 0.1); }
.factcheck-confidence-circle--unverified { border-color: #dc2626; color: #dc2626; background: rgba(220, 38, 38, 0.1); }

/* Claim body */
.factcheck-claim-body {
    flex: 1;
    min-width: 0;
}
.factcheck-claim-text {
    font-size: 14px;
    line-height: 1.5;
    color: #e2e8f0;
    margin-bottom: 6px;
}
.factcheck-claim-verdict {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 4px;
}
.factcheck-verdict-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.factcheck-verdict-badge--verified { background: rgba(22, 163, 74, 0.15); color: #16a34a; }
.factcheck-verdict-badge--uncertain { background: rgba(217, 119, 6, 0.15); color: #d97706; }
.factcheck-verdict-badge--unverified { background: rgba(220, 38, 38, 0.15); color: #dc2626; }
.factcheck-importance-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
}

.factcheck-claim-reasoning {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
    margin-bottom: 4px;
}

/* Source attribution */
.factcheck-source {
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    margin-top: 4px;
}
.factcheck-source-label {
    color: #64748b;
    margin-right: 4px;
}
.factcheck-source-title {
    color: #93c5fd;
    font-weight: 500;
}
.factcheck-source-snippet {
    color: #64748b;
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.3;
    font-style: italic;
}

/* No claims state */
.factcheck-no-claims {
    text-align: center;
    padding: 24px;
    color: #64748b;
    font-size: 14px;
}

/* Footer */
.factcheck-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.factcheck-meta {
    font-size: 12px;
    color: #64748b;
}
