/* style.css — Финальная версия */

/* Сброс для обертки */
.sbe-wrapper * { box-sizing: border-box; }

/* Основной контейнер редактора */
#editor-root {
    height: 86vh; 
    min-height: 600px; 
    width: 100%;
    background: #e0e0e0; 
    display: flex; 
    flex-direction: column;
    border: 1px solid #ccc; 
    font-family: 'Inter', sans-serif;
    position: relative; 
    overflow: hidden;
}

/* Шапка */
.ed-header {
    height: 50px; 
    background: #1E1E2D; 
    display: flex; 
    align-items: center;
    justify-content: space-between; 
    padding: 0 20px; 
    color: white; 
    flex-shrink: 0;
}
.btn-save { 
    background: #3B82F6; color: white; border: none; 
    padding: 6px 15px; border-radius: 4px; cursor: pointer; 
}

/* Панель инструментов */
.ed-toolbar {
    height: 46px; background: #fff; border-bottom: 1px solid #ddd;
    display: flex; align-items: center; padding: 0 10px; gap: 10px; flex-shrink: 0;
}
.tb-group { display: flex; align-items: center; gap: 5px; border-right: 1px solid #eee; padding-right: 10px; }
.tb-btn { border: none; background: transparent; padding: 5px; cursor: pointer; border-radius: 4px; }
.tb-input { border: 1px solid #ddd; padding: 4px; border-radius: 4px; font-size: 13px; }

/* Тело редактора */
.ed-body { display: flex; flex: 1; overflow: hidden; }

/* Сайдбар */
.ed-sidebar {
    width: 70px; background: #fff; border-right: 1px solid #ddd;
    display: flex; flex-direction: column; align-items: center;
    padding-top: 15px; gap: 15px; overflow-y: auto; z-index: 5; flex-shrink: 0;
}
.sb-item { display: flex; flex-direction: column; align-items: center; cursor: pointer; color: #555; font-size: 10px; text-align: center; }
.sb-item:hover { color: #000; }

/* Рабочая область */
.ed-workspace {
    flex: 1; background: #525659; overflow: auto;
    display: flex; justify-content: center; align-items: flex-start;
    padding: 40px; position: relative;
}

/* Канвас */
.canvas-wrap {
    background: white; box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transform-origin: top center; transition: transform 0.1s ease-out;
}

/* Футер */
.ed-footer {
    height: 40px; background: #fff; border-top: 1px solid #ddd;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; flex-shrink: 0;
}
.page-btn { padding: 4px 10px; cursor: pointer; background: #f0f0f0; border: 1px solid #ccc; border-radius: 4px; }

/* FABRIC FIXES */
.canvas-container { outline: none !important; }
.canvas-container textarea {
    position: fixed !important; top: 0 !important; left: 0 !important;
    opacity: 0 !important; width: 1px !important; height: 1px !important;
    z-index: -999 !important; overflow: hidden !important;
}

/* Слои оверлеев */
.sbe-overlays-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 10; overflow: hidden;
}
.sbe-iframe-wrapper {
    position: absolute; display: flex; flex-direction: column; overflow: hidden;
    transform-origin: top left; will-change: transform, width, height, top, left;
}
.sbe-iframe-content {
    flex: 1; background: #e0e0e0; position: relative; width: 100%; height: 100%;
}
.sbe-iframe-content iframe {
    width: 100%; height: 100%; border: none; display: block;
    background: white; pointer-events: none;
}

/* ========================================= */
/* === ВСЕ ПРЕЛОАДЕРЫ (ГЛАВНЫЙ + IFRAME) === */
/* ========================================= */

/* 1. ГЛАВНЫЙ ПРЕЛОАДЕР (Серый экран) */
.loader-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 99999; /* Поверх всего */
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 15px; font-size: 14px; color: #555; backdrop-filter: blur(2px);
}

/* 2. IFRAME ПРЕЛОАДЕР (Внутри рамки) */
.sbe-loader-wrap {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: #f0f0f0; z-index: 5; 
    transition: opacity 0.3s;
}

/* 3. САМА КРУТИЛКА */
.sbe-spinner {
    width: 40px; height: 40px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #3B82F6;
    border-radius: 50%;
    animation: sbe-spin 1s linear infinite;
}

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

/* --- ФУТЕР И ПАГИНАЦИЯ (Улучшенный стиль) --- */

.ed-footer {
    height: 45px; /* Чуть выше для удобства */
    background: #fff; 
    border-top: 1px solid #e0e0e0;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 0 15px; 
    flex-shrink: 0;
    font-size: 13px;
    color: #555;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02); /* Легкая тень сверху */
}

/* Группа кнопок пагинации */
.page-controls {
    display: flex;
    align-items: center;
    gap: 8px; /* Расстояние между элементами */
    background: #f9fafb; /* Легкий фон для блока */
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #eee;
}

/* Кнопки стрелок */
.page-btn { 
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer; 
    background: #fff; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    color: #555;
    transition: all 0.2s;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.page-btn:hover {
    background: #fff;
    border-color: #3B82F6;
    color: #3B82F6;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.page-btn:active {
    transform: translateY(1px);
}

/* Инпут номера страницы (Компактный) */
.page-num-input {
    width: 35px !important; /* Уменьшили с 45px до 35px */
    height: 28px !important;
    text-align: center;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    padding: 0 !important; /* Убираем внутренние отступы, они часто мешают уменьшить ширину */
    margin: 0 !important;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    background: #fff;
    line-height: 1; /* Чтобы цифра стояла ровно по центру */
}

.page-num-input:focus {
    border-color: #3B82F6 !important;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Убираем стрелочки (Chrome, Safari, Edge) */
.page-num-input::-webkit-outer-spin-button,
.page-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Убираем стрелочки (Firefox) */
.page-num-input {
    -moz-appearance: textfield;
}

/* Текст "Стр" и "/ 75" */
.page-controls span {
    font-weight: 500;
    color: #666;
    user-select: none; /* Чтобы не выделялось при кликах */
}

/* ========== ВАРИАНТ A: Стили для индикатора несохраненных изменений ========== */

/* Анимация пульсации для кнопки с несохраненными изменениями */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 152, 0, 0);
    }
}

/* Улучшенные стили кнопки сохранения */
.btn-save {
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}