/**
 * TaskFlow Rich Text Editor Styles
 * 재사용 가능한 리치 텍스트 에디터 CSS
 */

/* 에디터 컨테이너 */
.tf-editor-container {
    border: 1px solid var(--border);
    border-radius: var(--z-radius-sm);
    overflow: hidden;
    background: var(--bg-secondary);
    transition: border-color var(--z-dur) var(--z-ease), box-shadow var(--z-dur) var(--z-ease);
}

.tf-editor-container:focus-within {
    border-color: var(--z-form-accent);
    box-shadow: var(--z-focus-ring);
}

/* 툴바 */
.tf-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.tf-editor-toolbar-group {
    display: flex;
    gap: 2px;
    padding-right: 6px;
    margin-right: 6px;
    border-right: 1px solid var(--border);
}

.tf-editor-toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.tf-editor-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--z-radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: background var(--z-dur) var(--z-ease), color var(--z-dur) var(--z-ease);
}

.tf-editor-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 활성 = 옅은 키컬러 면 + 잉크(키컬러 채움 금지) */
.tf-editor-btn.active {
    background: var(--z-accent-light);
    color: var(--text-primary);
}

/* 에디터 본문 */
.tf-editor-content {
    min-height: 300px;
    max-height: 600px;
    padding: 16px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    outline: none;
    overflow-y: auto;
    resize: vertical;
}

.tf-editor-content:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

/* 에디터 내 요소 스타일 */
.tf-editor-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}

.tf-editor-content a {
    color: var(--accent-blue);
}

.tf-editor-content blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 16px;
    margin: 8px 0;
    color: var(--text-secondary);
}

.tf-editor-content .quote-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 12px 0;
    position: relative;
    font-style: italic;
}

.tf-editor-content .quote-box::before {
    content: '"';
    font-size: 48px;
    color: var(--accent-blue);
    opacity: 0.3;
    position: absolute;
    top: -10px;
    left: 10px;
    font-family: Georgia, serif;
}

.tf-editor-content .quote-single {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    font-style: italic;
    color: var(--text-secondary);
}

.tf-editor-content .quote-single::before {
    content: "'";
    font-size: 24px;
    color: var(--accent-purple);
    margin-right: 4px;
}

.tf-editor-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.tf-editor-content pre {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

.tf-editor-content ul, .tf-editor-content ol {
    padding-left: 24px;
    margin: 8px 0;
}

/* 힌트 */
.tf-editor-hint {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
}

/* 드롭다운 메뉴 */
.tf-editor-dropdown {
    position: relative;
    display: inline-block;
}

.tf-editor-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--z-radius-sm);
    padding: 6px;
    z-index: 100;
    min-width: 140px;
    box-shadow: var(--z-shadow-float);
}

.tf-editor-dropdown:hover .tf-editor-dropdown-content {
    display: block;
}

.tf-editor-dropdown-item {
    display: block;
    width: 100%;
    min-height: 36px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--z-radius-xs);
}

.tf-editor-dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 색상 선택기 */
.tf-color-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 4px;
}

.tf-color-picker-item {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
}

.tf-color-picker-item:hover {
    border-color: var(--text-primary);
}

/* 렌더링된 콘텐츠 스타일 (상세 페이지 등) */
.tf-rendered-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}

.tf-rendered-content a {
    color: var(--accent-blue);
}

.tf-rendered-content blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 16px;
    margin: 8px 0;
    color: var(--text-secondary);
}

.tf-rendered-content .quote-box {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 12px 0;
    position: relative;
    font-style: italic;
}

.tf-rendered-content .quote-box::before {
    content: '"';
    font-size: 48px;
    color: var(--accent-blue);
    opacity: 0.3;
    position: absolute;
    top: -10px;
    left: 10px;
    font-family: Georgia, serif;
}

.tf-rendered-content .quote-single {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    font-style: italic;
    color: var(--text-secondary);
}

.tf-rendered-content .quote-single::before {
    content: "'";
    font-size: 24px;
    color: var(--accent-purple);
    margin-right: 4px;
}

.tf-rendered-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.tf-rendered-content pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

.tf-rendered-content ul, .tf-rendered-content ol {
    padding-left: 24px;
    margin: 8px 0;
}

/* 이미지 리사이즈/회전 UI */
.tf-image-wrapper {
    display: inline-block;
    position: relative;
    margin: 8px 0;
    cursor: default;
    user-select: none;
    -webkit-user-drag: none;
}

.tf-image-wrapper img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.tf-image-wrapper.selected {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* 리사이즈 핸들 */
.tf-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent-blue);
    border: 2px solid white;
    border-radius: 50%;
    z-index: 10;
    display: none;
}

.tf-image-wrapper.selected .tf-resize-handle {
    display: block;
}

.tf-resize-handle.tf-nw { top: -6px; left: -6px; cursor: nw-resize; }
.tf-resize-handle.tf-ne { top: -6px; right: -6px; cursor: ne-resize; }
.tf-resize-handle.tf-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.tf-resize-handle.tf-se { bottom: -6px; right: -6px; cursor: se-resize; }
.tf-resize-handle.tf-n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.tf-resize-handle.tf-s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.tf-resize-handle.tf-w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }
.tf-resize-handle.tf-e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }

/* 회전 핸들 */
.tf-rotate-handle {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: var(--accent-purple);
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

.tf-rotate-handle::before {
    content: '↻';
    font-size: 14px;
}

.tf-rotate-handle:active {
    cursor: grabbing;
}

.tf-image-wrapper.selected .tf-rotate-handle {
    display: flex;
}

/* 회전 핸들 연결선 */
.tf-rotate-line {
    position: absolute;
    top: -23px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: var(--accent-purple);
    transform: translateX(-50%);
    display: none;
}

.tf-image-wrapper.selected .tf-rotate-line {
    display: block;
}

/* 이미지 크기 표시 */
.tf-image-size-info {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--z-cta);
    color: var(--z-cta-text);
    padding: 2px 8px;
    border-radius: var(--z-radius-xs);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    display: none;
}

.tf-image-wrapper.resizing .tf-image-size-info,
.tf-image-wrapper.selected:hover .tf-image-size-info {
    display: block;
}

/* 이미지 액션 버튼 */
.tf-image-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

.tf-image-wrapper.selected .tf-image-actions {
    display: flex;
}

.tf-image-action-btn {
    width: 28px;
    height: 28px;
    background: rgba(11, 12, 13, 0.62);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.tf-image-action-btn:hover {
    background: rgba(11, 12, 13, 0.82);
}

.tf-image-action-btn.delete:hover {
    background: var(--z-error);
}

/* ── 우클릭 메뉴(editor/editor-context-menu.js, 2026-10-01) — 문서·슬라이드 메뉴(.ec-menu)와 같은 생김새 ── */
.tfe-ctx { position: fixed; z-index: 30000; min-width: 224px; padding: 6px; background: var(--bg-secondary, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: var(--z-radius-sm, 12px); box-shadow: var(--z-shadow-float, 0 8px 24px rgba(0,0,0,.14)); }
.tfe-ctx-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 0 12px; background: transparent; border: none; border-radius: var(--z-radius-xs, 8px); color: var(--text-primary, #111); font-size: 14px; cursor: pointer; text-align: left; }
.tfe-ctx-item:hover:not(:disabled) { background: var(--bg-tertiary, #f3f4f6); }
.tfe-ctx-item:disabled { opacity: .4; cursor: default; }
.tfe-ctx-item.danger, .tfe-ctx-item.danger .tfe-ctx-ic { color: var(--z-danger, #dc2626); }
.tfe-ctx-ic { width: 18px; display: inline-flex; justify-content: center; color: var(--text-secondary, #4b5563); flex-shrink: 0; }
.tfe-ctx-lb { flex: 1; white-space: nowrap; }
.tfe-ctx-kbd { margin-left: 18px; font-size: 12px; color: var(--text-muted, #6b7280); white-space: nowrap; }
.tfe-ctx-head { font-size: 12px; font-weight: 600; color: var(--text-muted, #6b7280); padding: 4px 12px 2px; }
.tfe-ctx-sep { height: 1px; background: var(--border, #e5e7eb); margin: 6px 4px; }
.tfe-ctx-note { max-width: 260px; font-size: 12px; color: var(--text-muted, #6b7280); padding: 6px 12px; }
