/* Publication Manuscript Chat Input Area Styles */

.publication-manuscript-chat-input-area {
    position: fixed;
    bottom: 2px;
    left: 300px;
    right: 350px;
    z-index: 1050;
    
    width: auto;
    max-width: none;
    max-height: 100vh; /* Full viewport height */
    
    background-color: var(--bg-primary, #ffffff);
    border-radius: 8px;
    
    /* Flexbox layout for proper structure */
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.publication-manuscript-input-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 200px;
    max-height: calc(100vh - 4px); /* Account for bottom positioning */
    padding: 0;
    margin: 0;
    overflow: hidden; /* Prevent container overflow */
}

/* Header/Title Area */
.publication-manuscript-header {
    background-color: var(--bg-secondary, #f8f9fa);
}

.publication-manuscript-title-input {
    width: 100%;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    background-color: var(--bg-primary, #ffffff);
}

.publication-manuscript-title-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* Scrollable Content Area */
.publication-manuscript-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Allow flex shrinking */
    max-height: calc(100vh - 200px); /* Reserve space for header and actions */
    
    /* Better scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color, #dee2e6) transparent;
}

/* Webkit scrollbar styling for better appearance */
.publication-manuscript-content::-webkit-scrollbar {
    width: 6px;
}

.publication-manuscript-content::-webkit-scrollbar-track {
    background: transparent;
}

.publication-manuscript-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color, #dee2e6);
    border-radius: 3px;
}

.publication-manuscript-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted, #6c757d);
}

/* Bottom Actions */
.publication-manuscript-bottom-actions {
    background-color: var(--bg-primary, #ffffff);
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}

/* Query Input Item for Research Description and Research Data */
.publication-manuscript-content .query-input-item {
    background-color: var(--bg-primary, #ffffff);
}

.publication-manuscript-content .query-input-item:hover {
    border-color: var(--primary-color, #007bff);
}

.publication-manuscript-content .query-input-item:last-child {
    margin-bottom: 0; /* Remove margin from last item */
}

.publication-manuscript-content .query-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.publication-manuscript-content .query-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #333);
}

.publication-manuscript-content .text-input-wrapper {
    position: relative;
}

.publication-manuscript-content .query-textarea {
    width: 100%;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    padding: 8px 12px;
    padding-bottom: 40px; /* Space for controls */
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    transition: height 0.1s ease;
}

.publication-manuscript-content .query-textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.publication-manuscript-content .control-buttons {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 5px;
}

.publication-manuscript-content .control-btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action buttons styling */
.publication-manuscript-bottom-actions .action-buttons-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
}

.publication-manuscript-bottom-actions .add-more-btn {
    background-color: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    color: var(--text-primary, #333);
    width: 230px;
    height: 35px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.publication-manuscript-bottom-actions .add-more-btn:hover {
    background-color: var(--bg-hover, #e9ecef);
}

.publication-manuscript-bottom-actions .run-all-btn {
    background-color: #007bff;
    border: 1px solid #007bff;
    color: white;
    width: 230px;
    height: 35px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.publication-manuscript-bottom-actions .run-all-btn:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

/* Attached files styling */
.publication-manuscript-content .attached-files {
    margin-top: 8px;
    padding: 4px 0;
}

.publication-manuscript-content .file-preview-item {
    display: inline-block;
    margin: 2px;
    background-color: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
}

.publication-manuscript-content .file-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.publication-manuscript-content .file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.publication-manuscript-content .btn-remove-file {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-left: 4px;
}

.publication-manuscript-content .btn-remove-file:hover {
    background: #c82333;
}

/* Theme support */
[data-theme="dark"] .publication-manuscript-title-input {
    background-color: var(--bg-primary);
    color: white;
    border-color: #4a5568;
}

[data-theme="dark"] .publication-manuscript-title-input:focus {
    background-color: var(--bg-primary);
    border-color: #007bff;
}

[data-theme="dark"] .publication-manuscript-content .query-textarea {
    background-color: var(--bg-primary);
    color: white;
    border-color: #4a5568;
}

[data-theme="dark"] .publication-manuscript-content .query-textarea:focus {
    background-color: var(--bg-primary);
    border-color: #007bff;
}

/* Mobile responsive adjustments for publication manuscript */
@media (max-width: 1000px) {
    .publication-manuscript-chat-input-area {
        width: 100%;
        max-width: 100%;
        margin: 0 !important;
        left: 5px;
        right: 5px;
        bottom: 5px;
        max-height: 90vh;
        padding: 0;
    }
    
    .publication-manuscript-bottom-actions .action-buttons-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .publication-manuscript-bottom-actions .add-more-btn,
    .publication-manuscript-bottom-actions .run-all-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .publication-manuscript-content .control-btn {
        padding: 3px 5px;
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    .publication-manuscript-header {
        padding: 8px;
    }
    
    .publication-manuscript-content {
        padding: 12px;
        max-height: calc(100vh - 180px); /* Smaller header/actions on mobile */
    }
    
    .publication-manuscript-bottom-actions {
        padding: 8px;
    }
    
    .publication-manuscript-content .query-input-item {
        margin-bottom: 16px; /* Slightly less spacing on mobile */
        padding: 12px;
    }
    
    .publication-manuscript-content .query-textarea {
        min-height: 80px;
        font-size: 13px;
    }
}

/* Publication Manuscript File Preview Styles - Matching Multi-Query Mode Exactly */
.file-preview-inside-textarea {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 120px; /* Space for control buttons */
    z-index: 5;
    max-height: 70px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    background: transparent;
    pointer-events: none; /* Prevent blocking textarea clicks */
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0;
}

/* Use the same file-preview-item class as multi-query mode */
.publication-manuscript-content .file-preview-item {
    margin: 2px;
    flex-shrink: 0;
    pointer-events: all; /* Re-enable pointer events for individual file items */
}

.publication-manuscript-content .file-preview-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* File thumbnail container - exact match with multi-query */
.publication-manuscript-content .file-preview-item .file-thumbnail {
    width: 60px !important;
    height: 60px !important;
    position: relative;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.2s ease;
}

.publication-manuscript-content .file-preview-item .thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* File icon for non-images - exact match with multi-query */
.publication-manuscript-content .file-preview-item .file-icon {
    width: 100%;
    height: 60px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-color);
    background: var(--code-bg);
}

/* Remove file button - exact match with multi-query */
.publication-manuscript-content .file-preview-item .btn-remove-file {
    position: absolute;
    top: 0px;
    right: 38px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}

.publication-manuscript-content .file-preview-item .btn-remove-file:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* File name overlay - exact match with multi-query */
.publication-manuscript-content .file-preview-item .file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 8px;
    padding: 2px 4px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Dark theme support */
[data-theme="dark"] .publication-manuscript-content .file-preview-item {
    background-color: var(--bg-dark-secondary, #2d3748);
    border-color: var(--border-dark, #4a5568);
}

[data-theme="dark"] .publication-manuscript-content .file-preview-item .file-icon {
    color: var(--text-dark-primary, #e2e8f0);
    background: var(--code-bg-dark, #1a202c);
}

[data-theme="dark"] .publication-manuscript-content .file-preview-item .file-name {
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

/* Warm theme support */
[data-theme="warm"] .publication-manuscript-content .file-preview-item {
    background-color: var(--bg-warm-secondary, #3d2818);
    border-color: var(--border-warm, #5a412e);
}

[data-theme="warm"] .publication-manuscript-content .file-preview-item .file-icon {
    color: var(--text-warm-primary, #f5e6d3);
    background: var(--code-bg-warm, #2d1810);
}

[data-theme="warm"] .publication-manuscript-content .file-preview-item .file-name {
    background: rgba(0, 0, 0, 0.8);
    color: white;
}