/* Rufus-3D-Druck Clean v2.7.2
   Phoca Gallery Styling
   Ziel: Phoca Gallery optisch an das Rufus-Template anpassen, ohne Core-Dateien der Komponente zu ändern.
*/

:where(.pf-com-phocagallery, .com-phocagallery, .com_phocagallery, .phocagallery, #phocagallery) {
  --pg-rufus-card: rgba(17,24,39,.78);
  --pg-rufus-card-strong: rgba(17,24,39,.92);
  --pg-rufus-border: color-mix(in srgb, var(--pf-border, rgba(148,163,184,.22)), transparent 6%);
  --pg-rufus-muted: var(--pf-muted, #b7c4d6);
  --pg-rufus-text: var(--pf-text, #f8fafc);
}

/* Komponentenseite im gleichen Card-Look wie Beiträge */
.pf-com-phocagallery .pf-component:has(.phocagallery),
.pf-com-phocagallery .pf-component:has(#phocagallery),
.pf-com-phocagallery .pf-component:has(.pg-category-view),
.pf-com-phocagallery .pf-component:has(.pg-categories-view) {
  padding: clamp(1.25rem, 3vw, 2.2rem);
}

/* Hauptcontainer und Überschriften */
.com-phocagallery,
.com_phocagallery,
.phocagallery,
#phocagallery,
.pg-categories-view,
.pg-category-view,
.pg-detail-view {
  color: var(--pg-rufus-text);
}

.com-phocagallery h1,
.com-phocagallery h2,
.com-phocagallery h3,
.com_phocagallery h1,
.com_phocagallery h2,
.com_phocagallery h3,
.phocagallery h1,
.phocagallery h2,
.phocagallery h3,
#phocagallery h1,
#phocagallery h2,
#phocagallery h3 {
  color: var(--pg-rufus-text);
  letter-spacing: -.04em;
}

.phocagallery a,
#phocagallery a,
.com-phocagallery a,
.com_phocagallery a {
  color: inherit;
  text-decoration: none;
}

.phocagallery a:hover,
#phocagallery a:hover,
.com-phocagallery a:hover,
.com_phocagallery a:hover {
  color: var(--pf-second, #18d4ff);
}

/* Kategorien- und Bilderraster: viele Phoca-Versionen nutzen unterschiedliche Klassen.
   Deshalb werden die bekannten Varianten gesammelt gestylt. */
.pg-categories,
.pg-categories-view,
.pg-category-view,
.phocagallerycategories,
.phocagallery,
#phocagallery .pg-cv-box,
#phocagallery .pg-item-box {
  max-width: 100%;
}

.pg-categories-view .pg-cv-box,
.pg-category-view .pg-item-box,
.pg-item-box,
.pg-category-box,
.phocagallery-box-file,
.phocagallery-box-file-first,
.phocagallery-box-file-second,
.phocagallery-box,
.phocagallerycategories .category,
.phocagallery-categories .category {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--pg-rufus-border) !important;
  border-radius: 26px !important;
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--pf-second, #18d4ff), transparent 78%), transparent 22rem),
    radial-gradient(circle at 86% 96%, color-mix(in srgb, var(--pf-accent, #ff8a00), transparent 82%), transparent 22rem),
    linear-gradient(145deg, rgba(17,24,39,.86), rgba(17,24,39,.54)) !important;
  box-shadow: 0 22px 65px rgba(0,0,0,.24);
  backdrop-filter: blur(18px);
  transition: transform .24s ease, border-color .24s ease, box-shadow .24s ease, background .24s ease;
}

.pg-categories-view .pg-cv-box:hover,
.pg-category-view .pg-item-box:hover,
.pg-item-box:hover,
.pg-category-box:hover,
.phocagallery-box-file:hover,
.phocagallery-box:hover,
.phocagallerycategories .category:hover,
.phocagallery-categories .category:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--pf-second, #18d4ff), transparent 35%) !important;
  box-shadow:
    0 28px 85px rgba(0,0,0,.30),
    0 0 0 1px color-mix(in srgb, var(--pf-second, #18d4ff), transparent 72%);
}

/* Raster neutralisieren und modernisieren */
.pg-categories-view,
.pg-category-view,
.phocagallery,
#phocagallery {
  gap: 1rem;
}

.pg-categories-view .pg-row,
.pg-category-view .pg-row,
#phocagallery .pg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 !important;
}

#phocagallery .pg-cv-box,
#phocagallery .pg-item-box,
.pg-cv-box,
.pg-item-box,
.pg-category-box {
  margin: .5rem !important;
  padding: .9rem !important;
}

/* Bilder */
.pg-item-box img,
.pg-category-box img,
.phocagallery-box-file img,
.phocagallery-box img,
#phocagallery img,
.com-phocagallery img,
.com_phocagallery img {
  border-radius: 18px;
  max-width: 100%;
  height: auto;
}

.pg-item-box img,
.phocagallery-box-file img,
.phocagallery-box img {
  width: 100%;
  object-fit: cover;
}

/* Phoca setzt teils Inline-Breiten. Diese Regel macht die Boxen responsive,
   ohne die Komponente zu beschädigen. */
.pg-category-view .pg-item-box,
.pg-categories-view .pg-cv-box,
#phocagallery .pg-item-box,
#phocagallery .pg-cv-box {
  max-width: min(100%, 320px);
}

/* Namen, Beschreibungen, Zähler */
.pg-name,
.pg-cv-name,
.pg-category-name,
.phocagallery-name,
.phocagallery-box-file-name,
.phocagallery-box-file-first,
.phocagallery-box-file-second,
#phocagallery .name {
  color: var(--pg-rufus-text) !important;
  font-weight: 850;
  letter-spacing: -.02em;
}

.pg-description,
.pg-category-desc,
.pg-cv-desc,
.phocagallery-desc,
.phocagallery-image-box-caption,
#phocagallery .small,
#phocagallery small {
  color: var(--pg-rufus-muted) !important;
  line-height: 1.65;
}

.pg-number,
.pg-num,
.pg-count,
.phocagallery-count,
#phocagallery .badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--pg-rufus-border);
  border-radius: 999px;
  padding: .25rem .55rem;
  background: rgba(255,255,255,.07);
  color: var(--pg-rufus-muted);
  font-weight: 700;
}

/* Buttons, Zurück, Weiter, Pagination */
#phocagallery .btn,
#phocagallery button,
.com-phocagallery .btn,
.com_phocagallery .btn,
.phocagallery .btn,
.pg-pagination a,
.pg-pagination span,
.pagination a,
.pagination span {
  border: 1px solid var(--pg-rufus-border) !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.08) !important;
  color: var(--pg-rufus-text) !important;
  box-shadow: none !important;
}

#phocagallery .btn:hover,
#phocagallery button:hover,
.com-phocagallery .btn:hover,
.com_phocagallery .btn:hover,
.phocagallery .btn:hover,
.pg-pagination a:hover,
.pagination a:hover {
  background: linear-gradient(135deg, var(--pf-accent, #ff8a00), var(--pf-second, #18d4ff)) !important;
  color: #101827 !important;
  border-color: transparent !important;
}

/* Kategorie-Filter oben, falls Phoca/Module Selects oder Formulare ausgeben */
#phocagallery select,
#phocagallery input,
#phocagallery textarea,
.com-phocagallery select,
.com-phocagallery input,
.com-phocagallery textarea,
.com_phocagallery select,
.com_phocagallery input,
.com_phocagallery textarea {
  border: 1px solid var(--pg-rufus-border);
  border-radius: 16px;
  background: rgba(17,24,39,.78);
  color: var(--pg-rufus-text);
  padding: .7rem .9rem;
}

#phocagallery label,
.com-phocagallery label,
.com_phocagallery label {
  color: var(--pg-rufus-muted);
}

/* Detailansicht / großes Bild */
.pg-detail-view,
#phocagallery .pg-detail,
.com-phocagallery .pg-detail {
  text-align: center;
}

.pg-detail-view img,
#phocagallery .pg-detail img,
.com-phocagallery .pg-detail img {
  max-height: min(72vh, 780px);
  object-fit: contain;
  border-radius: 28px;
  box-shadow: var(--pf-shadow, 0 24px 90px rgba(0,0,0,.35));
}

/* Plugin-Ausgabe innerhalb normaler Joomla-Beiträge */
.pf-component .phocagallery,
.pf-component #phocagallery {
  margin-top: 1rem;
}

/* Mobile */
@media (max-width: 760px) {
  .pg-category-view .pg-item-box,
  .pg-categories-view .pg-cv-box,
  #phocagallery .pg-item-box,
  #phocagallery .pg-cv-box,
  .phocagallery-box-file,
  .phocagallery-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: .45rem 0 !important;
  }

  .pg-categories-view .pg-row,
  .pg-category-view .pg-row,
  #phocagallery .pg-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}


/* Rufus v2.7.2: Sicherer Phoca-Popup-Fix
   Wichtig: Keine globalen Fancybox/Magnific/SqueezeBox-Regeln mehr.
   Dadurch wird die Lightbox nicht mehr schwarz überdeckt. Diese Regeln greifen nur,
   wenn Phoca Gallery innerhalb von Joomla tmpl=component geladen wird. */
body.pf-component-only.pf-com-phocagallery {
  background: #000 !important;
  min-height: 100vh;
  overflow: auto;
}

body.pf-component-only.pf-com-phocagallery .pf-page-bg {
  display: none !important;
}

body.pf-component-only.pf-com-phocagallery .pf-main {
  min-height: 100vh;
  margin: 0 !important;
  padding: 12px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000 !important;
}

body.pf-component-only.pf-com-phocagallery .pf-container,
body.pf-component-only.pf-com-phocagallery .pf-component {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.pf-component-only.pf-com-phocagallery .pf-component {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 24px);
}

body.pf-component-only.pf-com-phocagallery #phocagallery,
body.pf-component-only.pf-com-phocagallery .phocagallery,
body.pf-component-only.pf-com-phocagallery .pg-detail-view,
body.pf-component-only.pf-com-phocagallery .pg-detail,
body.pf-component-only.pf-com-phocagallery .phocagallery-detail,
body.pf-component-only.pf-com-phocagallery .phocagallery-image-box,
body.pf-component-only.pf-com-phocagallery .phocagallery-image-box-image {
  max-width: 100% !important;
  width: auto !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center !important;
  background: transparent !important;
}

body.pf-component-only.pf-com-phocagallery img {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: calc(100vw - 32px) !important;
  max-height: calc(100vh - 32px) !important;
  object-fit: contain !important;
  object-position: center center !important;
  margin: 0 auto !important;
  border-radius: 12px;
}

body.pf-component-only.pf-com-phocagallery .page-header,
body.pf-component-only.pf-com-phocagallery .pg-detail-title,
body.pf-component-only.pf-com-phocagallery .phocagallery-detail-title {
  display: none !important;
}

@media (max-width: 760px) {
  body.pf-component-only.pf-com-phocagallery .pf-main {
    padding: 8px !important;
  }

  body.pf-component-only.pf-com-phocagallery img {
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 16px) !important;
  }
}


/* Rufus v2.7.3: Kompakte Phoca-Detail-/Popup-Ansicht
   Ziel: Bild sichtbar, begrenzte Höhe, Bedienbuttons sichtbar */
body.pf-component-popup,
body.contentpane,
body.com_phocagallery,
body[class*="com_phocagallery"] {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(24, 212, 255, .16), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(255, 138, 0, .14), transparent 26rem),
    #03070d !important;
  color: #eef4ff !important;
}

body.pf-component-popup .pf-component-wrap,
body.contentpane .pf-component-wrap {
  width: min(1180px, calc(100vw - 24px));
  min-height: auto !important;
  margin: 12px auto !important;
  padding: clamp(10px, 2vw, 18px) !important;
  border-radius: 22px;
  background: rgba(10, 16, 27, .72);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 28px 90px rgba(0,0,0,.45);
}

body.pf-component-popup .pf-component-wrap #phocagallery,
body.contentpane .pf-component-wrap #phocagallery,
body.pf-component-popup .pf-component-wrap .phocagallery,
body.contentpane .pf-component-wrap .phocagallery,
body.pf-component-popup .pf-component-wrap .pg-detail,
body.contentpane .pf-component-wrap .pg-detail,
body.pf-component-popup .pf-component-wrap .pg-detail-box,
body.contentpane .pf-component-wrap .pg-detail-box,
body.pf-component-popup .pf-component-wrap .phocagallery-box-file,
body.contentpane .pf-component-wrap .phocagallery-box-file {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  margin: 0 auto !important;
  text-align: center !important;
  overflow: visible !important;
}

body.pf-component-popup .pf-component-wrap img,
body.contentpane .pf-component-wrap img,
body.pf-component-popup .pf-component-wrap #phocagallery img,
body.contentpane .pf-component-wrap #phocagallery img,
body.pf-component-popup .pf-component-wrap .phocagallery img,
body.contentpane .pf-component-wrap .phocagallery img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: calc(100vw - 64px) !important;
  max-height: calc(100vh - 150px) !important;
  object-fit: contain !important;
  margin: 0 auto 14px !important;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.65);
}

/* Phoca Toolbar / Buttons oben halten */
body.pf-component-popup .pf-component-wrap .pg-detail-buttons,
body.contentpane .pf-component-wrap .pg-detail-buttons,
body.pf-component-popup .pf-component-wrap .pg-csv-box,
body.contentpane .pf-component-wrap .pg-csv-box,
body.pf-component-popup .pf-component-wrap .pagination,
body.contentpane .pf-component-wrap .pagination,
body.pf-component-popup .pf-component-wrap .pagenav,
body.contentpane .pf-component-wrap .pagenav,
body.pf-component-popup .pf-component-wrap .buttonheading,
body.contentpane .pf-component-wrap .buttonheading,
body.pf-component-popup .pf-component-wrap .buttons,
body.contentpane .pf-component-wrap .buttons {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px !important;
  position: relative !important;
  z-index: 10 !important;
}

/* Allgemeine Aktionslinks im Popup sichtbar machen */
body.pf-component-popup .pf-component-wrap a,
body.contentpane .pf-component-wrap a,
body.pf-component-popup .pf-component-wrap button,
body.contentpane .pf-component-wrap button,
body.pf-component-popup .pf-component-wrap .btn,
body.contentpane .pf-component-wrap .btn {
  color: #06111c !important;
  text-decoration: none !important;
}

body.pf-component-popup .pf-component-wrap a[href],
body.contentpane .pf-component-wrap a[href],
body.pf-component-popup .pf-component-wrap button,
body.contentpane .pf-component-wrap button,
body.pf-component-popup .pf-component-wrap .btn,
body.contentpane .pf-component-wrap .btn,
body.pf-component-popup .pf-component-wrap input[type="button"],
body.contentpane .pf-component-wrap input[type="button"] {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, var(--pf-accent, #ff8a00), var(--pf-second, #18d4ff)) !important;
  color: #06111c !important;
  font-weight: 800 !important;
  box-shadow: 0 12px 32px rgba(24, 212, 255, .18);
}

/* Bildlinks sollen nicht wie Buttons aussehen */
body.pf-component-popup .pf-component-wrap a:has(img),
body.contentpane .pf-component-wrap a:has(img) {
  display: inline-block !important;
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 14px !important;
}

/* Falls Phoca absolute Positionen im Popup setzt */
body.pf-component-popup .pf-component-wrap [style*="position:absolute"],
body.contentpane .pf-component-wrap [style*="position:absolute"] {
  position: relative !important;
  left: auto !important;
  top: auto !important;
}

/* Verhindert den riesigen schwarzen Leerraum oberhalb vom Bild */
body.pf-component-popup .pf-component-wrap table,
body.contentpane .pf-component-wrap table {
  width: auto !important;
  max-width: 100% !important;
  margin: 0 auto !important;
}

body.pf-component-popup .pf-component-wrap td,
body.contentpane .pf-component-wrap td {
  vertical-align: middle !important;
  text-align: center !important;
}

/* Kompakter Button zum Schließen, falls Joomla/Phoca keinen sichtbaren bietet */
.pf-phoca-close-helper {
  position: fixed;
  right: 16px;
  top: 14px;
  z-index: 99999;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: linear-gradient(135deg, var(--pf-accent, #ff8a00), var(--pf-second, #18d4ff));
  color: #06111c !important;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 18px 45px rgba(0,0,0,.35);
}

@media (max-width: 700px) {
  body.pf-component-popup .pf-component-wrap,
  body.contentpane .pf-component-wrap {
    width: calc(100vw - 14px);
    margin: 7px auto !important;
    padding: 8px !important;
    border-radius: 16px;
  }

  body.pf-component-popup .pf-component-wrap img,
  body.contentpane .pf-component-wrap img,
  body.pf-component-popup .pf-component-wrap #phocagallery img,
  body.contentpane .pf-component-wrap #phocagallery img {
    max-width: calc(100vw - 28px) !important;
    max-height: calc(100vh - 118px) !important;
    border-radius: 12px;
  }

  .pf-phoca-close-helper {
    top: 8px;
    right: 8px;
    min-width: 38px;
    height: 38px;
  }
}
