/**
 * File Upload Component Styles
 *
 * Wiederverwendbare Styles für die Dateiablage-Komponente.
 * Basiert auf dem audatis MANAGER Design-System.
 *
 * Diese Datei kann entweder separat eingebunden werden oder
 * die Styles werden aus bootstrap2.css verwendet (wo sie bereits enthalten sind).
 *
 * Verwendung:
 *   <link rel="stylesheet" href="/css/components/file-upload.css">
 *
 * Oder wenn bootstrap2.css bereits geladen ist, ist diese Datei nicht nötig.
 */

/* ========================================
   File Upload Component Container
   ======================================== */
.file-upload-component {
  width: 100%;
}

.file-upload-area {
  border: 2px dashed var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 20px;
  transition: all 0.2s ease;
}

.file-upload-area.drag-over {
  border-color: var(--primary-color, #007abb);
  background-color: rgba(0, 122, 187, 0.05);
}

/* ========================================
   Drag & Drop Zone
   ======================================== */
.file-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-radius: 6px;
  border: 2px dashed var(--border-color, #e5e7eb);
  background-color: var(--grey-50, #f9fafb);
  margin-top: 16px;
}

.file-dropzone:hover {
  background-color: var(--grey-100, #f3f4f6);
  border-color: var(--grey-300, #d1d5db);
}

.file-dropzone.drag-over {
  border-color: var(--primary-color, #007abb);
  background-color: rgba(0, 122, 187, 0.05);
}

.file-dropzone-icon {
  width: 64px;
  height: 64px;
  color: var(--grey-400, #9ca3af);
  margin-bottom: 16px;
  transition: color 0.2s ease;
}

.file-dropzone:hover .file-dropzone-icon {
  color: var(--primary-color, #007abb);
}

.file-dropzone-text {
  font-size: 15px;
  color: var(--text-secondary, #4b5563);
  margin-bottom: 8px;
}

.file-dropzone-text a,
.file-select-link {
  color: var(--primary-color, #007abb);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.file-dropzone-text a:hover,
.file-select-link:hover {
  text-decoration: underline;
}

.file-dropzone-hint {
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  line-height: 1.5;
}

.file-dropzone-hint small {
  display: block;
  margin-top: 4px;
}

/* ========================================
   File List
   ======================================== */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-list:empty {
  display: none;
}

.file-list:not(:empty) + .file-dropzone {
  margin-top: 16px;
}

/* ========================================
   File Item
   ======================================== */
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--grey-50, #f9fafb);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.file-item:hover {
  background-color: white;
  border-color: var(--primary-color, #007abb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

/* ========================================
   File Details
   ======================================== */
.file-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 1.4;
}

.file-meta {
  font-size: 12px;
  color: var(--text-muted, #6b7280);
}

/* ========================================
   File Actions
   ======================================== */
.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-500, #6b7280);
  transition: all 0.2s ease;
  text-decoration: none;
}

.file-action-btn:hover {
  background-color: var(--grey-100, #f3f4f6);
  color: var(--text-primary, #1e293b);
}

.file-action-btn.download:hover {
  background-color: #eff6ff;
  color: var(--primary-color, #007abb);
}

/* Delete button is always red */
.file-action-btn.delete {
  color: var(--error-color, #c84646);
}

.file-action-btn.delete:hover {
  background-color: #fef2f2;
  color: var(--error-darken, #a33838);
}

/* ========================================
   Upload Progress
   ======================================== */
.file-upload-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-upload-progress-list:empty {
  display: none;
}

.file-upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: var(--grey-50, #f9fafb);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
}

.file-upload-progress .file-icon {
  flex-shrink: 0;
}

.file-upload-progress .file-details {
  flex: 1;
  min-width: 0;
}

.file-upload-progress .progress-bar {
  flex: 1;
  height: 6px;
  background-color: var(--grey-200, #e5e7eb);
  border-radius: 3px;
  overflow: hidden;
}

.file-upload-progress .progress-fill {
  height: 100%;
  background-color: var(--primary-color, #007abb);
  transition: width 0.3s ease;
  border-radius: 3px;
}

.file-upload-progress .progress-text {
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  min-width: 45px;
  text-align: right;
}

.file-upload-progress.error .progress-fill {
  background-color: var(--error-color, #dc2626);
}

.file-upload-progress.success .progress-fill {
  background-color: var(--success-color, #16a34a);
}

/* Cancel button for upload progress */
.file-upload-progress .cancel-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-400, #9ca3af);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.file-upload-progress .cancel-btn:hover {
  background-color: #fef2f2;
  color: #dc2626;
}

/* ========================================
   Empty State (for file list)
   ======================================== */
.file-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted, #6b7280);
}

.file-empty-state svg {
  margin-bottom: 16px;
  color: var(--grey-400, #9ca3af);
}

.file-empty-state p {
  font-size: 14px;
  margin: 0;
}

/* ========================================
   Error Messages
   ======================================== */
.file-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  font-size: 14px;
  margin-bottom: 8px;
}

.file-error svg {
  flex-shrink: 0;
}

.file-error-dismiss {
  margin-left: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #dc2626;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.file-error-dismiss:hover {
  opacity: 1;
}

/* ========================================
   Readonly Mode
   ======================================== */
.file-upload-component[data-readonly="true"] .file-dropzone {
  display: none;
}

.file-upload-component[data-readonly="true"] .file-item {
  cursor: default;
}

.file-upload-component[data-readonly="true"] .file-action-btn.delete {
  display: none;
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 640px) {
  .file-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .file-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .file-dropzone {
    padding: 24px 16px;
  }

  .file-dropzone-icon {
    width: 48px;
    height: 48px;
  }

  .file-dropzone-text {
    font-size: 14px;
  }
}

/* ========================================
   Animation for new files
   ======================================== */
@keyframes fileItemFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-item.new {
  animation: fileItemFadeIn 0.3s ease-out;
}

/* Animation for removing files */
@keyframes fileItemFadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

.file-item.removing {
  animation: fileItemFadeOut 0.3s ease-out forwards;
}

/* ========================================
   Selectable Mode
   ======================================== */
.file-upload-component.selectable .file-list {
  gap: 4px;
}

.file-upload-component.selectable .file-item {
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.file-upload-component.selectable .file-item:hover {
  background-color: var(--grey-100, #f3f4f6);
  border-color: var(--grey-300, #d1d5db);
}

.file-upload-component.selectable .file-item.active,
.file-upload-component.selectable .file-item.selected {
  background-color: var(--selected-bg, #eff6ff);
  border-color: var(--primary-color, #007abb);
}

.file-upload-component.selectable .file-item.active .file-name,
.file-upload-component.selectable .file-item.selected .file-name {
  color: var(--primary-color, #007abb);
}

/* ========================================
   File Preview Panel
   ======================================== */
.file-preview-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--grey-50, #f9fafb);
  border-radius: 8px;
  overflow: hidden;
}

.file-preview-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: white;
}

.file-preview-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}

.file-preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 400px;
  overflow: hidden;
}

/* Preview Placeholder */
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-muted, #6b7280);
}

.preview-placeholder svg {
  color: var(--grey-300, #d1d5db);
  margin-bottom: 16px;
}

.preview-placeholder p {
  margin: 0;
  font-size: 14px;
  max-width: 280px;
  line-height: 1.5;
}

/* PDF Preview (iframe) */
.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Image Preview */
.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 20px;
}

/* Unsupported Format */
.preview-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-muted, #6b7280);
}

.preview-unsupported svg {
  color: var(--grey-300, #d1d5db);
  margin-bottom: 16px;
}

.preview-unsupported .unsupported-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  word-break: break-word;
}

.preview-unsupported .unsupported-text {
  margin: 0 0 20px;
  font-size: 14px;
  max-width: 300px;
  line-height: 1.5;
}

.preview-unsupported .btn {
  display: inline-flex;
  align-items: center;
}

/* ========================================
   Layout: File List with Preview
   ======================================== */
.file-upload-with-preview {
  display: flex;
  gap: 24px;
  min-height: 500px;
}

.file-upload-with-preview .file-list-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.file-upload-with-preview .file-list-panel .file-upload-component {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.file-upload-with-preview .file-list-panel .file-list {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 400px);
}

.file-upload-with-preview .file-preview-panel {
  flex: 1;
  min-width: 0;
}

/* Responsive: Stack on small screens */
@media (max-width: 900px) {
  .file-upload-with-preview {
    flex-direction: column;
  }

  .file-upload-with-preview .file-list-panel {
    width: 100%;
  }

  .file-upload-with-preview .file-list-panel .file-list {
    max-height: 200px;
  }

  .file-preview-content {
    min-height: 300px;
  }
}

/* ====================================================================
   File Preview Modal - Vollbild-Modal für PDF/Bild-Vorschau
   Verwendet die Standard-Modal-Klassen aus bootstrap2.css
   ==================================================================== */

.file-preview-modal.modal-overlay {
  z-index: 9999;
}

.file-preview-modal .modal.modal-preview-fullscreen {
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
}

.file-preview-modal .modal-body.file-preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  position: relative;
  min-height: 0;
  background: var(--grey-100, #f3f4f6);
}

.file-preview-modal .preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.file-preview-modal .preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-preview-modal .preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted, #6b7280);
}

.file-preview-modal .preview-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--grey-200, #e5e7eb);
  border-top-color: var(--primary-color, #007abb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
  .file-preview-modal .modal.modal-preview-fullscreen {
    width: 95vw;
    height: 90vh;
  }
}

/* ========================================
   File Preview Modal - Unsupported State
   ======================================== */
.file-preview-modal .file-preview-unsupported {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted, #6b7280);
}

.file-preview-modal .file-preview-unsupported svg,
.file-preview-modal .file-preview-unsupported .unsupported-icon {
  width: 64px;
  height: 64px;
  color: var(--grey-300, #d1d5db);
  margin-bottom: 20px;
}

.file-preview-modal .unsupported-filename {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  word-break: break-word;
  max-width: 400px;
}

.file-preview-modal .unsupported-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  max-width: 320px;
  color: var(--text-muted, #6b7280);
}

/* ========================================
   File Preview Modal - Footer
   ======================================== */
.file-preview-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: white;
}

.file-preview-modal .modal-footer .btn {
  min-width: 100px;
}

#previewDownloadBtn {
  text-decoration: none;
}
