/*
 * ============================================================================
 * ST Gallery Frontend - Kombinierte CSS-Datei
 * ============================================================================
 * Version: 2.6.0
 * Autor: AI Assistent "Henry" für WDSB / SaarlandToday
 * Datum: 2025-08-23
 *
 * Kombiniert alle Frontend-Styles:
 * - Base Gallery Styles
 * - Selection Overlay Styles
 * - Modal Styles
 * - Action Bar Styles
 * ============================================================================
 */

/* ============================================================================
 * BASE GALLERY STYLES
 * ============================================================================ */

/* Maximal-Breite-Begrenzung für große Bildschirme (iMac 5K, etc.) */
.st-gallery-content-view,
.st-gallery-wrapper,
.st-gallery {
  max-width: 1940px;
  margin: 0 auto; /* Zentrierung */
  padding: 0 1rem; /* Seitenabstand */
}

/* Basis Styles für Galerie-Container und Bilder */
.st-gallery-image-container,
.st-galerie-item-img {
  position: relative;
  display: inline-block;
  margin: 2px 5px;
  background-image: linear-gradient(#bbb, #ddd);
}

.st-gallery-image-container img,
.st-galerie-item-img img {
  display: block;
  max-width: 100%;
  height: auto;
}

.st-gallery-image-container img:hover,
.st-galerie-item-img img:hover {
  mix-blend-mode: luminosity;
}

/* Bildauswahl (Nummern-Label als Button) */
.st-galerie-item-no:hover {
  background-color: rgba(255, 157, 0, 0.9);
  opacity: 0.8;
}

.st-galerie-item-no.selected {
  background-color: #68B42D;
  color: white;
  border: 2px solid #fff;
}

/* Ausgewähltes Bild optisch hervorheben */
.st-gallery-image-container.selected {
  border: 5px solid #68B42D;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  border-radius: 5px;
}

.st-galerie-item.selected {
  transform: scale(0.95);
  opacity: 0.9;
}

/* ============================================================================
 * SELECTION OVERLAY STYLES
 * ============================================================================ */

.st-galerie-item-img { 
  position: relative; 
}

.st-gallery-select{
  position: absolute; 
  top: 8px; 
  right: 8px;
  width: 36px; 
  height: 36px; 
  border-radius: 6px;
  border: 2px solid #ff0; 
  background: rgba(255, 255, 0, 0.75); /* #ff0 mit 75% Deckkraft */
  cursor: pointer; 
  z-index: 5; 
  box-sizing: border-box;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}

.st-gallery-select:hover,
.st-gallery-select:focus-visible{
  background: rgba(255, 162, 0, 0.75); /* #ffa200 mit 75% Deckkraft */
  border-color: #ffa200;
  transform: scale(1.05);
}

.st-gallery-select.is-selected{
  background: rgba(104, 180, 45, 0.9); /* #68B42D mit 90% Deckkraft */
  border-color: #68B42D;
  color: white;
}

/* Häkchen für ausgewählte Bilder */
.st-gallery-select.is-selected::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.st-gallery-select.is-selected:hover,
.st-gallery-select.is-selected:focus-visible{
  background: rgba(104, 180, 45, 1); /* #68B42D mit 100% Deckkraft */
  border-color: #4a8a1f;
  transform: scale(1.05);
}

.st-gallery-select:focus-visible{
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.st-gallery-select:active{
  transform: scale(0.95);
}

/* Ausgewähltes Item hervorheben */
.st-gallery-item-selected {
  border: 3px solid #68B42D !important;
  box-shadow: 0 0 15px rgba(104, 180, 45, 0.5) !important;
  border-radius: 8px !important;
}

.st-gallery-item-selected::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(104, 180, 45, 0.1);
  border-radius: 8px;
  pointer-events: none;
  z-index: 1;
}

/* ============================================================================
 * MODAL STYLES
 * ============================================================================ */

.stg-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
}

.stg-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.stg-modal__card {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stg-modal__header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stg-modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.stg-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.stg-modal__close:hover {
  color: #374151;
  background-color: #f3f4f6;
}

.stg-modal__body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
}

.stg-modal__footer {
  padding: 16px 24px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ST Gallery Modal (Legacy) */
.st-gallery-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.st-gallery-modal-content {
  background: white;
  border-radius: 8px;
  max-width: 90%;
  max-height: 90%;
  overflow: auto;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.st-gallery-modal-title {
  margin: 0 0 15px 0;
  padding: 20px 20px 0 20px;
  font-size: 1.5rem;
  color: #333;
}

.st-gallery-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 5px;
  line-height: 1;
}

.st-gallery-modal-close:hover {
  color: #000;
}

.st-gallery-modal-body {
  padding: 20px;
}

/* Modal Open State */
.st-gallery-modal-open {
  overflow: hidden;
}

/* ============================================================================
 * ACTION BAR STYLES
 * ============================================================================ */

.st-gallery-fixed-actions{
  position:fixed !important; 
  right:20px !important; 
  bottom:20px !important; 
  z-index:9999 !important;
  display:none !important; /* Standardmäßig versteckt */
  flex-direction:column !important; /* Buttons untereinander */
  gap:5px !important; /* 5px Margin zwischen Buttons */
  background:rgba(17,24,39,.85) !important; /* slate-900 */
  border:1px solid rgba(255,255,255,.15) !important;
  border-radius:10px; 
  padding:10px 12px !important;
  backdrop-filter:saturate(120%) blur(2px);
  min-width:200px;
  visibility:hidden !important;
  opacity:0 !important;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* Sichtbar wenn Bilder ausgewählt sind */
.st-gallery-fixed-actions.has-selection {
  display:flex !important;
  visibility:visible !important;
  opacity:1 !important;
}

/* Debug-Style für sichtbare Button-Leiste */
.st-gallery-fixed-actions[data-debug="true"] {
  background:rgba(255,0,0,.8) !important; /* Rot für Debug */
  border:3px solid yellow !important;
}

.st-gallery-actions {
  display: flex !important;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem;
  background: #f8f9fa;
  border: 2px solid #007bff;
  border-radius: 8px;
  margin: 1rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  position: relative;
  align-items: center;
  justify-content: center;
  max-width: 1940px;
}

/* Action Bar Standardmäßig versteckt */
.st-gallery-actions[data-stg-action-bar="1"] {
  display: none;
}

/* Action Bar sichtbar bei Auswahl */
.st-gallery-actions[data-stg-action-bar="1"].is-visible {
  display: flex !important;
}

.st-gallery-action-btn {
  padding: 0.75rem 1.5rem;
  border: 1px solid #007bff;
  background: #007bff;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
  min-height: 48px;
  white-space: nowrap;
  text-align: center;
  flex-shrink: 0;
}

.st-gallery-action-btn:hover {
  background: #0056b3;
  border-color: #0056b3;
}

.st-gallery-action-btn:focus {
  outline: 2px solid #80bdff;
  outline-offset: 2px;
}

.st-gallery-action-btn.stg-select-all {
  background: #28a745;
  border-color: #28a745;
}

.st-gallery-action-btn.stg-select-all:hover {
  background: #1e7e34;
  border-color: #1e7e34;
}

.st-gallery-action-btn.stg-clear {
  background: #dc3545;
  border-color: #dc3545;
}

.st-gallery-action-btn.stg-clear:hover {
  background: #c82333;
  border-color: #c82333;
}

.st-gallery-action-btn.stg-request {
  background: #ffc107;
  border-color: #ffc107;
  color: #212529;
}

.st-gallery-action-btn.stg-request:hover {
  background: #e0a800;
  border-color: #e0a800;
}

.st-gallery-action-btn.stg-download {
  background: #17a2b8;
  border-color: #17a2b8;
}

.st-gallery-action-btn.stg-download:hover {
  background: #138496;
  border-color: #138496;
}

.stg-counts-button {
  background: #6c757d !important;
  border-color: #6c757d !important;
  font-weight: 600;
  min-width: 120px;
}

.stg-counts-button:hover {
  background: #5a6268 !important;
  border-color: #5a6268 !important;
}

.stg-counts-display {
  font-weight: 600;
  color: #495057;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid #ced4da;
  border-radius: 4px;
  min-width: 120px;
  text-align: center;
  font-size: 0.9rem;
}

/* ============================================================================
 * COUNTS MODAL STYLES
 * ============================================================================ */

.stg-counts-modal-content {
  padding: 1rem;
  text-align: center;
}

.stg-counts-modal-content h3 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.stg-counts-modal-content strong {
  color: #007bff;
  font-weight: 600;
}

.stg-counts-modal-content small {
  color: #6c757d;
  font-size: 0.875rem;
  line-height: 1.4;
}

/* ============================================================================
 * RESPONSIVE DESIGN MIT DRUPAL'S ELEGANTEM GRID-SYSTEM
 * ============================================================================
 * 
 * Drupal's CSS Grid macht responsive Design einfach und elegant:
 * - Keine manuellen calc() Berechnungen mehr
 * - Keine komplexen clamp() Formeln mehr
 * - Fließende Übergänge ohne Sprünge
 * - Automatische Anpassung von 360px bis 5400px (iMac 5K)
 * 
 * Maximal-Breite: Bei Viewports > 2024px wird auf 1940px begrenzt und zentriert
 * ============================================================================ */

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

.st-galerie-item-no:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.st-gallery-select:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .st-gallery-select,
  .st-gallery-action-btn,
  .stg-modal__close {
    transition: none;
  }
  
  .st-gallery-select:hover,
  .st-gallery-select:focus-visible {
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .st-gallery-select {
    border-width: 3px;
  }
  
  .st-gallery-item-selected {
    border-width: 4px !important;
  }
}

/* ============================================================================
 * PRINT STYLES
 * ============================================================================ */

@media print {
  .st-gallery-select,
  .st-gallery-actions,
  .st-gallery-fixed-actions {
    display: none !important;
  }
  
  .st-gallery-image-container,
  .st-galerie-item-img {
    break-inside: avoid;
  }
}
