/**
 * WYSIWYG Task Editor Styles
 *
 * Styles for the new TipTap-based Task Creator
 */

/* ===== Editor Container ===== */
.wysiwyg-task-editor {
    display: flex;
    gap: 1rem;
    height: calc(100vh - 200px);
    min-height: 600px;
}

/* ===== Main Editor Area (Left) ===== */
.wysiwyg-task-editor__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-height: calc(100vh - 200px); /* Phase 1.5: Scrolling fix */
}

/* ===== Toolbar ===== */
.editor-toolbar {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.toolbar-btn {
    padding: 0.375rem 0.75rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
    color: var(--color-text);
}

.toolbar-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.toolbar-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

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

/* ===== TipTap Editor Content ===== */
.tiptap-editor-content {
    flex: 1;
    overflow-y: auto; /* Phase 1.5: Enable scrolling */
    padding: 1.5rem;
    max-height: calc(100vh - 400px); /* Phase 1.5: Scrolling fix */
}

/* TipTap Prose Styles */
.tiptap-editor-content .ProseMirror {
    outline: none;
    min-height: 300px;
}

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

.tiptap-editor-content .ProseMirror ul,
.tiptap-editor-content .ProseMirror ol {
    padding-left: 1.5rem;
    margin: 0 0 0.75rem 0;
}

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

.tiptap-editor-content .ProseMirror strong {
    font-weight: 600;
}

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

/* ===== Math Object Badges ===== */
.math-object-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: #fbbf24;
    color: #92400e;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0 0.125rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.math-object-badge:hover {
    background: #f59e0b;
    color: white;
    border-color: #d97706;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== Math Result Badges ===== */
.math-result-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: #3b82f6;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0 0.125rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.math-result-badge:hover {
    background: #2563eb;
    border-color: #1d4ed8;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ===== Operation Marker Badges ===== */
.operation-marker-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0 0.125rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.operation-marker-badge:hover {
    background: var(--color-primary-dark);
    border-color: #1e40af;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ===== Side Panels (Right) ===== */
.wysiwyg-task-editor__sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.side-panel {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.side-panel h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Panel Items ===== */
.panel-item {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: all 0.15s;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

.panel-item:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.panel-item:active {
    cursor: grabbing;
    transform: translateY(0);
}

.panel-item__icon {
    font-size: 1.25rem;
}

.panel-item__label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== Buttons in Panels ===== */
.panel-btn {
    width: 100%;
    padding: 0.5rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.panel-btn:hover {
    background: var(--color-primary-dark);
}

.panel-btn-secondary {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.panel-btn-secondary:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

/* ===== Auto-Block (Solution Tab) ===== */
.auto-block {
    padding: 1rem;
    background: var(--color-bg-secondary);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    margin: 1rem 0;
    position: relative;
}

/* Phase 1.5: Auto-Block "Perfect" Style */
.auto-block--perfect {
    border: 2px solid #10b981;
    background: linear-gradient(to bottom, #f0fdf4, #ffffff);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.auto-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.auto-block-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* Phase 1.5: Perfect Badge */
.auto-block-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: #10b981;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-icon {
    font-size: 0.875rem;
}

/* Phase 1.5: Operation Info */
.auto-block-info {
    padding: 0.5rem 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.75rem;
}

/* Phase 1.5: LaTeX Display */
.latex-display {
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    line-height: 1.8;
    background: white;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid #e5e7eb;
    overflow-x: auto;
}

/* Phase 1.5: Footer */
.auto-block-footer {
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
    margin-top: 0.75rem;
}

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

/* Phase 1.5: Actions */
.auto-block-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-icon-sm {
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.btn-icon-sm:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

/* Legacy styles (for backwards compatibility) */
.auto-block-content {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--color-text);
}

.auto-block-content pre {
    background: white;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

/* ===== Tab Navigation ===== */
.tab-navigation {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
    color: var(--color-text);
}

.tab-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.tab-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Modal Styles ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-dialog {
    background: white;
    border-radius: var(--radius-md);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-dialog-wide {
    max-width: 900px;
    width: 95%;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ===== Alert Styles (for modals) ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* ===== Phase 1.5: Loading Spinner ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.loading-message {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Phase 2: Preview Tab Styles ===== */
.preview-container {
    padding: 1.5rem;
    background: white;
    min-height: 400px;
    overflow-y: auto;
    max-height: calc(100vh - 350px);
}

.preview-loading {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-secondary);
}

.preview-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.preview-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    background: var(--color-bg);
}

.preview-section-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
}

.preview-svg-container {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.preview-svg-container svg {
    max-width: 100%;
    height: auto;
}

/* ===== Phase 2: Category Tabs Styles ===== */
.category-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.category-tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all 0.15s;
}

.category-tab:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.category-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

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

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .wysiwyg-task-editor {
        flex-direction: column;
    }

    .wysiwyg-task-editor__sidebar {
        width: 100%;
        flex-direction: row;
    }

    .side-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .wysiwyg-task-editor__sidebar {
        flex-direction: column;
    }
}

/* Custom Select Dropdown */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    min-height: 38px;
    display: flex;
    align-items: center;
}

.custom-select-trigger:hover {
    border-color: var(--color-primary);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 0.25rem;
}

.custom-select-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
}

.custom-select-option:hover {
    background: var(--color-bg-hover);
}

.custom-select-option.selected {
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-weight: 500;
}
