/**
 * CODDB Chat File Upload Styles
 * Styles for file upload preview, drag & drop, and file display
 */

/* Upload Preview Container */
.coddb-chat-upload-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

/* Upload Item */
.coddb-chat-upload-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.coddb-chat-upload-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(var(--accent-color-rgb), 0.2);
}

.coddb-chat-upload-item:last-child {
    margin-bottom: 0;
}

/* Upload Item Header */
.coddb-chat-upload-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.coddb-chat-upload-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.coddb-chat-upload-info {
    flex: 1;
    min-width: 0;
}

.coddb-chat-upload-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coddb-chat-upload-size {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.coddb-chat-upload-remove {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.coddb-chat-upload-remove:hover {
    background: color-mix(in srgb, var(--error-color) 80%, black);
    transform: scale(1.1);
}

/* Upload Preview Content */
.coddb-chat-upload-preview-content {
    margin: 8px 0;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

.coddb-chat-upload-image-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}

.coddb-chat-upload-text-preview {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
}

/* Upload Actions */
.coddb-chat-upload-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.coddb-chat-upload-actions button {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.coddb-chat-upload-actions button:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent-color) 80%, white);
    transform: translateY(-1px);
}

.coddb-chat-upload-actions button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.coddb-chat-upload-actions button.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.coddb-chat-upload-actions button.secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

/* Drag and Drop Styles */
.coddb-chat-drag-over {
    background: color-mix(in srgb, var(--accent-color) 10%, var(--bg-primary));
    border: 2px dashed var(--accent-color);
    position: relative;
}

.coddb-chat-drag-over::after {
    content: "📁 Drop files here to upload";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    padding: 20px 40px;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 16px;
    z-index: 1000;
    pointer-events: none;
}

/* File Input Enhancement */
.coddb-chat-file-upload {
    position: relative;
}

.coddb-chat-file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.coddb-chat-file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.coddb-chat-file-label:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

/* Message File Attachments */
.coddb-chat-message-attachment {
    margin: 8px 0;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.coddb-chat-message-attachment:hover {
    border-color: var(--accent-color);
    background: var(--bg-hover);
}

.coddb-chat-attachment-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.coddb-chat-attachment-info {
    flex: 1;
    min-width: 0;
}

.coddb-chat-attachment-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coddb-chat-attachment-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.coddb-chat-attachment-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.coddb-chat-attachment-action {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.coddb-chat-attachment-action:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Image Attachment Styles */
.coddb-chat-message-image {
    margin: 8px 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.coddb-chat-message-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.coddb-chat-message-image img:hover {
    transform: scale(1.02);
}

.coddb-chat-image-caption {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-secondary);
}

/* File Preview Modal */
.coddb-chat-file-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.coddb-chat-file-preview-content {
    background: var(--bg-primary);
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.coddb-chat-file-preview-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}

.coddb-chat-file-preview-title {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.coddb-chat-file-preview-close {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.coddb-chat-file-preview-close:hover {
    background: color-mix(in srgb, var(--error-color) 80%, black);
    transform: scale(1.1);
}

.coddb-chat-file-preview-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.coddb-chat-file-preview-code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

/* File Type Specific Styles */
.coddb-file-type-image .coddb-chat-attachment-icon { color: #4CAF50; }
.coddb-file-type-document .coddb-chat-attachment-icon { color: #2196F3; }
.coddb-file-type-archive .coddb-chat-attachment-icon { color: #FF9800; }
.coddb-file-type-code .coddb-chat-attachment-icon { color: #9C27B0; }
.coddb-file-type-text .coddb-chat-attachment-icon { color: #607D8B; }

/* Loading States */
.coddb-chat-upload-loading {
    opacity: 0.6;
    pointer-events: none;
}

.coddb-chat-upload-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: coddb-spin 1s linear infinite;
}

@keyframes coddb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .coddb-chat-upload-preview {
        margin-left: -16px;
        margin-right: -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .coddb-chat-message-attachment {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .coddb-chat-attachment-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .coddb-chat-file-preview-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .coddb-chat-file-preview-header {
        padding: 12px 16px;
    }
    
    .coddb-chat-file-preview-body {
        padding: 16px;
    }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
    .coddb-chat-upload-text-preview {
        color: #e0e0e0;
    }
    
    .coddb-chat-file-preview-code {
        background: #1a1a1a;
        color: #e0e0e0;
        border-color: #333;
    }
}
