/**
 * Rich Input Editor Styles
 * Email-client-like rich text input with inline media support
 */

/* Goedly Brand Colors */
:root {
    --business-primary: #086E92;
    --business-secondary: #E4E264;
    --business-accent: #58B748;
}

/* Rich Editor Container */
.ai-chat-rich-editor {
    min-height: 44px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 12px;
    background: transparent;
    border: none;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    transition: all 0.2s ease;
    word-wrap: break-word;
    white-space: pre-wrap;
    width: 100%;
    box-sizing: border-box;
}

.ai-chat-rich-editor:focus {
    outline: none;
}

.ai-chat-rich-editor.drag-over {
    background: rgba(8, 110, 146, 0.05);
    border-radius: 8px;
}

/* Placeholder with hints */
.ai-chat-rich-editor.empty:not(:focus)::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
    display: block;
}

/* Hint text for file capabilities */
.ai-chat-rich-editor.empty:not(:focus)::after {
    content: "Tip: Paste images (Ctrl+V) or drag files here";
    color: #cbd5e1;
    font-size: 12px;
    font-style: italic;
    pointer-events: none;
    display: block;
    margin-top: 4px;
}

/* Inline Images */
.ai-chat-inline-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: inline-block;
    transition: all 0.2s ease;
    margin: 4px;
    vertical-align: middle;
    position: relative;
}

.ai-chat-inline-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}


/* Remove button for media */
.ai-chat-media-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 0;
    transition: transform 0.2s ease;
    pointer-events: auto !important;
    user-select: none;
    -webkit-user-select: none;
}

.ai-chat-media-wrapper:hover .ai-chat-media-remove {
    display: flex;
}

.ai-chat-media-remove:hover {
    transform: scale(1.1);
    background: #dc2626;
}

.ai-chat-media-remove i {
    width: 12px;
    height: 12px;
}

/* Attachment Chips */
.ai-chat-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f0f4f8, #e2e8f0);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    padding: 4px 8px 4px 10px;
    margin: 2px;
    font-size: 13px;
    vertical-align: middle;
    transition: all 0.2s ease;
    cursor: default;
    max-width: 250px;
}

.ai-chat-attachment-chip:hover {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-chat-attachment-chip i {
    width: 16px;
    height: 16px;
    color: #64748b;
    flex-shrink: 0;
}

.ai-chat-attachment-chip .attachment-name {
    color: #334155;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.ai-chat-attachment-chip .attachment-size {
    color: #94a3b8;
    font-size: 11px;
    margin-left: 4px;
    flex-shrink: 0;
}

.ai-chat-attachment-chip .attachment-remove {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    pointer-events: auto !important;
    user-select: none;
    -webkit-user-select: none;
}

.ai-chat-attachment-chip .attachment-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.ai-chat-attachment-chip .attachment-remove i {
    width: 12px;
    height: 12px;
}

/* Updated input wrapper styles */
.ai-chat-input-wrapper {
    flex: 1;
    position: relative;
    background: transparent;
    border: none;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    z-index: 1; /* Above the gradient animation */
}

.ai-chat-input-wrapper:focus-within {
    /* No visual change on focus */
}

.ai-chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px;
    background: #f8fafc;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

/* Inline attachments preview area */
.ai-chat-inline-attachments {
    padding: 8px 12px;
    background: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

/* Upload progress indicator */
.ai-chat-upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(8, 110, 146, 0.1);
    border-radius: 1px;
    overflow: hidden;
}

.ai-chat-upload-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: var(--business-primary);
    width: var(--progress, 0%);
    transition: width 0.3s ease;
}

/* Attachment button */
.ai-chat-attach {
    position: relative;
}

/* Visual drag zone indicator */
.ai-chat-input-wrapper.drag-active {
    background: linear-gradient(135deg, rgba(8, 110, 146, 0.08), rgba(88, 183, 72, 0.04));
}

.ai-chat-input-wrapper.drag-active::before {
    content: "Drop files here to add them";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--business-primary);
    font-weight: 500;
    pointer-events: none;
    z-index: 1000;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .ai-chat-inline-image {
        max-width: 150px;
        max-height: 100px;
    }
    
    .ai-chat-attachment-chip {
        max-width: 200px;
        font-size: 12px;
    }
    
    .ai-chat-rich-editor {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ai-chat-rich-editor.empty:not(:focus)::after {
        content: "Tap paperclip or paste images";
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-chat-rich-editor {
        background: #1e293b;
        color: #e2e8f0;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .ai-chat-attachment-chip {
        background: linear-gradient(135deg, #334155, #475569);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .ai-chat-attachment-chip:hover {
        background: linear-gradient(135deg, #475569, #64748b);
    }
    
    .ai-chat-attachment-chip .attachment-name {
        color: #e2e8f0;
    }
    
    .ai-chat-attachment-chip .attachment-size {
        color: #94a3b8;
    }
}