/**
 * Attachment Cards Component
 * Global CSS for vedlegg (attachments) - både aktive og slettede
 * Brukes på: work_task/view, work_task/entity_user, project/view, files
 */

/* ============================================
   BASE ATTACHMENT CARD
   ============================================ */

.attachment-card {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  height: 100%;
}

.attachment-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.attachment-card:active {
  transform: translateY(0);
}

/* File info icon (i-knappen) */
.attachment-card .file-info-trigger {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
  color: var(--primary-color, #0d6efd);
  opacity: 0.8;
}

.attachment-card .file-info-trigger:hover {
  transform: scale(1.2);
  opacity: 1;
}

/* Card uses Bootstrap's default card-body styling with p-3 (padding) */

/* ============================================
   ACTIVE ATTACHMENT CARDS
   ============================================ */

.attachment-card.active-file {
  border: 1px solid #dee2e6;
  background: white;
}

.attachment-card.active-file:hover {
  border-color: var(--primary-color, #0d6efd);
}

/* Active file with GPS data */
.attachment-card.active-file.has-gps::after {
  content: '\F4F9'; /* bi-geo-alt-fill */
  font-family: 'bootstrap-icons';
  position: absolute;
  top: 8px;
  left: 8px;
  color: var(--success-color, #28a745);
  font-size: 14px;
  z-index: 5;
}

/* ============================================
   DELETED ATTACHMENT CARDS
   ============================================ */

.attachment-card.deleted-file {
  /* Same styling as active files, only border is RED */
  background: white;
  border: 1px solid var(--danger-color, #dc3545) !important;
}

/* File info icon (i-knappen) on deleted files - RED */
.attachment-card.deleted-file .file-info-trigger {
  color: var(--danger-color, #dc3545) !important;
}

/* Pulse animation for critical files (≤7 days) */
.attachment-card.deleted-file.urgency-critical {
  animation: pulse-border-red 2s infinite;
}

@keyframes pulse-border-red {
  0%, 100% {
    border-color: var(--danger-color, #dc3545);
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
  }
  50% {
    border-color: #c82333;
    box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
  }
}

/* Restore button uses Bootstrap's default btn-sm btn-success w-100 styling */

/* ============================================
   RESPONSIVE GRID LAYOUT
   ============================================ */

/* Grid container for attachment cards */
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 576px) {
  .attachments-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }
}

/* ============================================
   LOADING STATE
   ============================================ */

.attachment-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.attachment-card.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary-color, #0d6efd);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   EMPTY STATE
   ============================================ */

.attachments-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}

.attachments-empty .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.attachments-empty .empty-text {
  font-size: 1rem;
  margin: 0;
}

/* ============================================
   BADGE OVERLAYS
   ============================================ */

/* "Slettet" badge */
.attachment-card.deleted-file .deleted-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger-color, #dc3545);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  z-index: 11;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* "Nytt" badge (for nylig opplastede filer) */
.attachment-card.active-file.is-new::before {
  content: 'Ny';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success-color, #28a745);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  z-index: 11;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   FILE TYPE SPECIFIC STYLING
   ============================================ */

/* Image files */
.attachment-card.file-type-image .card-body {
  padding: 0;
}

.attachment-card.file-type-image .card-img-top {
  height: 150px;
  object-fit: cover;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.attachment-card.file-type-image .card-title {
  padding: 0.5rem;
  font-size: 0.75rem;
}

/* PDF files */
.attachment-card.file-type-pdf .file-icon {
  color: var(--danger-color, #dc3545);
}

/* Word/Excel files */
.attachment-card.file-type-document .file-icon {
  color: var(--primary-color, #0d6efd);
}

/* ZIP/Archive files */
.attachment-card.file-type-archive .file-icon {
  color: var(--warning-color, #ffc107);
}

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

.attachment-card:focus {
  outline: 2px solid var(--primary-color, #0d6efd);
  outline-offset: 2px;
}

.attachment-card .file-info-trigger:focus {
  outline: 2px solid var(--primary-color, #0d6efd);
  outline-offset: 2px;
}

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

@media print {
  .attachment-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  .attachment-card:hover {
    transform: none;
    box-shadow: none;
  }
  
  .attachment-card.deleted-file {
    opacity: 1;
  }
}

