/* TipTap — editor-only styles.
 *
 * ВАЖНО:
 * - Этот файл отвечает только за UI редактирования (ProseMirror / bubble menu / suggestions).
 * - Стили отображения read-only контента — в `tiptap-content.css`.
 */

/* Контейнер редактора - соответствует gc-input */
.gc-editor-container {
    width: 100%;
    background-color: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-field);
    transition: all 0.3s ease;
    min-height: 200px;
    position: relative;
}

/* Focus state для контейнера */
.gc-editor-container:focus-within {
    border-color: var(--accent-link);
    box-shadow: 0 0 0 3px rgba(var(--accent-link-rgb, 241, 90, 48), 0.15);
}

/* Hover state для контейнера */
.gc-editor-container:hover:not(:focus-within) {
    border-color: var(--accent-link);
    box-shadow: 0 0 0 3px rgba(var(--accent-link-rgb, 241, 90, 48), 0.25);
}

/* Поле редактора (TipTap/ProseMirror) */
.stage-tiptap-editor {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: var(--spacing-md);
    font-size: var(--font-size-mdl);
    line-height: 1.5;
    color: var(--font-primary);
}

.stage-tiptap-editor:focus {
    outline: none;
}

/* Placeholder */
.stage-tiptap-editor p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: var(--font-secondary);
    pointer-events: none;
    height: 0;
    font-size: var(--font-size-mdl);
}

/* Notepad-like typography: Enter = hardBreak (<br>) внутри абзаца */
.stage-tiptap-editor p {
    margin: 0;
    line-height: 1.5;
}

.stage-tiptap-editor p + p {
    margin-top: var(--spacing-2xs);
}

.stage-tiptap-editor p:last-child {
    margin-bottom: 0;
}

.stage-tiptap-editor a,
.stage-tiptap-editor .stage-editor-link {
    color: var(--accent-link);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.stage-tiptap-editor a:hover,
.stage-tiptap-editor .stage-editor-link:hover {
    text-decoration: underline;
    text-decoration-color: var(--accent-link);
    text-underline-offset: 2px;
    opacity: 0.8;
}

.stage-tiptap-editor strong {
    font-weight: 700;
}

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

.stage-tiptap-editor code {
    background: var(--bg-content-secondary);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--font-primary);
}

/* Скроллбар для редактора */
.stage-tiptap-editor::-webkit-scrollbar {
    width: 8px;
}

.stage-tiptap-editor::-webkit-scrollbar-track {
    background: var(--bg-content-secondary);
    border-radius: var(--radius-sm);
}

.stage-tiptap-editor::-webkit-scrollbar-thumb {
    background: var(--ui-border);
    border-radius: var(--radius-sm);
}

.stage-tiptap-editor::-webkit-scrollbar-thumb:hover {
    background: var(--font-secondary);
}

/* Bubble menu (TipTap BubbleMenu + tippy) */
.bubble-menu {
    display: flex;
    align-items: center;
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    padding: 4px;
    gap: 2px;
    z-index: 99999;
}

.tippy-box[data-theme~='bubble-menu'] {
    background-color: transparent;
    border: none;
    box-shadow: none;
}

.tippy-box[data-theme~='bubble-menu'] .tippy-content {
    padding: 0;
}

.bubble-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--font-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: var(--font-size-sm);
}

.bubble-menu-btn:hover {
    background: var(--bg-hover);
}

.bubble-menu-btn.is-active {
    background: var(--accent-primary);
    color: var(--color-on-accent);
}

/* Скелетон строк при первом открытии редактора описания (до монтирования TipTap) */
.gc-event-description-editor-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2xs);
    width: 100%;
    box-sizing: border-box;
    text-align: left;
}

.gc-event-description-editor-skeleton-block {
    display: flex;
    flex-direction: column;
}

/*
 * Совпадает с .event-description-text в модале: font-size md, line-height 1.6, между абзацами margin 1em (как у p).
 * Полоски — доля строки; шаг по вертикали ≈ 1.6em как у реального текста.
 */
#descriptionEditorModal #tiptapEditor .gc-event-description-editor-skeleton {
    gap: 0;
    font-size: var(--font-size-md);
    line-height: 1.6;
}

#descriptionEditorModal #tiptapEditor .gc-event-description-editor-skeleton-block + .gc-event-description-editor-skeleton-block {
    margin-top: 1em;
}

#descriptionEditorModal #tiptapEditor .gc-event-description-editor-skeleton .gc-skeleton-text {
    height: 0.55em;
    margin-bottom: calc(1.6em - 0.55em);
}

#descriptionEditorModal #tiptapEditor .gc-event-description-editor-skeleton-block .gc-skeleton-text:last-child {
    margin-bottom: 0;
}

/* Скелетон и mount — колонка до снятия loader; редактор тянется после удаления .editor-loading */
.gc-event-description-tiptap-root.tiptap-editor {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-2xs);
}

.gc-event-description-tiptap-root .gc-event-description-editor-mount {
    flex: 1 1 auto;
    min-height: 0;
}

.gc-event-description-tiptap-root .editor-loading {
    flex: 0 0 auto;
}

/*
 * Только пока висит скелетон (класс вешает description-editor.js): область загрузки = тот же прямоугольник,
 * что и у смонтированного редактора — скелетон поверх mount, без смены постоянного лейаута модала.
 */
#descriptionEditorModal.gc-event-description-modal--editor-bootstrapping #tiptapEditor.tiptap-editor {
    position: relative;
}

#descriptionEditorModal.gc-event-description-modal--editor-bootstrapping #tiptapEditor.tiptap-editor .editor-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    flex: none;
    width: auto;
    height: auto;
    box-sizing: border-box;
    pointer-events: none;
    /* inset:0 совпадает с padding-edge; как у ProseMirror — внутренние отступы как у .tiptap-editor */
    padding: var(--spacing-lg);
}

@media (max-width: 768px) {
    #descriptionEditorModal.gc-event-description-modal--editor-bootstrapping #tiptapEditor.tiptap-editor .editor-loading {
        padding: var(--spacing-md);
    }
}

#descriptionEditorModal.gc-event-description-modal--editor-bootstrapping #tiptapEditor .gc-event-description-editor-mount {
    position: relative;
    z-index: 0;
}

/* Один ребёнок после снятия скелетона — тянем редактор на высоту колонки модала */
#tiptapEditor.tiptap-editor > .gc-event-description-editor-mount:only-child {
    min-height: 100%;
}

/* Подсказки @-упоминаний (TipTap suggestion) — как панель .gc-dropdown-menu / строки .gc-dropdown-item */
.gc-mention-suggestions {
    position: fixed;
    z-index: 11050;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4xs);
    min-width: min(13.75rem, calc(100vw - var(--spacing-xl)));
    max-width: calc(100vw - var(--spacing-md));
    max-height: min(40vh, 16rem);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: var(--spacing-xs);
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.gc-mention-suggestions::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.gc-mention-suggestions-empty {
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--font-secondary);
    font-size: var(--font-size-caption);
    line-height: 1.4;
}

.gc-mention-suggestions-item {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    padding: var(--spacing-sm);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--font-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    line-height: 1.25;
    min-height: 2.25rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.gc-mention-suggestions-item:hover,
.gc-mention-suggestions-item:focus-visible {
    background: var(--bg-hover);
    color: var(--font-primary);
    outline: none;
}

/* Клавиатурное выделение — заметнее ряда, без заливки accent */
.gc-mention-suggestions-item.is-active {
    background: var(--ui-surface-2);
    color: var(--font-primary);
}

.gc-mention-suggestions-item.is-active:hover,
.gc-mention-suggestions-item.is-active:focus-visible {
    background: var(--bg-hover);
    color: var(--font-primary);
}

/* Посты: редактор композера использует тот же .stage-tiptap-editor */
.gc-post-form-editor .stage-editor-shell,
.gc-post-form-editor .stage-tiptap-editor {
    min-height: 140px;
}

/* Адаптив (ранее было в stage-editor.css) */
@media (max-width: 767.98px) {
    .gc-editor-container {
        border-radius: var(--radius-field);
        min-height: 150px;
    }

    .stage-tiptap-editor {
        min-height: 150px;
        padding: var(--spacing-md);
        font-size: var(--font-size-md);
    }

    .bubble-menu-btn {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-lg);
    }

    .bubble-menu {
        padding: 6px 8px;
    }
}

@media (max-width: 576px) {
    .stage-tiptap-editor {
        font-size: var(--font-size-sm);
        padding: var(--spacing-md);
    }
}

/* Палитра slash-команд (описание мероприятия и др.) — fixed у body */
.slash-menu {
    position: fixed;
    z-index: calc(var(--z-modal, 1055) + 2);
    min-width: 220px;
    max-width: min(360px, calc(100vw - 20px));
    padding: var(--spacing-2xs);
    border-radius: var(--radius-md);
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    box-shadow: var(--shadow-dropdown, 0 8px 24px rgba(0, 0, 0, 0.35));
}

.slash-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--font-primary);
    cursor: pointer;
}

.slash-menu-item:hover,
.slash-menu-item:focus-visible {
    background: var(--bg-hover, color-mix(in srgb, var(--font-primary) 8%, transparent));
    outline: none;
}

.slash-menu-item__title {
    display: block;
    font-size: var(--font-size-mdl);
    font-weight: 600;
}

.slash-menu-item__desc {
    display: block;
    margin-top: var(--spacing-3xs, 2px);
    font-size: var(--font-size-xs);
    color: var(--font-secondary);
}

