/* 
 * PowerOn | Multi-Agent Service - Files Component Styles
 * Styles for file upload, preview, and management
 * CSS Variables sind in styles_variables.css definiert
 */

/* File preview is now handled by modal - old container styles removed */

/* File preview types */
.file-preview-image {
  max-width: 100%;
  margin: 0 auto;
  display: block;
}

.file-preview-text {
  white-space: pre-wrap;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.875rem;
  overflow: auto;
  padding: 0.5rem;
  background-color: var(--color-bg);
  border: 1px solid var(--color-medium-gray);
  border-radius: 15px;
}

.file-preview-pdf {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

.file-preview-unsupported {
  font-style: italic;
  color: var(--color-gray);
  margin-top: 1rem;
  font-family: var(--font-family);
}

/* File information display */
.file-info {
  text-align: center;
  padding: 2rem;
  font-family: var(--font-family);
}

/* Message document file items */
.message-documents .file-item {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.5rem;
  margin: 0.25rem 0;
  background-color: var(--color-highlight-gray);
  border: 1px solid var(--color-medium-gray);
  border-radius: 15px;
  gap: 0.5rem;
}

.message-documents .file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  text-align: left;
  padding: 0;
}

.message-documents .file-info i {
  font-size: 0.875rem;
  color: var(--color-gray);
  width: 1rem;
  text-align: center;
}

.message-documents .file-actions {
  display: flex;
  gap: 0.25rem;
  margin-right: 0.5rem;
}

.message-documents .file-actions button {
  padding: 0.125rem 0.375rem;
  background: none;
  border: 1px solid var(--color-gray-disabled);
  border-radius: 15px;
  color: var(--color-gray);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.75rem;
  font-family: var(--font-family);
}

.message-documents .file-actions button:hover {
  background-color: var(--color-highlight-gray);
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

.message-documents .file-size {
  font-size: 0.75rem;
  color: var(--color-gray);
  font-family: monospace;
  min-width: 3rem;
  text-align: right;
}

.message-documents .file-name {
  font-size: 0.875rem;
  color: #374151;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info h4 {
  margin: 1rem 0 0.5rem;
}

.file-info p {
  margin: 0.25rem 0;
  color: #4b5563;
}

.file-actions {
  display: flex;
  align-items: center;
}

/* User input area for files */
.user-input-area {
  padding: 1rem;
}

.user-input-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#user-message-input {
  width: 100%;
  min-height: 80px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  overflow-y: auto;
}

#user-message-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

#user-message-input.awaiting-input {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.user-input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Additional files container - improved visibility */
.additional-files-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 10px;
  height: 100%;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  background-color: #f9fafb;
}

.additional-file-item {
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  font-size: 0.875rem;
}

.additional-file-item i {
  margin-right: 10px;
  color: #6b7280;
}

.file-name {
  flex: 1;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-all;
}

.remove-additional-file {
  color: #ef4444;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  margin-left: 8px;
}

.remove-additional-file:hover {
  background-color: #fee2e2;
}

/* File dropzone */
.file-dropzone-wrapper {
  position: relative;
}

.file-dropzone-wrapper.dragging {
  outline: 2px dashed #3b82f6;
  background-color: rgba(59, 130, 246, 0.1);
}

.file-dropzone-wrapper.dragging::after {
  content: "Drop files here";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.9);
  padding: 10px 15px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  font-weight: bold;
  color: #2196F3;
}

/* Selected files preview - improved visibility */
.selected-files-preview {
  margin: 8px 0 12px 0;
  background-color: #f0f9ff;  /* Light blue background for better visibility */
  border: 1px solid #93c5fd;  /* Blue border */
  border-radius: 0.25rem;
  padding: 8px;
  display: block;  /* Ensure it's visible */
  width: 100%;
}

.files-preview-header {
  font-size: 0.75rem;
  font-weight: 600;  /* Slightly bolder */
  color: #3b82f6;  /* Blue text to match border */
  margin-bottom: 8px;
}

.files-preview-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-preview-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.file-preview-item:last-child {
  margin-bottom: 0;
}

.file-preview-item i {
  margin-right: 8px;
  color: #6b7280;
}

.file-preview-item span {
  flex: 1;
  word-wrap: break-word;
  word-break: break-all;
}

.remove-file-btn {
  color: #ef4444;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: 50%;
}

.remove-file-btn:hover {
  background-color: #fee2e2;
}

/* No files message */
.no-files-message {
  color: #6b7280;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* Loading states */
.loading-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #6b7280;
}

.loading-preview i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* Error states */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #6b7280;
  text-align: center;
}

.error-state i {
  font-size: 3rem;
  color: #ef4444;
  margin-bottom: 1rem;
}

.error-state h4 {
  margin: 0 0 0.5rem 0;
  color: #111827;
}

.error-state p {
  margin: 0;
  color: #6b7280;
}

/* Animation */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.pulse-attention {
  animation: pulse 2s infinite;
}

/* Formatted preview */
.formatted-preview {
  padding: 15px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #333;
  overflow: auto;
}

.formatted-preview code {
  font-family: 'Courier New', Courier, monospace;
  background-color: #f5f5f5;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
  color: #d63384;
}

.formatted-preview pre {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  overflow: auto;
  margin: 10px 0;
}

.formatted-preview pre code {
  background-color: transparent;
  padding: 0;
  color: #333;
  font-size: 0.9em;
  white-space: pre;
}

.formatted-preview h1, 
.formatted-preview h2, 
.formatted-preview h3 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.formatted-preview h1 {
  font-size: 1.5em;
  border-bottom: 1px solid #eaecef;
  padding-bottom: 0.3em;
}

.formatted-preview h2 {
  font-size: 1.25em;
  border-bottom: 1px solid #eaecef;
  padding-bottom: 0.3em;
}

.formatted-preview h3 {
  font-size: 1em;
}

.formatted-preview ul, 
.formatted-preview ol {
  padding-left: 2em;
  margin-top: 0;
  margin-bottom: 16px;
}

.formatted-preview li + li {
  margin-top: 0.25em;
}

.formatted-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

.formatted-preview table th, 
.formatted-preview table td {
  border: 1px solid #ddd;
  padding: 6px 13px;
}

.formatted-preview table tr {
  background-color: #fff;
  border-top: 1px solid #c6cbd1;
}

.formatted-preview table tr:nth-child(2n) {
  background-color: #f6f8fa;
}

.formatted-preview table th {
  background-color: #f6f8fa;
  font-weight: 600;
}

/* Copy notification */
.copy-notification {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: #10b981;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  animation: fadeIn 0.3s ease, fadeOut 0.5s ease 1.5s forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

.additional-files-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 10px;
  height: 100%;  
  max-height: 200px;  /* Add this */
  overflow-y: auto;   /* Change from 'auto' to 'auto' */
  overflow-x: hidden; /* Add this to prevent horizontal scrollbar */
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  background-color: #f9fafb;
}

/* Workflow Files Styles */
.files-section {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.files-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.files-actions {
  display: flex;
  gap: 0.5rem;
}

.files-content {
  flex: 1;
  padding: 1rem;
  overflow: auto;
}

/* Files List */
.files-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.file-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.file-icon {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  color: #64748b;
}

.file-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.file-size {
  flex: 0 0 auto;
  margin-left: 8px;
  color: #888;
  font-size: 0.95em;
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 500;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.file-meta {
  font-size: 0.75rem;
  color: #64748b;
}

.file-actions {
  display: flex;
  gap: 0.5rem;
}

/* File Upload */
.upload-section {
  margin-bottom: 1rem;
  padding: 1rem;
  background-color: #f8fafc;
  border: 2px dashed #e2e8f0;
  border-radius: 0.5rem;
  text-align: center;
}

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.upload-icon {
  font-size: 2rem;
  color: #64748b;
}

.upload-text {
  color: #64748b;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.upload-button:hover {
  background-color: #2563eb;
}

/* File Actions */
.file-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.action-download {
  background-color: #f1f5f9;
  color: #1e293b;
}

.action-download:hover {
  background-color: #e2e8f0;
}

.action-delete {
  background-color: #fee2e2;
  color: #991b1b;
}

.action-delete:hover {
  background-color: #fecaca;
}

/* TTS Button States */
.file-action-btn.tts.playing {
  background-color: #fee2e2;
  color: #dc2626;
  border-color: #f87171;
}

.file-action-btn.tts.playing:hover {
  background-color: #fecaca;
}

.file-action-btn.tts.preparing {
  background-color: #fef3c7;
  color: #d97706;
  border-color: #fbbf24;
  animation: tts-preparing-pulse 1.5s ease-in-out infinite;
}

.file-action-btn.tts.preparing:hover {
  background-color: #fde68a;
}

@keyframes tts-preparing-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4);
  }
  50% {
    opacity: 0.8;
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .files-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .files-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .file-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .file-actions {
    margin-top: 0.75rem;
    width: 100%;
    justify-content: flex-end;
  }
}

/* File Preview Modal Styles */
.file-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1003;
}

.file-preview-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    margin-left: 125px; /* Offset to account for sidebar width */
}

.file-preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.file-preview-modal-header h4 {
    margin: 0;
    color: #374151;
    font-size: 1.1rem;
    font-weight: 600;
}

.file-preview-modal-actions {
    display: flex;
    gap: 0.5rem;
}

.modal-action-btn {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.modal-action-btn[title="Download file"] {
    background: #3b82f6;
    color: white;
}

.modal-action-btn[title="Download file"]:hover {
    background: #2563eb;
}

.modal-action-btn[title="Copy content"] {
    background: #10b981;
    color: white;
}

.modal-action-btn[title="Copy content"]:hover {
    background: #059669;
}

.modal-action-btn[title="Close preview"] {
    background: #ef4444;
    color: white;
}

.modal-action-btn[title="Close preview"]:hover {
    background: #dc2626;
}

.file-preview-modal-body {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.file-preview-content {
    height: 100%;
}

.file-info-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.file-type-badge {
    background: #f3f4f6;
    color: #374151;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.file-preview-text {
    white-space: pre-wrap;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    overflow: auto;
    padding: 0.5rem;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    max-height: 400px;
}

/* Responsive design for file preview modal */
@media (max-width: 1200px) {
    .file-preview-modal-content {
        max-width: 95%;
        max-height: 95%;
        margin-left: 100px; /* Slightly reduced offset for medium screens */
    }
}

@media (max-width: 768px) {
    .file-preview-modal-content {
        max-width: 98%;
        max-height: 98%;
        margin: 1rem;
        margin-left: 1rem; /* Reset margin for mobile where sidebar is hidden */
    }
    
    .file-preview-modal-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .file-preview-modal-actions {
        width: 100%;
        justify-content: flex-end;
    }
}