:root {
  --card-bg: #fff;
  --card-border: #e5e5e5;
  --btn-bg: #ffffff;
  --btn-border: #d1d5db;
  --btn-hover-bg: #f3f4f6;
  --primary: #006fa1;
  --primary-dark: #005075;
  --radius: 8px;
  --shadow-light: 0 4px 16px rgba(0, 0, 0, 0.04);
}

/* ---------- Collection Grid (cols bleibt inline via PHP) ---------- */
.dam-collection.dam-layout-grid {
  display: grid;
  gap: 1rem;
  /* grid-template-columns: wird vom inline style / media queries kontrolliert */
}

/* Breakpoints: fallback / enforced reductions */
@media (max-width: 1200px) {
  .dam-collection.dam-layout-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (max-width: 992px) {
  .dam-collection.dam-layout-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 640px) {
  .dam-collection.dam-layout-grid {
    grid-template-columns: repeat(1, 1fr) !important;
  }
}

/* Fallback wrapper (Elementor) */
.dam-wrapper.dam-layout-grid {
  display: grid !important;
  gap: 1rem;
}
.dam-wrapper.dam-columns-1.dam-layout-grid { grid-template-columns: 1fr; }
.dam-wrapper.dam-columns-2.dam-layout-grid { grid-template-columns: repeat(2,1fr); }
.dam-wrapper.dam-columns-3.dam-layout-grid { grid-template-columns: repeat(3,1fr); }
.dam-wrapper.dam-columns-4.dam-layout-grid { grid-template-columns: repeat(4,1fr); }
.dam-wrapper.dam-columns-5.dam-layout-grid { grid-template-columns: repeat(5,1fr); }
.dam-wrapper.dam-columns-6.dam-layout-grid { grid-template-columns: repeat(6,1fr); }

/* ---------- Card ---------- */
.dam-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1rem;
  box-shadow: var(--shadow-light);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

/* Image */
.dam-card img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  object-fit: contain;
}

/* Title */
.dam-card h3 {
  margin: .4rem 0;
  font-size: 1.1rem;
  line-height: 1.2;
  word-break: break-word;
}

/* ---------- Buttons ---------- */
.dam-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0;
  width: 100%;
}

.dam-btn svg {
  display: block;
  stroke: #1f2937; /* dunkles Grau/Schwarz */
  width: 1em;
  height: 1em;
}

.dam-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  padding: .5rem;
  width: 100%;
  height: auto;
  min-width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.dam-btn:hover {
  background: var(--btn-hover-bg);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.dam-btn:active {
  transform: translateY(0);
}

/* Fokuszustand für Barrierefreiheit */
.dam-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Optional: leichte Farbverstärkung beim Hover */
.dam-btn:hover svg {
  stroke: var(--primary-dark);
}

button.dam-btn {
    border-radius: 10px !important;
    padding: 0px !important;
}

/* ---------- Attributes (Zebra) ---------- */
.dam-attrs {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  font-size: .9rem;
}
.dam-attrs li {
  padding: .5rem;
}
.dam-attrs li:nth-child(odd) {
  background: #f9f9f9;
}

/* ---------- Pagination / Load More ---------- */
.dam-load-more-wrap,
.dam-paged-nav {
  text-align: center;
  margin: 1rem 0;
}
.dam-load-more,
.dam-paged-nav a {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: .65rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background .2s ease;
  font-weight: 500;
}
.dam-load-more:hover,
.dam-paged-nav a:hover {
  background: var(--primary-dark);
}

/* ---------- Lightbox ---------- */
#dam-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  background: rgba(0,0,0,0.8); /* direkter dunkler Hintergrund für Kontrast */
}

.dam-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(3px);
}
/* Lightbox: Content flexibel, Header + Body */
.dam-lightbox-content {
  position: relative;
  width: 100%;
  max-width: 95vw;
  max-height: 95vh;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}
/* Header fixiert oben */
.dam-lightbox-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem .75rem;
  background: #f5f5f7;
  gap: .5rem;
  border-bottom: 1px solid #e2e8f0;
}
.dam-lightbox-title {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dam-lightbox-actions {
  display: flex;
  gap: .5rem;
}
.dam-lightbox-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.dam-lightbox-download {
  text-decoration: none;
  font-size: 1.1rem;
  padding: .25rem .5rem;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: inherit;
}

/* Body nimmt Rest: zentriert Inhalt, skalierend */
.dam-lightbox-body {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  background: #000;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0; /* kein innerer Abstand, damit Raum maximal genutzt wird */
}

/* Bild / PDF: optimal skalieren, kein erzwungenes 100% forcing */
#dam-lightbox-img,
#dam-lightbox-pdf {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border: none;
  object-fit: contain;
  display: block;
}


/* PDF spezifisch: damit es bei Hochformat besser skaliert */
#dam-lightbox-pdf {
  width: auto;
  height: 100%;
  max-height: 100%;
  max-width: 90vw; /* verhindert zu breite Darstellung auf schmalen Viewports */
  box-sizing: border-box;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 640px) {
  .dam-card {
    padding: .75rem;
  }
  .dam-card h3 {
    font-size: 1rem;
  }
  .dam-btn {
    font-size: 1rem;
    padding: .4rem;
  }
  .dam-buttons {
    grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
    gap: .25rem;
  }
}



/* Wrapper über gesamte Collection */
.dam-gpt-wrapper {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  gap: 1rem;
  margin: 0 0 1rem;
  flex-wrap: wrap;
  background: #fff;
  padding: 1rem;
  border: 1px solid #ddd;
  position: relative;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-radius: 8px;
}

/* Hervorhebung, damit Nutzer sieht, dass Panel geöffnet wurde */
.dam-gpt-wrapper-opened {
  animation: fadeInDown 0.25s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Close button oben rechts im Panel (falls noch nicht vorhanden) */
.dam-gpt-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: background .2s ease, transform .1s ease;
  z-index: 999;
}

.dam-gpt-close:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
}

.dam-gpt-left {
  background: #fafafa;
  border: 1px solid #e2e8f0;
  padding: 0.75rem;
  border-radius: 6px;
}
/* 30/70 Aufteilung */
.dam-gpt-left {
  flex: 0 0 30%;
  min-width: 220px;
}

.dam-gpt-right {
  background: #fff;
  border: 1px solid #d1d5db;
  padding: 1rem;
  border-radius: 6px;
  position: relative;
}
.dam-gpt-right {
  flex: 1;
  min-width: 300px;
  position: relative;
}
.dam-gpt-panel textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.5rem;
  box-sizing: border-box;
}
.dam-gpt-panel button {
  background: var(--primary);
  color: white;
  border: none;
  padding: .5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  margin-right: .5rem;
}
.dam-gpt-panel button:hover {
  background: var(--primary-dark);
}
.dam-gpt-image-result img {
  border-radius: 6px;
  margin-top: .5rem;
  display: block;
}