*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1c1e21;
  min-height: 100vh;
  padding: 24px;
}

header {
  margin-bottom: 24px;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
}

header p {
  font-size: 13px;
  color: #65676b;
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
}

.state {
  text-align: center;
  padding: 60px 24px;
  color: #65676b;
  font-size: 14px;
}

.state--error {
  color: #e53e3e;
}

/* ----- Ad Card ----- */
.ad-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.ad-card__loading {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
}

.ad-card__error {
  padding: 32px 16px;
  text-align: center;
  color: #65676b;
  font-size: 13px;
}

.ad-card__error-detail {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.7;
}

/* Header (page info) */
.ad-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}

.ad-card__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e4e6eb;
  flex-shrink: 0;
  object-fit: cover;
}

.ad-card__page-name {
  font-size: 14px;
  font-weight: 600;
  color: #050505;
  line-height: 1.2;
}

.ad-card__sponsored {
  font-size: 12px;
  color: #65676b;
  margin-top: 2px;
}

/* Body text */
.ad-card__body {
  padding: 0 16px 12px;
  font-size: 14px;
  color: #050505;
  line-height: 1.34;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Media area */
.ad-card__media {
  position: relative;
  background: #000;
  width: 100%;
}

.ad-card__media img,
.ad-card__media video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 600px;
  object-fit: contain;
}

/* Link area (under media) */
.ad-card__link {
  background: #f0f2f5;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ad-card__link-info {
  flex: 1;
  min-width: 0;
}

.ad-card__link-domain {
  font-size: 12px;
  color: #65676b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ad-card__link-title {
  font-size: 16px;
  font-weight: 600;
  color: #050505;
  line-height: 1.2;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ad-card__cta {
  background: #e4e6eb;
  color: #050505;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.ad-card__cta:hover {
  background: #d8dadf;
}

/* Footer (meta info) */
.ad-card__meta {
  padding: 8px 16px 12px;
  font-size: 12px;
  color: #65676b;
  border-top: 1px solid #e4e6eb;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.ad-card__meta-label {
  font-weight: 600;
  color: #65676b;
}

/* Spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #1877f2;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
/* ============================================
   v2 CSS additions
   Tilføj nederst i /opt/teamblue-creatives/public/styles/app.css
   ============================================ */

/* ----- Video fallback (thumbnail med play-overlay) ----- */
.ad-card__video-fallback {
  position: relative;
  width: 100%;
}

.ad-card__video-fallback img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 600px;
  object-fit: contain;
}

.ad-card__no-thumbnail {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1c1e21;
  color: #65676b;
  font-size: 14px;
}

.ad-card__play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.ad-card__play-overlay:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.ad-card__play-overlay:focus-visible {
  outline: 2px solid #1877f2;
  outline-offset: 4px;
  border-radius: 50%;
}

.ad-card__video-no-preview {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ----- Preview Modal ----- */
.preview-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}

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

.preview-modal__container {
  background: #fff;
  border-radius: 12px;
  width: 540px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.preview-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e4e6eb;
  flex-shrink: 0;
}

.preview-modal__title {
  font-size: 15px;
  font-weight: 600;
  color: #050505;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 12px;
}

.preview-modal__close {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #65676b;
  flex-shrink: 0;
  transition: background 0.15s;
}

.preview-modal__close:hover {
  background: #f0f2f5;
  color: #050505;
}

.preview-modal__body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #f0f2f5;
}

.preview-modal__iframe {
  width: 100%;
  height: 720px;
  border: none;
  display: block;
  background: #fff;
}

.preview-modal__loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #f0f2f5;
}

.preview-modal__loading-text {
  font-size: 13px;
  color: #65676b;
}

/* Mobil-tilpasning */
@media (max-width: 600px) {
  .preview-modal__backdrop {
    padding: 0;
  }
  .preview-modal__container {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .preview-modal__iframe {
    height: 100%;
  }
}
