/* ========================================= */
/* РЕДАКТОР СТАТЕЙ (REFACTORED & CLEAN)      */
/* ========================================= */

/* --- 1. Основной контейнер редактора --- */
#screen-admin-article-editor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 2500;
    overflow-y: auto;
    padding: 0;
    padding-bottom: 50px;
    box-sizing: border-box;
}

    /* Контейнер для контента (обертка) */
    #screen-admin-article-editor .editor-body-wrapper {
        padding: 20px;
        max-width: 900px;
        margin: 0 auto;
    }

    /* --- 2. Шапка редактора (Unified & Compact) --- */
    #screen-admin-article-editor .editor-header {
        position: sticky;
        top: 0;
        z-index: 30;
        height: 65px;
        padding: 0 10px;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
    }

        /* Общий стиль кнопок в шапке */
        #screen-admin-article-editor .editor-header button {
            height: 38px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 0 16px;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            border: 1px solid transparent;
            transition: all 0.2s ease;
        }

    /* Кнопка "Назад" (Icon only) */
    #screen-admin-article-editor .btn-back {
        background: var(--surface);
        border-color: var(--border) !important;
        color: var(--text);
        width: 38px;
        min-width: 38px;
        padding: 0 !important;
    }

        #screen-admin-article-editor .btn-back span:not(.material-symbols-outlined) {
            display: none;
        }

    /* Кнопка "Предпросмотр" */
    #screen-admin-article-editor .btn-preview {
        background: var(--surface);
        border: 1px solid var(--border) !important;
        color: var(--text);
        width: 38px;
        padding: 0 !important;
    }

        #screen-admin-article-editor .btn-back:hover,
        #screen-admin-article-editor .btn-preview:hover {
            background: var(--hover);
        }

    /* Кнопка "Сохранить" (Primary) */
    #screen-admin-article-editor .btn-save {
        background: var(--primary);
        color: #fff;
        padding: 0 14px !important;
    }

        #screen-admin-article-editor .btn-save:hover {
            opacity: 0.9;
            transform: translateY(-1px);
        }

/* --- 3. Поле заголовка --- */
#art-edit-title {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--border);
    border-radius: 0;
    padding: 15px 0;
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    transition: border-color 0.3s;
    width: 100%;
}

    #art-edit-title:focus {
        outline: none;
        box-shadow: none;
        border-bottom-color: var(--primary);
    }

    #art-edit-title::placeholder {
        opacity: 0.5;
        font-weight: normal;
    }

/* --- 4. WYSIWYG Панель инструментов --- */
.wysiwyg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 65px;
    z-index: 20;
}

    .wysiwyg-toolbar button {
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: 1px solid transparent;
        border-radius: 8px;
        color: var(--text-sec);
        cursor: pointer;
        transition: all 0.2s ease;
    }

        .wysiwyg-toolbar button:hover {
            background: var(--hover);
            color: var(--text);
        }

    .wysiwyg-toolbar .separator {
        width: 1px;
        height: 20px;
        background: var(--border);
        margin: 0 6px;
        align-self: center;
        opacity: 0.5;
    }

/* --- 5. WYSIWYG Область контента --- */
.wysiwyg-content {
    min-height: 50vh;
    padding: 25px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 1px solid rgba(255,255,255,0.05);
    border-radius: 0 0 16px 16px;
    outline: none;
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
}

    /* Типографика внутри редактора */
    .wysiwyg-content h2,
    .wysiwyg-content h3 {
        margin-top: 25px;
        margin-bottom: 15px;
        color: var(--text);
        font-weight: 800;
        line-height: 1.2;
    }

    .wysiwyg-content ul,
    .wysiwyg-content ol {
        padding-left: 20px;
        margin-bottom: 15px;
        color: var(--text-sec);
    }

    .wysiwyg-content li {
        margin-bottom: 5px;
    }

    .wysiwyg-content a {
        color: var(--primary);
        text-decoration: none;
        border-bottom: 1px dashed var(--primary);
    }

    .wysiwyg-content:empty:before {
        content: attr(placeholder);
        color: var(--text-sec);
        opacity: 0.5;
        pointer-events: none;
    }

    .wysiwyg-content::after {
        content: "";
        display: table;
        clear: both;
    }

    /* --- 6. Работа с изображениями --- */
    .wysiwyg-content img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 15px auto;
        cursor: pointer;
        border-radius: 8px;
        border: 2px solid transparent;
        transition: all 0.2s;
        box-sizing: border-box;
    }

        .wysiwyg-content img:hover {
            opacity: 0.9;
        }

        .wysiwyg-content img.selected {
            border-color: var(--primary);
            box-shadow: 0 0 0 4px rgba(145, 71, 255, 0.15);
        }

/* Утилиты размеров изображений */
.img-size-100 {
    width: 100%;
}

.img-size-75 {
    width: 75%;
}

.img-size-50 {
    width: 50%;
}

.img-size-25 {
    width: 25%;
}

/* Утилиты выравнивания */
.img-align-left {
    float: left !important;
    margin: 5px 20px 10px 0 !important;
    display: inline-block !important;
}

.img-align-center {
    float: none !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.img-align-right {
    float: right !important;
    margin: 5px 0 10px 20px !important;
    display: inline-block !important;
}

/* --- 7. Плавающее меню изображений --- */
#img-floating-toolbar {
    display: none;
    position: fixed; /* БЫЛО: absolute */
    z-index: 3000; /* Подняли выше редактора (было 2600) */
    /* Остальные стили без изменений... */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    gap: 5px;
    flex-wrap: wrap;
    width: 220px;
    justify-content: center;
    backdrop-filter: blur(10px);
}

    #img-floating-toolbar button {
        background: transparent;
        border: 1px solid transparent;
        border-radius: 8px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--text-sec);
        transition: 0.2s;
    }

        #img-floating-toolbar button:hover {
            background: var(--hover);
            color: var(--text);
        }

        #img-floating-toolbar button.size-btn {
            width: auto;
            padding: 0 8px;
            font-size: 11px;
            font-weight: 700;
            color: var(--text-sec);
        }

            #img-floating-toolbar button.size-btn:hover {
                color: var(--primary);
            }

    #img-floating-toolbar .sep-row {
        width: 100%;
        height: 1px;
        background: var(--border);
        margin: 4px 0;
        opacity: 0.5;
    }

/* ========================================= */
/* ПАНЕЛЬ ФИЛЬТРОВ И СПИСКИ                  */
/* ========================================= */
.articles-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 15px;
    align-items: center;
}

.articles-filter-select {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 42px;
    margin: 0;
    padding: 0 30px 0 12px;
    border-radius: 10px;
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    /* Стрелочка */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23999%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    transition: border-color 0.2s;
}

    .articles-filter-select:focus {
        border-color: var(--primary);
    }

.articles-filter-btn {
    display: flex;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 42px;
    margin: 0;
    padding: 0;
    border-radius: 10px;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 11px;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

    .articles-filter-btn:active {
        background: var(--hover);
        transform: scale(0.98);
    }

/* Карточка статьи в списке (Админ и Юзер) */
.article-card {
    display: block;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    background: var(--surface) !important; /* Уточнение фона */
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

    .article-card:active {
        background: var(--hover) !important;
    }

/* --- Стили для тумблера публикации --- */
/* --- Стили для тумблера публикации в шапке (FIXED) --- */
.publish-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 4px 12px 4px 8px; /* Чуть больше справа для текста */
    border-radius: 20px;
    border: 1px solid var(--border);
    height: 32px; /* Фиксируем высоту контейнера */
    box-sizing: border-box;
    transition: 0.2s;
    margin-left: 10px;
    cursor: pointer;
}

    .publish-toggle-wrapper:hover {
        background: var(--hover);
        border-color: var(--text-sec);
    }

    /* Текст рядом с тумблером */
    .publish-toggle-wrapper span {
        font-size: 10px;
        font-weight: 800;
        color: var(--text-sec);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        line-height: 1; /* Убираем лишние отступы строки */
        padding-top: 1px; /* Микро-коррекция для визуального центра */
    }

/* Сам переключатель (Small) */
.toggle-switch.small {
    position: relative;
    display: inline-block;
    width: 32px; /* Оптимальная ширина */
    height: 18px; /* Оптимальная высота */
    margin: 0;
    flex-shrink: 0;
}

    /* Фон переключателя (трек) */
    .toggle-switch.small .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(255, 255, 255, 0.2); /* Цвет выключенного (серый) */
        transition: .3s;
        border-radius: 18px;
    }

        /* Кружочек */
        .toggle-switch.small .slider:before {
            position: absolute;
            content: "";
            height: 14px;
            width: 14px;
            left: 2px;
            bottom: 2px;
            background-color: white;
            transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
            border-radius: 50%;
            box-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }

    /* Состояние "Включено" */
    .toggle-switch.small input:checked + .slider {
        background-color: var(--primary); /* Акцентный цвет (голубой/фиолетовый) */
    }

        .toggle-switch.small input:checked + .slider:before {
            transform: translateX(14px); /* Сдвиг кружочка */
        }

/* ========================================= */
/* МОДАЛЬНОЕ ОКНО ПРОСМОТРА (PREVIEW)        */
/* ========================================= */
#modal-article-preview {
    display: none; /* Управляется JS */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 11000; /* Самый верхний слой */
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

#article-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 60px 20px;
    background: var(--bg);
    scrollbar-width: none; /* Firefox */
}

    #article-preview-content::-webkit-scrollbar {
        display: none;
    }

    #article-preview-content h1 {
        font-size: 28px !important;
        margin-top: 10px !important;
        font-family: 'Inter', sans-serif;
        letter-spacing: -0.5px;
        line-height: 1.2;
    }

#article-swipe-area {
    padding: 12px 0;
    cursor: grab;
    background: var(--bg);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    user-select: none;
    -webkit-user-drag: none;
}

    #article-swipe-area:active {
        cursor: grabbing;
    }

/* ========================================= */
/* DESKTOP АДАПТИВ                         */
/* ========================================= */
@media (min-width: 1024px) {
    #screen-admin-article-editor .editor-body-wrapper {
        max-width: 900px;
        margin: 0 auto;
    }

    .wysiwyg-content {
        min-height: 60vh;
        font-size: 17px;
        box-shadow: var(--shadow-card);
    }
}

/* ========================================= */
/* БЛОК ПОДЕЛИТЬСЯ (SHARE)                   */
/* ========================================= */

.article-footer-share {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
    margin-bottom: 20px;
}

.af-title {
    font-size: 11px;
    color: var(--text-sec);
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 15px;
    text-align: center;
}

.af-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.1s, opacity 0.2s;
    color: #fff;
    flex: 1;
    max-width: 140px;
}

    .share-btn:active {
        transform: scale(0.96);
    }

    .share-btn:hover {
        opacity: 0.9;
    }

    .share-btn svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }

    /* Цвета соцсетей */
    .share-btn.tg {
        background: #229ED9; /* Telegram Blue */
    }

    .share-btn.vk {
        background: #0077FF; /* VK Blue */
    }

    .share-btn.copy {
        background: var(--surface);
        color: var(--text);
        border: 1px solid var(--border);
    }

        .share-btn.copy:hover {
            background: var(--hover);
        }

/* Мобильная адаптация кнопок */
@media (max-width: 400px) {
    .af-buttons {
        flex-direction: column;
    }

    .share-btn {
        width: 100%;
        max-width: none;
        padding: 12px;
    }
}

/* Добавьте это в секцию .wysiwyg-content */

.wysiwyg-content img {
    /* ... ваши старые стили ... */
    cursor: zoom-in; /* Курсор лупы */
}

/* На всякий случай убедимся, что lightbox перекрывает всё */
#modal-image-viewer {
    backdrop-filter: blur(5px);
}

#img-viewer-source {
    /* Убираем постоянный transition, чтобы драг был мгновенным */
    transition: none;
    transform-origin: center center;
    will-change: transform;
    /* Запрещаем выделение и перетаскивание самого элемента браузером */
    user-select: none;
    -webkit-user-drag: none;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Добавляем этот класс, когда нужно плавное изменение (при зуме) */
.viewer-transition {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}