/* Document Attachment Styles - Simple Design */

/* Upload Button - Compact and aligned */
.chat-upload-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-bottom: 4px;
    order: 1;
}

.chat-upload-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #9ca3af;
}

/* Upload button when document is attached */
.chat-upload-btn.has-attachment {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.input-box .attachment-preview {
    flex-shrink: 0;
    align-self: flex-end;
    margin-left: 36px;
    margin-right: 8px;
    margin-bottom: 4px;
    order: 2;
}

/* Ensure textarea is properly positioned */
.input-box .chat-input {
    flex: 1;
    min-width: 200px;
    order: 3;
}

/* Ensure send button is properly positioned */
.input-box .send-btn {
    flex-shrink: 0;
    margin-left: 0.5rem;
    align-self: flex-end;
    margin-bottom: 4px;
    order: 4;
}

/* Input box with attachment - dynamic width */
.input-box.has-attachment {
    transition: all 0.3s ease;
}

.chat-upload-btn svg {
    width: 20px;
    height: 20px;
}

/* Already defined above in clean design */

.chat-upload-btn:active {
    background: rgba(124, 58, 237, 0.2);
}

.chat-upload-btn.uploading {
    pointer-events: none;
    opacity: 0.6;
}

.chat-upload-btn .upload-spinner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

.chat-upload-btn.uploading .upload-spinner {
    display: block;
}

.chat-upload-btn.uploading svg {
    opacity: 0;
}

/* Upload Progress Bar */
.upload-progress {
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 1px;
    overflow: hidden;
    display: none;
}

.upload-progress.active {
    display: block;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

.document-attachment-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin: 8px 0;
    max-width: 180px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
    color: #9ca3af;
    font-size: 11px;
}

.document-attachment-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Card styling when inside a message bubble - same as input box */
.message-content .document-attachment-card {
    /* Inherits main card styles, no overrides needed */
}

.message-content .document-attachment-card:hover {
    /* Inherits main hover styles */
}

/* For assistant messages */
.assistant .message-content .document-attachment-card {
    /* Same as regular cards, no special styling */
}

.assistant .message-content .document-attachment-card:hover {
    /* Inherits main hover styles */
}

.doc-icon-wrapper {
    width: 14px;
    height: 14px;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: none;
    opacity: 0.7;
}

/* Icon for attachments inside messages - same as input box */
.message-content .doc-icon-wrapper {
    /* Inherits main icon styles */
}

.doc-icon-wrapper svg {
    width: 14px;
    height: 14px;
    color: #9ca3af;
}

.message-content .doc-icon-wrapper svg {
    /* Inherits main svg styles */
}

.doc-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.doc-filename {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 1px;
    text-shadow: none;
    max-width: 80px;
}

/* Filename styling inside messages - same as input box */
.message-content .doc-filename {
    /* Inherits main filename styles */
}

.doc-metadata {
    font-size: 10px;
    color: #666;
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Metadata styling inside messages - same as input box */
.message-content .doc-metadata {
    /* Inherits main metadata styles */
}

.doc-size, .doc-entities {
    display: flex;
    align-items: center;
    gap: 4px;
}

.remove-doc-btn {
    width: 14px;
    height: 14px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: none;
    opacity: 0.5;
    padding: 0;
}

.remove-doc-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    opacity: 1;
}

/* Hide remove button for attachments inside messages */
.message-content .remove-doc-btn {
    display: none;
}

.remove-doc-btn svg {
    width: 14px;
    height: 14px;
    color: #9ca3af;
}

/* Attachment Preview - Clean white card */
.attachment-preview {
    display: none;
    align-items: center;
    margin-right: 8px;
    align-self: flex-end;
}

.attachment-preview.show {
    display: inline-flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Input wrapper styling */
.input-wrapper {
    position: relative;
    width: 100%;
}

.input-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.attachment-preview .document-attachment-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 11px;
    color: #9ca3af;
}

.attachment-preview .doc-icon-wrapper {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.attachment-preview .doc-icon-wrapper svg {
    width: 14px;
    height: 14px;
    color: #9ca3af;
}

.attachment-preview .doc-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.attachment-preview .doc-filename {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: #9ca3af;
}

.attachment-preview .doc-size {
    font-size: 10px;
    color: #666;
}

.attachment-preview .remove-doc-btn {
    display: flex;
    width: 14px;
    height: 14px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.attachment-preview .remove-doc-btn:hover {
    opacity: 1;
}

.attachment-preview .remove-doc-btn svg {
    width: 14px;
    height: 14px;
    color: #9ca3af;
}

/* Message with attachment */
.message-with-attachment {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Attachment container INSIDE message bubble */
.message-content .message-attachments {
    display: inline-block;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

/* For assistant messages */
.assistant .message-content .message-attachments {
    background: transparent;
    border: none;
}

/* Upload zone styling */
.upload-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(139, 92, 246, 0.1);
    border: 2px dashed #8b5cf6;
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.upload-zone.active {
    display: flex;
}

.upload-zone-content {
    text-align: center;
    color: #8b5cf6;
    font-weight: 500;
}

.upload-zone-content svg {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    opacity: 0.8;
}

/* Drag and drop states */
.dragging .input-wrapper {
    position: relative;
}

.dragging .upload-zone {
    display: flex;
}

/* File type icons */
.file-type-pdf { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.file-type-doc { background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%); }
.file-type-txt { background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); }
.file-type-csv { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); }

/* Animation for attachment appearance */
@keyframes slideInFromBottom {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.document-attachment-card {
    animation: slideInFromBottom 0.3s ease;
}

.attachment-preview .remove-doc-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    /* transform removed to prevent movement */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Hover effects */
.attachment-preview .document-attachment-card:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(200, 200, 200, 0.5);
}

/* Loading state for document upload */
.document-uploading {
    opacity: 0.6;
    pointer-events: none;
}

.document-uploading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Removed tooltip pseudo-elements to fix hover black line issue */
/* Using native title attribute for better UX instead */

/* Pulse animation for better visibility */
@keyframes pulse-upload {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(139, 92, 246, 0);
    }
}

/* Removed pulse animation on hover for cleaner UX */

/* Success animation */
@keyframes upload-success {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.chat-upload-btn.success {
    animation: upload-success 0.5s ease;
    background: rgba(16, 185, 129, 0.1);
    color: #4c8bca;
}

.chat-upload-btn.success svg {
    animation: checkmark 0.5s ease;
    color: #4c8bca;
    filter: drop-shadow(0 2px 4px rgba(76, 139, 202, 0.3));
}

@keyframes checkmark {
    0% {
        transform: scale(0) rotate(-45deg);
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* Drag and Drop Zone */
.upload-drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(139, 92, 246, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}

.upload-drop-zone.active {
    display: flex;
    pointer-events: all;
    animation: fadeIn 0.2s ease;
}

.upload-drop-content {
    text-align: center;
    color: white;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    animation: slideUp 0.3s ease;
}

.upload-drop-content svg {
    margin-bottom: 20px;
    /* animation removed to stop up/down motion */
}

.drop-text {
    font-size: 24px;
    font-weight: 600;
    margin: 16px 0 8px 0;
}

.drop-subtext {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* bounce-down animation removed */

/* Document Preview Modal */
.document-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.document-modal-content {
    background: #2b2b2b;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    max-width: 80%;
    max-height: 80%;
    width: 800px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.document-modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-modal-header h3 {
    margin: 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.document-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.document-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.document-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    background: #202023;
}

#document-modal-text {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #e5e7eb;
    font-size: 14px;
    line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
}

/* Arabic text in modal */
#document-modal-text:lang(ar),
[dir="rtl"] #document-modal-text {
    font-family: 'IBM Plex Sans Arabic', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    text-align: right;
    direction: rtl;
}

/* Darken chat container when dragging */
.chat-container.dragging {
    filter: brightness(0.3);
    transition: filter 0.3s ease;
}