/**
 * Attachment Section Component
 * Global CSS for vedlegg-seksjonen (attachment section)
 * 
 * Brukes på:
 * - work_task/view
 * - work_task/entity_user_work_task
 * - work_task/Edit_Work_Task (reg_work_task)
 * - files/list_files
 * 
 * Standard struktur:
 * <div class="card">
 *   <div class="card-header bg-white">
 *     <h5><i class="bi-paperclip"></i>Vedlegg (count)</h5>
 *     <div class="form-check form-switch">Toggle</div>
 *   </div>
 *   <div class="card-body">
 *     <div class="attachment-actions">Buttons</div>
 *     <div id="activeFilesContainer">Active files</div>
 *     <div id="deletedFilesContainer">Deleted files</div>
 *   </div>
 * </div>
 */

/* ============================================
   CARD HEADER STYLING
   ============================================ */

/* Vedlegg card header */
.card-header.bg-white {
  background-color: #fff !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
  padding: 1rem 1.25rem;
}

/* Header title with icon */
.card-header h5 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 0;
}

.card-header h5 i {
  color: var(--primary-color, #0d6efd);
  margin-right: 0.5rem;
}

/* Toggle switch in header */
.card-header .form-check-switch {
  padding-left: 2.5em;
  min-height: 1.5rem;
}

.card-header .form-check-input {
  cursor: pointer;
  width: 2em;
  height: 1em;
  margin-top: 0.25em;
}

.card-header .form-check-label {
  cursor: pointer;
  font-size: 0.875rem;
  color: #6c757d;
  user-select: none;
}

.card-header .form-check-label:hover {
  color: #495057;
}

/* Deleted files badge in toggle */
.card-header .badge {
  font-size: 0.75rem;
  padding: 0.25em 0.5em;
  vertical-align: middle;
}

/* ============================================
   CARD BODY STYLING
   ============================================ */

/* Action buttons container */
.attachment-actions,
.d-flex.justify-content-end.align-items-center.gap-2.mb-3 {
  margin-bottom: 1rem !important;
}

/* Action buttons */
.attachment-actions .btn,
.d-flex.justify-content-end.align-items-center.gap-2 .btn {
  transition: all 0.2s ease;
}

.attachment-actions .btn:hover,
.d-flex.justify-content-end.align-items-center.gap-2 .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ============================================
   FILES CONTAINER STYLING
   ============================================ */

/* Active files container */
#activeFilesContainer,
#activeFilesContainerGlobal {
  transition: all 0.3s ease;
}

/* Deleted files container */
#deletedFilesContainer,
#deletedFilesContainerGlobal {
  transition: all 0.3s ease;
}

/* Empty state message */
.text-center.py-5 {
  color: #6c757d;
}

.text-center.py-5 i {
  opacity: 0.5;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  /* Stack header on mobile */
  .card-header .d-flex {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
  
  .card-header h5 {
    font-size: 1.1rem;
  }
  
  /* Adjust toggle on mobile */
  .card-header .form-check-switch {
    margin-top: 0.5rem;
  }
}

@media (max-width: 576px) {
  /* Reduce padding on small screens */
  .card-header.bg-white {
    padding: 0.75rem 1rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Stack action buttons on mobile */
  .attachment-actions,
  .d-flex.justify-content-end.align-items-center.gap-2 {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  .attachment-actions .btn,
  .d-flex.justify-content-end.align-items-center.gap-2 .btn {
    width: 100%;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  /* Hide toggles and action buttons when printing */
  .card-header .form-check-switch,
  .attachment-actions,
  .d-flex.justify-content-end.align-items-center.gap-2 {
    display: none !important;
  }
  
  /* Hide deleted files when printing */
  #deletedFilesContainer,
  #deletedFilesContainerGlobal {
    display: none !important;
  }
  
  /* Ensure card header prints properly */
  .card-header.bg-white {
    background-color: #f8f9fa !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus states */
.card-header .form-check-input:focus {
  border-color: var(--primary-color, #0d6efd);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.card-header .form-check-label:focus-within {
  outline: 2px solid var(--primary-color, #0d6efd);
  outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Fade in/out for container switches */
@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);
  }
}

/* Apply animation when containers are toggled */
#activeFilesContainer.showing,
#activeFilesContainerGlobal.showing,
#deletedFilesContainer.showing,
#deletedFilesContainerGlobal.showing {
  animation: fadeIn 0.3s ease forwards;
}

#activeFilesContainer.hiding,
#activeFilesContainerGlobal.hiding,
#deletedFilesContainer.hiding,
#deletedFilesContainerGlobal.hiding {
  animation: fadeOut 0.3s ease forwards;
}



