/* ============================================================ */
/* Baustellenüberwachung – modernes, dunkles UI                  */
/* ============================================================ */

:root {
  --bg:        #0b0f15;
  --bg-2:      #11161f;
  --surface:   #161c27;
  --surface-2: #1c2330;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.14);
  --text:      #e7ecf3;
  --text-2:    #aab3c2;
  --muted:     #7a8497;
  --accent:    #ffb547;     /* warmes Baustellen-Gelb */
  --accent-2:  #ff8a3d;
  --danger:    #ff6b6b;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,0.35);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.5);
  --font:      ui-sans-serif, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { overflow-x: hidden; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255,181,71,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(80,130,255,0.08), transparent 55%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: rgba(11,15,21,0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.2px; min-width: 0; }
.brand-mark {
  display: inline-block; width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(255,138,61,0.45);
}
.brand-logo {
  height: 28px; width: auto; max-width: 160px;
  display: block; object-fit: contain;
  border-radius: 6px;
}
.brand-logo.brand-logo-lg { height: 96px; max-width: 260px; border-radius: 12px; }
.brand-text { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 8px 14px; border-radius: 999px;
  color: var(--text-2); font-weight: 500; font-size: 14px;
  transition: background 120ms ease, color 120ms ease;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active {
  background: linear-gradient(135deg, rgba(255,181,71,0.20), rgba(255,138,61,0.10));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255,181,71,0.35);
}

.user { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--text-2); font-size: 13px; }
.logout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border);
}
.logout:hover { background: var(--surface-2); color: var(--text); }

/* ---------------- Page ---------------- */
.page {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 20px 40px;
  flex: 1 0 auto;          /* schiebt den Footer ans Seitenende */
}

/* ---------------- Footer (nur angemeldet) ---------------- */
.sitefoot {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 18px);
  background: rgba(11,15,21,0.65);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
.sitefoot-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 6px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  text-align: center;
}
.sitefoot-line strong { color: var(--text); font-weight: 600; }
.sitefoot-sep { color: var(--muted); }
.sitefoot a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.18);
  text-underline-offset: 3px;
  transition: text-decoration-color 120ms ease, color 120ms ease;
}
.sitefoot a:hover { text-decoration-color: var(--accent); }
.sitefoot a:hover strong { color: var(--accent); }
@media (max-width: 480px) {
  .sitefoot-sep { display: none; }
  .sitefoot-inner { gap: 2px; flex-direction: column; }
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: end; justify-content: space-between;
  margin-bottom: 22px;
}
.toolbar-title h1 {
  font-size: 26px; font-weight: 700; margin: 0 0 4px;
  letter-spacing: -0.2px;
}
.muted { color: var(--muted); }

.toolbar-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar-controls input[type=date],
.toolbar-controls select,
.toolbar-controls button {
  appearance: none; -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: 10px 14px;
  border-radius: 10px;
  font: inherit;
  min-height: 42px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.toolbar-controls input[type=date]:focus,
.toolbar-controls select:focus {
  border-color: var(--accent);
}
.toolbar-controls input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  cursor: pointer;
}

/* Tag-Navigation: Pfeile + Datums-Dropdown als Gruppe */
.day-nav {
  display: flex; gap: 6px; align-items: stretch; min-width: 0;
}
.day-nav .day-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; min-height: 42px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  font-size: 20px; line-height: 1;
  user-select: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  flex: 0 0 auto;
}
.day-nav a.day-arrow:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
.day-nav span.day-arrow { opacity: 0.35; cursor: not-allowed; color: var(--text-2); }
.day-nav .dd, .day-nav > select { flex: 1 1 auto; min-width: 0; }

/* ---------------- Grid ---------------- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.grid.videos { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.card img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  background: var(--bg-2);
}
.card-label {
  position: absolute; left: 8px; bottom: 8px;
  font-size: 11px; padding: 4px 8px;
  background: rgba(0,0,0,0.55); color: #fff;
  border-radius: 6px; backdrop-filter: blur(4px);
  letter-spacing: 0.3px;
}

/* Video-Karten */
.video-card { display: flex; flex-direction: column; }
.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.video-thumb img,
.video-thumb video {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 200ms ease;
}
.card:hover .video-thumb img,
.card:hover .video-thumb video { transform: scale(1.03); }
.play-badge {
  position: absolute; inset: 0; margin: auto;
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 22px; color: #1a1a1a;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  padding-left: 4px;
  transition: transform 140ms ease;
}
.card:hover .play-badge { transform: scale(1.08); }
.card-meta {
  display: flex; flex-direction: row; align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.card-meta-text {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 auto; min-width: 0;
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.1px; }
.card-sub   { font-size: 12.5px; }

.card-download {
  flex: 0 0 auto;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-2);
  font-size: 17px; line-height: 1;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.card-download:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}
.card-download:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------------- Empty State ---------------- */
.empty {
  text-align: center;
  margin: 80px auto;
  max-width: 460px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 40px 24px;
}
.empty-icon { font-size: 42px; margin-bottom: 6px; }
.empty h2 { margin: 6px 0 6px; font-size: 18px; }
.empty code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-2); padding: 2px 6px; border-radius: 6px;
  font-size: 12.5px; color: var(--text-2);
}

/* ---------------- Login ---------------- */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  font-family: var(--font); color: var(--text);
  background:
    radial-gradient(700px 400px at 50% -10%, rgba(255,181,71,0.18), transparent 60%),
    radial-gradient(600px 400px at 50% 110%, rgba(80,130,255,0.10), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(380px, 92vw);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand {
  display: flex; align-items: center; justify-content: center;
  margin: 4px 0 12px;
}
.brand-mark-lg {
  width: 72px; height: 72px; border-radius: 18px;
}
.login-card h1 { margin: 4px 0 8px; font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.login-card input {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.login-card input:focus { border-color: var(--accent); background: var(--surface-2); }
.login-card button {
  margin-top: 6px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1300;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 80ms ease, filter 120ms ease;
}
.login-card button:hover { filter: brightness(1.05); }
.login-card button:active { transform: translateY(1px); }
.alert {
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.35);
  color: #ffb3b3;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

/* ---------------- Custom Dropdown ---------------- */
.dd { position: relative; min-width: 0; }
select.dd-native {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.dd-trigger {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: 10px 14px;
  border-radius: 10px;
  font: inherit;
  min-height: 42px;
  min-width: 140px;
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease;
}
.dd-trigger:hover  { background: var(--surface-2); }
.dd-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dd.open .dd-trigger { border-color: var(--accent); }
.dd-label {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-chev {
  font-size: 18px; line-height: 1;
  color: var(--text-2);
  transition: transform 160ms ease;
}
.dd.open .dd-chev { transform: rotate(180deg); color: var(--accent); }

.dd-sheet {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; min-width: 100%;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  max-height: min(360px, 60vh);
  overflow-y: auto;
  animation: dd-pop 130ms ease;
}
@keyframes dd-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.dd-head { display: none; }
.dd-list { display: flex; flex-direction: column; gap: 2px; }
.dd-item {
  display: block; width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
  white-space: nowrap;
}
.dd-item:hover { background: var(--surface-2); }
.dd-item.active {
  background: linear-gradient(135deg, rgba(255,181,71,0.20), rgba(255,138,61,0.10));
  box-shadow: inset 0 0 0 1px rgba(255,181,71,0.30);
  color: var(--text);
  font-weight: 600;
}

.dd-backdrop {
  position: fixed; inset: 0;
  z-index: 70;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: dd-fade 150ms ease;
  display: none;
}
.dd-backdrop[hidden] { display: none !important; }
@keyframes dd-fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 641px) {
  .dd-backdrop { display: none !important; }
}

@media (max-width: 640px) {
  .dd { width: 100%; }
  .dd-trigger { width: 100%; min-width: 0; }
  .dd-backdrop:not([hidden]) { display: block; }
  body.dd-open { overflow: hidden; }

  .dd-sheet {
    position: fixed;
    top: auto; left: 0; right: 0; bottom: 0;
    min-width: 0;
    z-index: 80;
    border-radius: 18px 18px 0 0;
    border: 1px solid var(--border-2);
    border-bottom: 0;
    padding: 8px 10px max(14px, env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow: hidden;          /* nur die Liste scrollt, nicht die Sheet selbst */
    flex-direction: column;
    animation: dd-slide-up 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 -20px 60px rgba(0,0,0,0.55);
  }
  .dd-sheet[hidden] { display: none !important; }
  .dd-sheet:not([hidden]) { display: flex; }
  .dd-sheet .dd-head { flex: 0 0 auto; }
  .dd-sheet .dd-list { flex: 1 1 auto; overflow-y: auto; min-height: 0;
                       -webkit-overflow-scrolling: touch; }
  @keyframes dd-slide-up {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
  .dd-head {
    display: flex; flex-direction: column; align-items: center;
    padding: 6px 0 10px;
    gap: 8px;
  }
  .dd-handle {
    width: 44px; height: 4px; border-radius: 999px;
    background: rgba(255,255,255,0.20);
  }
  .dd-title {
    font-size: 13px; color: var(--text-2);
    text-transform: uppercase; letter-spacing: 0.8px;
  }
  .dd-item { padding: 14px 14px; font-size: 15.5px; }
}

/* ---------------- PhotoSwipe Caption ---------------- */
.pswp-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 60px calc(env(safe-area-inset-bottom, 0px) + 18px);
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
  pointer-events: none;
}

/* ---------------- Video-Player Overlay ---------------- */
.vp {
  position: fixed; inset: 0;
  background: rgba(5,7,10,0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: vp-in 180ms ease;
}
.vp[hidden] { display: none !important; }
@keyframes vp-in { from { opacity: 0; } to { opacity: 1; } }

.vp-stage {
  width: min(1180px, 96vw);
  max-height: 92vh;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  touch-action: pan-y;
}
.vp-video {
  width: 100%;
  max-height: 78vh;
  background: #000;
  border-radius: 12px;
  outline: none;
  box-shadow: var(--shadow-lg);
}
.vp-caption {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text);
  text-align: center;
}
.vp-title { font-size: 16px; font-weight: 600; }
.vp-sub   { font-size: 13px; }

.vp-close, .vp-nav {
  position: absolute;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(20,24,32,0.7);
  color: #fff;
  border: 1px solid var(--border-2);
  display: grid; place-items: center;
  font-size: 22px;
  transition: background 120ms ease, transform 120ms ease;
}
.vp-close:hover, .vp-nav:hover { background: rgba(40,48,62,0.9); transform: scale(1.05); }
.vp-close { top: 18px; right: 18px; font-size: 18px; }
.vp-prev  { left: 18px; top: 50%; transform: translateY(-50%); }
.vp-next  { right: 18px; top: 50%; transform: translateY(-50%); }
.vp-prev:hover { transform: translateY(-50%) scale(1.05); }
.vp-next:hover { transform: translateY(-50%) scale(1.05); }

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand-logo { height: 26px; max-width: 110px; }
  .brand-text { display: none; }            /* nur Logo, kein Markenname */
  .nav { margin-left: auto; gap: 2px; }
  .nav a { padding: 7px 10px; font-size: 13px; }
  .user-name { display: none; }             /* spart Platz neben Logout */
  .logout { width: 36px; height: 36px; }

  .toolbar { gap: 12px; align-items: flex-start; }
  .toolbar-title h1 { font-size: 22px; }
  .toolbar-controls { width: 100%; }
  .toolbar-controls select { width: 100%; }
  .day-nav { width: 100%; }

  .page { padding: 16px 12px 60px; }
  .grid { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .grid.videos { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

  .vp-prev, .vp-next { width: 42px; height: 42px; font-size: 20px; }
  .vp-close { top: 12px; right: 12px; }
  .vp-prev  { left: 10px; }
  .vp-next  { right: 10px; }
  .vp-stage { width: 100vw; padding: 0 8px; }
  .vp-video { max-height: 70vh; border-radius: 8px; }
}

@media (max-width: 380px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid.videos { grid-template-columns: 1fr; }
  .nav a { padding: 6px 8px; }
}
