/* ============================================
   URL Preview Grid Component Styles
   ============================================ */

.url-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 20px 0 16px 0;
  position: relative;
  z-index: 1; /* Unter dem overlay und expand-fab */
}

@media (max-width: 768px) {
  .url-preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Base Styles */
.url-preview-card {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

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

/* Header */
.url-preview-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  cursor: default;
  user-select: none;
}

.url-preview-card__icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #666;
  flex-shrink: 0;
}

.url-preview-card__icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.url-preview-card__icon--youtube {
  color: #ff0000;
  font-size: 24px;
}

.url-preview-card__title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* YouTube Video Container */
.url-preview-card__youtube {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.url-preview-card__video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  background: #000;
}

.url-preview-card__video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* YouTube Footer (minimalistisch) */
.url-preview-card__youtube-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
}

.url-preview-card__youtube-icon {
  display: flex;
  align-items: center;
  font-size: 20px;
  color: #ff0000;
}

.url-preview-card__youtube-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  transition: color 0.2s ease;
}

.url-preview-card__youtube-link:hover {
  color: #ff0000;
}

.url-preview-card__youtube-link i {
  font-size: 12px;
}

/* Website Preview Content */
.url-preview-card__content {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.url-preview-card__url {
  font-size: 13px;
  color: #666;
  word-break: break-all;
  line-height: 1.5;
}

/* Footer */
.url-preview-card__footer {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  background: #f8f9fa;
}

.url-preview-card__youtube .url-preview-card__footer {
  background: #fff;
}

.url-preview-card__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1976d2;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.url-preview-card__link:hover {
  color: #1565c0;
  text-decoration: underline;
}

.url-preview-card__link i {
  font-size: 12px;
}

.url-preview-card__open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Empty State */
.url-preview-empty {
  grid-column: 1 / -1;
  padding: 48px 24px;
  text-align: center;
  color: #999;
}

.url-preview-empty i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.url-preview-empty p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
  .url-preview-card {
    background: #2a2a2a;
    border-color: #404040;
  }

  .url-preview-card__header,
  .url-preview-card__footer {
    background: #1e1e1e;
    border-color: #404040;
  }

  .url-preview-card__title {
    color: #e0e0e0;
  }

  .url-preview-card__url {
    color: #b0b0b0;
  }

  .url-preview-card__icon {
    color: #b0b0b0;
  }
}

/* ============================================
   Rich Preview Styles
   ============================================ */

/* Loading State */
.url-preview-card__website--loading {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.url-preview-card__loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #666;
  font-size: 14px;
}

.url-preview-card__loader i {
  font-size: 32px;
  color: #3b82f6;
}

/* Rich Preview */
.url-preview-card__website--rich {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.url-preview-card__image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #f3f4f6;
  position: relative;
}

.url-preview-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.url-preview-card:hover .url-preview-card__image img {
  transform: scale(1.05);
}

.url-preview-card__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.url-preview-card__website--rich .url-preview-card__header {
  padding: 0;
  background: transparent;
  border: none;
  cursor: default;
  gap: 8px;
}

.url-preview-card__domain {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.url-preview-card__website--rich .url-preview-card__title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: #111827;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.url-preview-card__description {
  font-size: 14px;
  line-height: 1.6;
  color: #6b7280;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.url-preview-card__website--rich .url-preview-card__footer {
  margin-top: auto;
  padding-top: 8px;
}

.url-preview-card__website--rich .url-preview-card__icon {
  width: 20px;
  height: 20px;
  font-size: 14px;
}

.url-preview-card__website--rich .url-preview-card__icon img {
  width: 16px;
  height: 16px;
}

/* ============================================
   Integration with Task Viewer Overlay System
   ============================================ */

/* When parent card has 'has-more' class (collapsed state), hide URL preview */
.tv-subtask-card.has-more .url-preview-grid {
  max-height: 0;
  overflow: hidden;
  margin: 0;
  opacity: 0;
  transition: all 0.3s ease;
}

/* When expanded (no 'has-more' class), show URL preview */
.tv-subtask-card:not(.has-more) .url-preview-grid,
.tv-subtask-card.is-open:not(.has-more) .url-preview-grid {
  max-height: none;
  overflow: visible;
  margin: 20px 0 16px 0;
  opacity: 1;
  transition: all 0.3s ease;
}

/* Ensure URL preview has its own space and isn't affected by expand-fab */
.tv-subtask-card__info {
  position: relative;
  padding-bottom: 0; /* Remove any bottom padding that might interfere */
}

/* Expand-fab should be absolutely positioned and not affect layout */
.tv-subtask-card .expand-fab {
  position: absolute !important;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10; /* Above overlay and URL preview */
  pointer-events: auto; /* Ensure it's clickable */
}

.tv-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to bottom, transparent, white);
  pointer-events: none;
  z-index: 5; /* Above URL preview, below expand-fab */
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
  .url-preview-card {
    background: #1f2937;
    border-color: #374151;
  }

  .url-preview-card:hover {
    background: #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .url-preview-card__header {
    background: #374151;
    border-bottom-color: #4b5563;
  }

  .url-preview-card__title {
    color: #f3f4f6;
  }

  .url-preview-card__content {
    color: #d1d5db;
  }

  .url-preview-card__url {
    color: #9ca3af;
  }

  .url-preview-card__link {
    color: #60a5fa;
  }

  .url-preview-card__link:hover {
    color: #93c5fd;
  }

  /* Rich Preview Dark Mode */
  .url-preview-card__image {
    background: #111827;
  }

  .url-preview-card__website--rich .url-preview-card__title {
    color: #f9fafb;
  }

  .url-preview-card__domain {
    color: #9ca3af;
  }

  .url-preview-card__description {
    color: #d1d5db;
  }

  .url-preview-card__loader {
    color: #d1d5db;
  }

  .url-preview-card__loader i {
    color: #60a5fa;
  }

  .tv-card-overlay {
    background: linear-gradient(to bottom, transparent, #1f2937);
  }
}
