/* static/css/page.css
 *
 * Единый CSS для CMS-страниц:
 *   - page_detail.html   (просмотр)
 *   - page_edit.html     (редактирование)
 *   - page_create.html   (создание)
 *
 * Заменяет: page-detail.css, page-editor.css, page-create.css.
 */

/* ============================================================
   1. ОБЩИЙ КОНТЕЙНЕР
   ============================================================ */

.page-content,
.edit-container,
.page-create-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    color: #212529;
}

.edit-container,
.page-create-container {
    max-width: 1000px;
}

/* ============================================================
   2. ТИПОГРАФИКА КОНТЕНТА
   ============================================================ */

.page-content h1,
.page-content-body h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.page-content h2,
.page-content-body h2 {
    font-size: 1.75rem;
    margin: 1.5rem 0 1rem;
    font-weight: 600;
}

.page-content h3,
.page-content-body h3 {
    font-size: 1.35rem;
    margin: 1.25rem 0 0.75rem;
    font-weight: 600;
}

.page-content p,
.page-content-body p {
    line-height: 1.7;
    margin-bottom: 1rem;
}

/* Сохранение переносов строк для legacy plain-text страниц */
.page-content-body {
    line-height: 1.7;
    color: #212529;
    white-space: pre-wrap;       /* ← ключевое */
    word-wrap: break-word;
}

/* Если внутри есть HTML — pre-wrap не мешает */
.page-content-body p {
    white-space: normal;
}

/* ============================================================
   3. МЕДИА
   ============================================================ */

.page-content img,
.page-content-body img,
.editor-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.page-content iframe,
.page-content-body iframe,
.editor-content iframe {
    max-width: 100%;
    border-radius: 8px;
}

.page-content video,
.page-content-body video,
.editor-content video {
    max-width: 100%;
    border-radius: 8px;
}

.page-content audio,
.page-content-body audio,
.editor-content audio {
    width: 100%;
    max-width: 400px;
}

/* ============================================================
   4. ТАБЛИЦЫ, ЦИТАТЫ, КОД
   ============================================================ */

.page-content table,
.page-content-body table,
.editor-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.page-content table th,
.page-content table td,
.page-content-body table th,
.page-content-body table td,
.editor-content table th,
.editor-content table td {
    border: 1px solid #dee2e6;
    padding: 8px 12px;
}

.page-content table th,
.page-content-body table th,
.editor-content table th {
    background: #f8f9fa;
    font-weight: 600;
}

.page-content blockquote,
.page-content-body blockquote,
.editor-content blockquote {
    border-left: 4px solid #0d6efd;
    padding-left: 16px;
    margin-left: 0;
    color: #6c757d;
}

.page-content pre,
.page-content-body pre,
.editor-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
}

.page-content code,
.page-content-body code,
.editor-content code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
}

/* ============================================================
   5. ПЛЕЙСХОЛДЕР ПЕРЕВОДА
   ============================================================ */

.translation-placeholder {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
    text-align: center;
    border: 1px dashed #dee2e6;
}

.translation-placeholder .spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid #e9ecef;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: pageSpin 0.8s linear infinite;
}

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

/* ============================================================
   6. АДМИНСКАЯ КНОПКА (FAB)
   ============================================================ */

.admin-controls {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-controls .btn {
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.admin-controls .btn:hover {
    transform: scale(1.1);
}

.admin-controls .btn-edit {
    background: #0d6efd;
    color: white;
}

/* ============================================================
   7. ПАНЕЛЬ ПУБЛИКАЦИИ
   ============================================================ */

.publish-toggle-wrapper {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.publish-toggle-wrapper .status-label {
    font-weight: 500;
    color: #495057;
    margin-right: 0.5rem;
}

.status-badge,
.status-indicator {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-badge.published,
.status-indicator.published {
    background: #d1e7dd;
    color: #0a3622;
}

.status-badge.unpublished,
.status-indicator.unpublished {
    background: #f8d7da;
    color: #58151c;
}

/* ============================================================
   8. TOGGLE SWITCH
   ============================================================ */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #198754;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   9. РЕДАКТОР TIPTAP
   ============================================================ */

.tiptap-toolbar {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.tiptap-toolbar .separator {
    color: #dee2e6;
    margin: 0 4px;
    user-select: none;
}

.tiptap-toolbar button {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 30px;
    text-align: center;
    line-height: 1.2;
    color: #333;
}

.tiptap-toolbar button:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.tiptap-toolbar button.is-active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.tiptap-toolbar select {
    background: transparent;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 14px;
    cursor: pointer;
    height: 28px;
    min-width: 70px;
}

/* Область редактора */
.tiptap-editor {
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 16px;
    min-height: 400px;
    background: white;
    color: #212529;
    line-height: 1.7;
}

.tiptap-editor:focus,
.tiptap-editor:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: none;
}

.tiptap-editor .ProseMirror {
    outline: none;
    min-height: 400px;
}

.tiptap-editor .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: #adb5bd;
    float: left;
    height: 0;
    pointer-events: none;
}

/* ============================================================
   10. АДАПТИВНОСТЬ
   ============================================================ */

@media (max-width: 768px) {
    .page-content,
    .page-content-body {
        padding: 1.5rem 1rem;
    }

    .page-content h1 { font-size: 2rem; }
    .page-content h2 { font-size: 1.5rem; }
    .page-content h3 { font-size: 1.2rem; }

    .publish-toggle-wrapper {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-controls {
        bottom: 20px;
        right: 16px;
    }

    .admin-controls .btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .tiptap-toolbar {
        padding: 6px 8px;
        gap: 2px;
    }

    .tiptap-toolbar button {
        padding: 3px 6px;
        font-size: 13px;
        min-width: 26px;
    }
}

@media (max-width: 576px) {
    .page-content h1 { font-size: 1.75rem; }
    .page-content h2 { font-size: 1.35rem; }
    .page-content h3 { font-size: 1.1rem; }

    .page-content table,
    .page-content-body table {
        font-size: 0.875rem;
    }

    .page-content table th,
    .page-content table td {
        padding: 6px 8px;
    }
}