/* === TipTap Smooth Caret Chat Input === */

/* Wrapper: same style as textarea */
.tiptap-input-wrap {
    position: relative;
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    background: #fff;
    transition: border-color 0.2s;
    overflow: hidden;
}
.tiptap-input-wrap:focus-within {
    border-color: var(--accent, #667eea);
}

/* EditorContent wrapper div — MUST use :first-child to avoid matching caret div */
.tiptap-input-wrap > div:first-child {
    display: flex;
    flex-direction: column;
}

/* TipTap editor area */
.tiptap-input-wrap .tiptap-chat {
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    min-height: 38px;
    max-height: 120px;
    padding: 9px 14px;
    line-height: 1.4;
    font-size: 15px;
    font-family: inherit;
    flex: 1;
    text-rendering: optimizeSpeed;
    -webkit-user-select: text;
    user-select: text;
    -webkit-tap-highlight-color: transparent;
}

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

/* Remove default paragraph margins in chat */
.tiptap-input-wrap .tiptap-chat p {
    margin: 0;
}

/* Smooth caret blink */
@keyframes caretBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Hide textarea when TipTap is active */
.chat-form-row textarea[style*="display: none"],
.chat-form-row textarea[style*="display:none"] {
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    overflow: hidden;
    position: absolute;
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .tiptap-input-wrap .tiptap-chat {
        max-height: 80px;
        font-size: 16px; /* prevent iOS zoom */
        min-height: 36px;
        padding: 8px 12px;
    }
}
