/* ============================================
   RAF-15: MESSAGE ATTACHMENTS STYLES
   Styling for attachments within chat messages
   ============================================ */

/* ==============================================
   BASE ATTACHMENT CONTAINER
   ============================================== */

.message-attachment {
  margin-bottom: 8px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  position: relative;
  transition: all 0.2s ease;
}

.message-attachment.load-error {
  opacity: 0.6;
}

/* RAF-14: Upload Indicator */
.message-attachment-uploading {
  position: relative;
}

.upload-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(75, 196, 81, 0.95);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: uploadPulse 1.5s infinite;
}

.upload-indicator.error {
  background: rgba(220, 53, 69, 0.95);
  animation: none;
}

@keyframes uploadPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.message-attachment-uploaded .upload-indicator {
  display: none;
}

/* ==============================================
   IMAGE ATTACHMENTS
   ============================================== */

.message-attachment-image {
  position: relative;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

.message-attachment-image img {
  max-width: 300px;
  max-height: 200px;
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.message-attachment-image:hover img {
  transform: scale(1.02);
}

/* Image Overlay (View/Download buttons) */
.attachment-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message-attachment-image:hover .attachment-overlay {
  opacity: 1;
}

.attachment-action {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.attachment-action:hover {
  background: #f3f4f6;
  transform: scale(1.1);
}

.attachment-action svg {
  width: 20px;
  height: 20px;
  color: #1f2937;
}

/* Image Error State */
.attachment-error-message {
  display: none;
  padding: 16px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

.message-attachment-image.load-error .attachment-error-message {
  display: block;
}

/* ==============================================
   VOICE MESSAGE ATTACHMENTS (GREEN THEME)
   ============================================== */

.message-attachment-voice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #4BC451 0%, #3da842 100%);
  border-radius: 20px;
  max-width: 320px;
}

.message-attachment-voice .voice-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.message-attachment-voice .voice-icon svg {
  width: 18px;
  height: 18px;
  color: white;
}

.message-attachment-voice audio {
  flex: 1;
  height: 32px;
  max-width: 100%;
}

/* ==============================================
   AUDIO FILE ATTACHMENTS (PURPLE THEME)
   ============================================== */

.message-attachment-audio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #9333ea 0%, #7e22ce 100%);
  border-radius: 12px;
  max-width: 350px;
}

.message-attachment-audio .audio-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.message-attachment-audio .audio-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.message-attachment-audio .audio-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.message-attachment-audio .audio-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.message-attachment-audio .audio-filename {
  color: white;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-attachment-audio audio {
  width: 100%;
  height: 32px;
}

/* ==============================================
   VIDEO ATTACHMENTS
   ============================================== */

.message-attachment-video {
  background: #1f2937;
  border-radius: 12px;
  overflow: hidden;
  max-width: 350px;
}

.message-attachment-video video {
  width: 100%;
  max-width: 350px;
  height: auto;
  display: block;
  background: #000;
}

.message-attachment-video .video-info {
  padding: 8px 12px;
  background: #2a2a2a;
}

.message-attachment-video .video-filename {
  color: white;
  font-size: 13px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==============================================
   DOCUMENT ATTACHMENTS
   ============================================== */

.message-attachment-document {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  max-width: 350px;
  transition: all 0.2s ease;
}

.message-attachment-document:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.message-attachment-document .doc-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4BC451, #3da842);
  border-radius: 8px;
}

.message-attachment-document .doc-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.message-attachment-document .doc-info {
  flex: 1;
  min-width: 0;
}

.message-attachment-document .doc-name {
  color: #1f2937;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.message-attachment-document .doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
}

.message-attachment-document .doc-type {
  font-weight: 500;
  text-transform: uppercase;
}

.message-attachment-document .doc-download {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.message-attachment-document .doc-download:hover {
  background: #d1d5db;
  transform: scale(1.05);
}

.message-attachment-document .doc-download svg {
  width: 18px;
  height: 18px;
  color: #1f2937;
}

/* ==============================================
   ERROR STATE
   ============================================== */

.message-attachment-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  font-size: 14px;
}

.message-attachment-error svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* ==============================================
   IMAGE LIGHTBOX
   ============================================== */

.image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 1;
}

.lightbox-content img {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-close svg {
  width: 24px;
  height: 24px;
  color: white;
}

.lightbox-name {
  color: white;
  font-size: 14px;
  text-align: center;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==============================================
   RESPONSIVE - MOBILE
   ============================================== */

@media (max-width: 768px) {
  .message-attachment-image img {
    max-width: 100%;
    max-height: 150px;
  }
  
  .message-attachment-voice,
  .message-attachment-audio,
  .message-attachment-document {
    max-width: 100%;
  }
  
  .message-attachment-video {
    max-width: 100%;
  }
  
  .message-attachment-video video {
    max-width: 100%;
  }
  
  .attachment-action {
    width: 36px;
    height: 36px;
  }
  
  .attachment-action svg {
    width: 18px;
    height: 18px;
  }
  
  .lightbox-content img {
    max-height: calc(100vh - 100px);
  }
  
  .lightbox-close {
    top: -40px;
    width: 36px;
    height: 36px;
  }
}

/* ==============================================
   DARK MODE
   ============================================== */

@media (prefers-color-scheme: dark) {
  .message-attachment-image {
    background: #1f2937;
    border-color: #374151;
  }
  
  .message-attachment-document {
    background: #1f2937;
    border-color: #374151;
  }
  
  .message-attachment-document:hover {
    background: #2a2a2a;
    border-color: #4b5563;
  }
  
  .message-attachment-document .doc-name {
    color: #f3f4f6;
  }
  
  .message-attachment-document .doc-meta {
    color: #9ca3af;
  }
  
  .message-attachment-document .doc-download {
    background: #374151;
  }
  
  .message-attachment-document .doc-download:hover {
    background: #4b5563;
  }
  
  .message-attachment-document .doc-download svg {
    color: #d1d5db;
  }
  
  .message-attachment-error {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fecaca;
  }
  
  .attachment-action {
    background: rgba(255, 255, 255, 0.9);
  }
  
  .attachment-action:hover {
    background: white;
  }
}

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

.attachment-action:focus-visible,
.doc-download:focus-visible,
.lightbox-close:focus-visible {
  outline: 2px solid #4BC451;
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .message-attachment,
  .message-attachment-image img,
  .attachment-action,
  .doc-download,
  .lightbox-close {
    transition: none;
  }
  
  .image-lightbox {
    animation: none;
  }
}

/* ==============================================
   LOADING STATES
   ============================================== */

.message-attachment-loading {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

