@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;850&display=swap");

/* =========================================================
   MediaGallery UI — Dark Glass / Windows 11 Photos-inspired
   ========================================================= */

:root {
  /* Layout */
  --header-h: 72px;
  --max-w: 1400px;

  /* Colors */
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --danger: #ef4444;

  --bg: #050505;
  --bg-2: #0a0a0a;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-bg-2: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.55);

  /* Radius / Shadow */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.55);

  /* Typography */
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  /* Transitions */
  --t: 180ms cubic-bezier(0.2, 0, 0.2, 1);

  /* Justified layout spacing (sollte 0 sein für “ohne sichtbare Abstände”) */
  --jl-gap: 0px;

  /* Selection */
  --sel-max: 10;
}

/* --------------------------
   Base / Reset
-------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* Subtle background glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(800px 500px at 12% 10%, rgba(59,130,246,0.10), transparent 55%),
    radial-gradient(700px 450px at 85% 20%, rgba(34,197,94,0.07), transparent 60%),
    radial-gradient(circle at top left, #111, #050505);
  z-index: -1;
}

/* --------------------------
   Utilities
-------------------------- */
.hidden { display: none !important; }
.invisible { visibility: hidden !important; }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--text-muted); }
.sep { height: 1px; background: var(--border); margin: 16px 0; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 520ms var(--t) both; }

/* --------------------------
   Layout Containers
-------------------------- */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px;
}

.page.full {
  max-width: 100%;
  padding: 0;
}

/* Standard content spacing under sticky header */
.with-topbar {
  padding-top: 18px;
}

/* --------------------------
   Topbar / Header
-------------------------- */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  background: rgba(5,5,5,0.72);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right { justify-content: flex-end; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.main-logo {
  height: 42px;
  width: auto;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.06));
  transition: transform var(--t);
}
.main-logo:hover { transform: scale(1.04); }

.brand-text-wrapper { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Small counters in topbar */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
}
.pill strong { color: var(--text); font-weight: 800; }

/* --------------------------
   Buttons
-------------------------- */
.btn, button.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--t), background var(--t), border-color var(--t), box-shadow var(--t), opacity var(--t);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover, button.btn:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-1px);
}
.btn:active, button.btn:active { transform: translateY(0); }
.btn:disabled, button.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn i, button.btn i { font-size: 16px; opacity: 0.9; }

.btn-primary {
  background: #fff;
  color: #000;
  border: none;
}
.btn-primary:hover {
  background: rgba(255,255,255,0.92);
  box-shadow: 0 0 22px rgba(255,255,255,0.08);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.12);
  color: #fff;
}

.btn-danger {
  border-color: rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.10);
}
.btn-danger:hover {
  border-color: rgba(239,68,68,0.55);
  background: rgba(239,68,68,0.16);
}

.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 12px 18px; font-size: 15px; border-radius: 14px; }

/* Button group */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* --------------------------
   Panels / Cards / Titles
-------------------------- */
.panel {
  padding: 26px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: 24px;
}
.panel-title {
  font-size: 26px;
  font-weight: 850;
  letter-spacing: -0.02em;
  margin: 0 0 8px 0;
}
.panel-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

/* --------------------------
   Dashboard Grid (Galleries)
-------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.tile {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #0f0f0f;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 10;
  transition: transform 260ms var(--t), border-color var(--t), box-shadow var(--t);
}

.tile-media {
  width: 100%;
  height: 100%;
  display: block;
}
.tile img,
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform 520ms cubic-bezier(0.2, 0, 0.2, 1);
  filter: saturate(1.02) contrast(1.02);
}

.tile:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 14px 34px rgba(0,0,0,0.45);
}
.tile:hover img,
.tile:hover video {
  transform: scale(1.05);
}

.tile-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 14px 12px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
  display: grid;
  gap: 3px;
}
.tile-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin: 0;
}
.tile-sub {
  margin: 0;
  color: rgba(255,255,255,0.72);
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.tile-sub .dot { width: 4px; height: 4px; background: rgba(255,255,255,0.35); border-radius: 50%; display: inline-block; }

/* Optional “badge” on tile */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}
.badge i { font-size: 13px; opacity: 0.9; }

/* --------------------------
   Gallery Header / Toolbar
-------------------------- */
.gallery-head {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 18px 24px 12px 24px;
}

.gallery-title {
  margin: 0;
  font-size: 24px;
  font-weight: 850;
  letter-spacing: -0.02em;
}
.gallery-desc {
  margin: 8px 0 0 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.gallery-toolbar {
  max-width: var(--max-w);
  margin: 10px auto 10px auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.toolbar-left,
.toolbar-right {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.counter {
  color: var(--text-muted);
  font-size: 13px;
}
.counter strong { color: #fff; font-weight: 850; }

/* Toggle pill button (e.g. selection mode) */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  transition: background var(--t), border-color var(--t), transform var(--t);
}
.toggle:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.18); transform: translateY(-1px); }
.toggle .state { width: 34px; height: 18px; border-radius: 999px; background: rgba(255,255,255,0.10); border: 1px solid var(--border); position: relative; }
.toggle .state::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,0.55); position: absolute; top: 1px; left: 1px; transition: transform var(--t), background var(--t); }
.toggle.on .state { background: rgba(59,130,246,0.22); border-color: rgba(59,130,246,0.4); }
.toggle.on .state::after { transform: translateX(16px); background: #fff; }

/* --------------------------
   Justified Gallery Grid
   - Container with no visible gaps
-------------------------- */
.gallery-wrap {
  width: 100%;
  padding: 0;
}

.justified {
  width: 100%;
  padding: 0;
  margin: 0;
  /* if your JS applies inline styles/rows, this is just the base */
}

/* Each item gets height from justified layout JS; we enforce seamless look */
.j-item {
  position: relative;
  overflow: hidden;
  border-radius: 0; /* seamless tiles */
  background: #0b0b0b;
  border: none;
  margin: var(--jl-gap);
}

/* Media inside item */
.j-item img,
.j-item .thumb,
.j-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.001);
  transition: transform 520ms cubic-bezier(0.2, 0, 0.2, 1);
}

/* Optional “contain” mode */
.gallery-contain .j-item img,
.gallery-contain .j-item .thumb,
.gallery-contain .j-item video {
  object-fit: contain;
  background: #070707;
}

.j-item:hover img,
.j-item:hover .thumb,
.j-item:hover video {
  transform: scale(1.03);
}

/* Slight overlay on hover (subtle) */
.j-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.02), rgba(0,0,0,0.04));
  opacity: 0;
  transition: opacity var(--t);
  pointer-events: none;
}
.j-item:hover::after { opacity: 1; }

/* Type badge (video) */
.media-type {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 5;
}

/* --------------------------
   Selection Mode
-------------------------- */
.select-mode .j-item { cursor: pointer; }
.select-mode .j-item::after { opacity: 1; }

.check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.95);
  background: rgba(0,0,0,0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 6;
  transform: scale(0.92);
  transition: opacity var(--t), transform var(--t), background var(--t), border-color var(--t);
}

.select-mode .check { opacity: 1; transform: scale(1); }

.selected {
  outline: 2px solid rgba(59,130,246,0.9);
  outline-offset: -2px;
}
.selected .check {
  background: rgba(59,130,246,0.92);
  border-color: rgba(59,130,246,0.92);
}
.selected .check::after {
  content: "\f272";
  font-family: "bootstrap-icons";
  font-size: 14px;
  color: #fff;
}

/* Selection bar (optional fixed bottom bar) */
.selection-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: none;
  padding: 12px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,10,10,0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 16px 60px rgba(0,0,0,0.6);
}
.select-mode .selection-bar { display: flex; }
.selection-bar .left { display: flex; align-items: center; gap: 12px; flex: 1; }
.selection-bar .right { display: flex; align-items: center; gap: 10px; }
.selection-bar .count {
  font-weight: 850;
  letter-spacing: -0.01em;
}
.selection-bar .hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* --------------------------
   Forms / Inputs (Admin/Password)
-------------------------- */
.input, input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: #fff;
  outline: none;
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.35); }
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: rgba(59,130,246,0.55);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
  background: rgba(255,255,255,0.04);
}

.form-row { display: grid; gap: 12px; }
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --------------------------
   Dropzone / Upload
-------------------------- */
.dropzone {
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.02);
  border-radius: var(--r-lg);
  padding: 22px;
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--text-muted);
  transition: background var(--t), border-color var(--t), transform var(--t);
}
.dropzone.dragover {
  border-color: rgba(59,130,246,0.65);
  background: rgba(59,130,246,0.08);
  color: rgba(255,255,255,0.85);
  transform: translateY(-1px);
}
.dropzone .big {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}
.dropzone .small {
  font-size: 13px;
  color: var(--text-muted);
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: rgba(59,130,246,0.9);
  transition: width 160ms linear;
}

/* --------------------------
   Tables (Admin)
-------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.table th, .table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: left;
  font-size: 13px;
}
.table th {
  color: rgba(255,255,255,0.72);
  font-weight: 800;
  letter-spacing: 0.01em;
  background: rgba(255,255,255,0.02);
}
.table tr:hover td { background: rgba(255,255,255,0.03); }

/* --------------------------
   Toast / Alert
-------------------------- */
.alert {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: var(--r-md);
  padding: 12px 14px;
  color: rgba(255,255,255,0.86);
}
.alert.info { border-color: rgba(59,130,246,0.35); background: rgba(59,130,246,0.08); }
.alert.warn { border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.08); }
.alert.danger { border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.10); }

/* --------------------------
   PhotoSwipe v5 minimal theming
-------------------------- */
/* Keep it subtle; PhotoSwipe has its own UI. */
.pswp { --pswp-bg: rgba(0,0,0,0.92); }
.pswp__top-bar, .pswp__bottom-bar { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pswp__button { opacity: 0.9; }
.pswp__button:hover { opacity: 1; }
.pswp__counter { color: rgba(255,255,255,0.75); }

/* --------------------------
   Responsive
-------------------------- */
.mobile-only { display: none; }

@media (max-width: 980px) {
  header.topbar { padding: 0 16px; }
  .page { padding: 18px; }
  .form-row.two { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  header.topbar {
    grid-template-columns: 1fr auto;
  }
  .header-left { display: none; }
  .mobile-only { display: flex; }

  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .gallery-head { padding: 14px 16px 10px 16px; }
  .gallery-toolbar { padding: 0 16px; }

  .selection-bar {
    left: 12px; right: 12px; bottom: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .selection-bar .right { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

#justified {
  position: relative;
}

#justified .tile {
  position: absolute;
  display: block;
  overflow: hidden;
  border-radius: 10px;
}

#justified img.media {
  width: 100%;
  height: 100%;
  display: block;
}

#justified[data-fit="cover"] img.media { object-fit: cover; }
#justified[data-fit="contain"] img.media { object-fit: contain; background: rgba(255,255,255,.03); }

.lock-panel[hidden] { display: none !important; }

.lock-panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  z-index: 9999;
}


/* Stil für den "Laden" Spinner passend zum Design */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Anpassung der Gallery-Buttons für Mobile */
@media (max-width: 600px) {
  .gallery-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-right {
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }
}