/**
 * Стили для системы выбора редактора статей
 */

/* Заголовок редактора с инструментами */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.editor-header label {
    margin: 0;
    font-weight: 600;
    color: #333;
}

.editor-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Переключатель редактора */
.article-editor-switcher {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

/* Заголовок переключателя с кнопкой справки */
.editor-switch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.editor-switch-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Кнопка справки по горячим клавишам */
.hotkeys-help-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hotkeys-help-btn:hover {
    background: #5a6268;
    transform: scale(1.1);
}

.hotkeys-help-btn.active {
    background: #3498db;
}

.editor-switch-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-switch-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.editor-switch-btn.active {
    background: #3498db;
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

.editor-switch-btn.active:hover {
    background: #0056b3;
}

/* Панель инструментов для простого редактора */
.article-editor-toolbar {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    padding: 8px 12px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.article-toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 6px 8px;
    cursor: pointer;
    color: #495057;
    transition: all 0.2s ease;
    font-size: 14px;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-toolbar-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #212529;
}

.article-toolbar-btn:active {
    background: #dee2e6;
    transform: translateY(1px);
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #dee2e6;
    margin: 4px 8px;
}

/* Группировка кнопок */
.toolbar-group {
    display: flex;
    gap: 2px;
    align-items: center;
}

.toolbar-group + .toolbar-group::before {
    content: '';
    width: 1px;
    height: 20px;
    background: #dee2e6;
    margin: 0 6px;
}

/* Textarea с панелью инструментов */
.article-editor-container .form-control {
    border-radius: 0 0 4px 4px;
    border-top: none;
    resize: vertical;
    min-height: 300px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
}

/* Индикатор загрузки */
.editor-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.editor-loading i {
    font-size: 24px;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

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

/* Уведомления редактора */
.editor-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 250px;
    font-size: 14px;
    animation: slideInRight 0.3s ease-out;
}

.editor-notification.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.editor-notification.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.editor-notification.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Настройки редактора в форме */
.editor-settings-inline {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-settings-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.editor-settings-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Справка по горячим клавишам */
.hotkeys-help {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 20px;
    margin-top: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease-out;
}

.hotkeys-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.hotkeys-section h4 {
    color: #495057;
    margin: 0 0 15px 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hotkeys-section h4 i {
    color: #3498db;
}

.hotkeys-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.hotkey-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f1f3f4;
}

.hotkey-item:last-child {
    border-bottom: none;
}

.hotkey {
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #ced4da;
}

.hotkey-desc {
    color: #6c757d;
    font-size: 13px;
}

.hotkeys-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.hotkeys-footer p {
    margin: 0;
    color: #6c757d;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hotkeys-footer i {
    color: #ffc107;
}

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

/* SimpleMDE переопределения для статей */
.article-editor-container .CodeMirror {
    min-height: 300px;
    font-size: 14px;
    line-height: 1.5;
}

.article-editor-container .editor-toolbar {
    border-color: #dee2e6;
    background: #f8f9fa;
}

.article-editor-container .editor-toolbar a {
    color: #495057 !important;
}

.article-editor-container .editor-toolbar a:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.article-editor-container .editor-toolbar.fullscreen {
    z-index: 1050; /* Поверх Bootstrap модалов */
}

.article-editor-container .CodeMirror.CodeMirror-fullscreen {
    z-index: 1050;
}

/* Темы для редактора */
.article-editor-container.dark-theme .article-editor-toolbar {
    background: #343a40;
    border-color: #495057;
}

.article-editor-container.dark-theme .article-toolbar-btn {
    color: #adb5bd;
}

.article-editor-container.dark-theme .article-toolbar-btn:hover {
    background: #495057;
    color: #f8f9fa;
}

.article-editor-container.dark-theme .form-control {
    background: #495057;
    color: #f8f9fa;
    border-color: #6c757d;
}

/* Улучшения для SimpleMDE */
.article-editor-container .CodeMirror {
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.article-editor-container .editor-toolbar {
    border-top: 1px solid #dee2e6;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    border-radius: 4px 4px 0 0;
}

.article-editor-container .CodeMirror-scroll {
    min-height: 300px;
}

/* Стили для статуса редактора */
.editor-status-text {
    margin-left: auto;
    font-size: 13px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 5px 0;
}

.editor-status-text i {
    opacity: 0.7;
}

/* Статус черновика */
.draft-status-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.draft-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    animation: fadeInScale 0.3s ease-out;
}

.draft-status-badge i {
    font-size: 11px;
}

.draft-status-badge .draft-text {
    font-weight: 600;
}

.draft-clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

.draft-clear-btn:hover {
    background: #c82333;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(220, 53, 69, 0.4);
}

.draft-clear-btn i {
    font-size: 12px;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Стили для индикаторов черновиков - базовые */
.draft-icon-edit {
    position: absolute !important;
    right: 36px !important;
    top: 8px !important;
    z-index: 10 !important;
    display: none;
    cursor: help;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.draft-icon-edit:hover {
    opacity: 1;
}

.draft-icon-edit .draft-icon {
    fill: none;
    stroke: #28a745;
    stroke-width: 1.5;
}

.draft-icon-edit .draft-icon.draft-icon-saved {
    stroke: #28a745;
    fill: #d4edda;
}

.draft-icon-edit .draft-icon.draft-icon-unsaved {
    stroke: #ffc107;
    fill: #fff3cd;
}

.clear-article-draft {
    right: 8px !important;
    top: 8px !important;
    z-index: 10 !important;
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.clear-article-draft:hover {
    opacity: 1;
    transform: scale(1.1);
}

.clear-article-draft svg {
    display: block;
}

/* Обеспечиваем правильное позиционирование для всех контейнеров */
.article-editor-container {
    position: relative;
}

/* Стили для всех контейнеров редакторов - кнопки в правом верхнем углу */
.article-editor-container .draft-icon-edit {
    position: absolute !important;
    right: 36px !important;
    top: 8px !important;
    z-index: 10 !important;
}

.article-editor-container #clear-article-draft {
    position: absolute !important;
    right: 8px !important;
    top: 8px !important;
    z-index: 10 !important;
}

/* Специальные стили для классического редактора */
.article-editor-container:not(.simplemde-mode) .draft-icon-edit,
.article-editor-container.classic-mode .draft-icon-edit {
    position: absolute !important;
    right: 36px !important;
    top: 8px !important;
    z-index: 10 !important;
}

.article-editor-container:not(.simplemde-mode) #clear-article-draft,
.article-editor-container.classic-mode #clear-article-draft {
    position: absolute !important;
    right: 8px !important;
    top: 8px !important;
    z-index: 10 !important;
}

/* Показываем индикаторы когда есть черновик */
.article-editor-container .draft-icon-edit[style*="inline"] {
    display: inline !important;
}

.article-editor-container #clear-article-draft[style*="inline"] {
    display: inline !important;
}

/* Стили для SimpleMDE режима - кнопки также в правом верхнем углу */
.article-editor-container.simplemde-mode .draft-icon-edit {
    position: absolute;
    right: 36px;
    top: 8px;
    z-index: 10;
}

.article-editor-container.simplemde-mode #clear-article-draft {
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 10;
}

/* Специальная обработка для CodeMirror контейнера */
.article-editor-container .CodeMirror-wrap {
    position: relative;
}

/* Когда индикаторы находятся внутри CodeMirror-wrap */
.CodeMirror-wrap .draft-icon-edit {
    position: absolute;
    right: 36px;
    top: 8px;
    z-index: 10;
}

.CodeMirror-wrap #clear-article-draft {
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 10;
}

/* Скрываем индикаторы в режимах предпросмотра */
.article-editor-container .editor-preview-side .draft-icon-edit,
.article-editor-container .editor-preview-full .draft-icon-edit {
    display: none !important;
}

.article-editor-container .editor-preview-side #clear-article-draft,
.article-editor-container .editor-preview-full #clear-article-draft {
    display: none !important;
}

/* Полноэкранный режим SimpleMDE */
.CodeMirror-fullscreen .draft-icon-edit {
    position: fixed;
    right: 50px;
    top: 15px;
    z-index: 1051;
}

.CodeMirror-fullscreen #clear-article-draft {
    position: fixed;
    right: 20px;
    top: 15px;
    z-index: 1051;
}

/* Анимация появления индикаторов */
@keyframes draftIndicatorShow {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 0.7;
        transform: scale(1);
    }
}

.draft-icon-edit[style*="inline"] {
    animation: draftIndicatorShow 0.3s ease-out;
}

#clear-article-draft[style*="inline"] {
    animation: draftIndicatorShow 0.3s ease-out;
}

/* Адаптивность */
@media (max-width: 768px) {
    .editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .hotkeys-sections {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .draft-status-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .editor-switch-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .hotkeys-footer p {
        flex-direction: column;
        gap: 5px;
    }
}