/* ==========================================================================
   Fotoalbum - Themes & Basisstile
   Drei Farbschemata ueber CSS Custom Properties: hell, dunkel, kunterbunt.
   Das aktive Schema wird per data-theme-Attribut auf <html> gesetzt
   (siehe static/js/theme.js).
   ========================================================================== */

:root[data-theme="hell"] {
  --bg-gradient: linear-gradient(160deg, #fff6e9 0%, #ffe9d6 45%, #fef3e0 100%);
  --bg: #fff8f0;
  --surface: #ffffff;
  --surface-alt: #fff3e6;
  --text: #2b2118;
  --text-muted: #6b5b4d;
  --primary: #e8672a;
  --primary-contrast: #ffffff;
  --secondary: #16847c;
  --accent: #ffb703;
  --border: #f0dcc4;
  --focus: #0b5da3;
  --shadow: rgba(60, 40, 10, 0.14);
  --success: #21813f;
  --danger: #b3273e;
  --warning: #a8630c;
  --info: #0b6fa8;
  --link: #b34d16;
}

:root[data-theme="dunkel"] {
  --bg-gradient: linear-gradient(160deg, #0e151c 0%, #142029 55%, #101922 100%);
  --bg: #101820;
  --surface: #182430;
  --surface-alt: #202f3c;
  --text: #f2ede3;
  --text-muted: #c3cdd3;
  --primary: #ff9a52;
  --primary-contrast: #14202a;
  --secondary: #57d8cb;
  --accent: #ffd873;
  --border: #2c3c49;
  --focus: #8fd6ff;
  --shadow: rgba(0, 0, 0, 0.45);
  --success: #4fce7c;
  --danger: #ff8590;
  --warning: #ffc971;
  --info: #7fd1ff;
  --link: #ffb27a;
}

:root[data-theme="kunterbunt"] {
  --bg-gradient: linear-gradient(135deg, #ff9a76 0%, #ffd66b 35%, #6ee7d8 70%, #7fb2ff 100%);
  --bg: #fff2f8;
  --surface: #ffffff;
  --surface-alt: #fff0f7;
  --text: #241b2f;
  --text-muted: #5b4d68;
  --primary: #e2436a;
  --primary-contrast: #ffffff;
  --secondary: #0f9488;
  --accent: #f2a900;
  --border: #f3c8dd;
  --focus: #163fae;
  --shadow: rgba(90, 30, 60, 0.18);
  --success: #157a41;
  --danger: #c22245;
  --warning: #a15a00;
  --info: #163fae;
  --link: #c22b5e;
}

/* ==========================================================================
   Basis
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient) fixed;
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3, h4 { line-height: 1.25; }

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

img { max-width: 100%; display: block; }

/* ==========================================================================
   Kopfzeile
   ========================================================================== */

.site-header {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.65rem;
  padding-bottom: 0.4rem;
}

.header-nav-row {
  display: flex;
  padding-top: 0;
  padding-bottom: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 2.4rem; width: auto; display: block; }

.main-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.main-nav a, .main-nav button.linklike {
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
}
.main-nav a:hover, .main-nav button.linklike:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

/* Theme-Umschalter */
.theme-switch {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
  flex-shrink: 0;
}
.theme-switch button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1;
}
.theme-switch button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-contrast);
}

/* ==========================================================================
   Flash-Meldungen
   ========================================================================== */

.flash-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.95rem;
}
.flash-success { background: color-mix(in srgb, var(--success) 18%, var(--surface)); border-color: var(--success); }
.flash-danger  { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); border-color: var(--danger); }
.flash-warning { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); border-color: var(--warning); }
.flash-info    { background: color-mix(in srgb, var(--info) 18%, var(--surface)); border-color: var(--info); }

/* ==========================================================================
   Karten / Buttons / Formulare
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px -12px var(--shadow);
  padding: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  background: var(--primary);
  color: var(--primary-contrast);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:hover { text-decoration: none; box-shadow: 0 6px 16px -6px var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

form .field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.92rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], textarea, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
.field-error { color: var(--danger); font-size: 0.85rem; margin-top: 0.25rem; }
.field-hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.checkbox-field { display: flex; align-items: flex-start; gap: 0.5rem; }
.checkbox-field input { width: auto; margin-top: 0.3rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.badge-aktiv { color: var(--success); }
.badge-entwurf { color: var(--warning); }
.badge-archiviert { color: var(--text-muted); }

table {
  width: 100%;
  border-collapse: collapse;
  /* Auf schmalen Bildschirmen darf die Tabelle horizontal scrollen statt
     die Seite zu sprengen - "display:block" macht das ohne zusaetzliches
     Wrapper-Markup in jedem Template moeglich. */
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; white-space: nowrap; }
th { color: var(--text-muted); font-weight: 700; }

/* ==========================================================================
   Landing / Auth
   ========================================================================== */

.hero {
  padding: 4rem 0 3rem;
  text-align: center;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 0.5rem; }
.hero p { color: var(--text-muted); font-size: 1.15rem; max-width: 640px; margin: 0 auto 1.75rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.auth-shell {
  max-width: 460px;
  margin: 2.5rem auto;
}

/* ==========================================================================
   Galerie
   ========================================================================== */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
}
.photo-thumb {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .meta-badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 0.72rem;
  padding: 0.1rem 0.4rem; border-radius: 999px;
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(10, 8, 6, 0.92);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.lightbox.open { display: flex; }
.lightbox-content { max-width: 96vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.lightbox-content img { max-height: 76vh; border-radius: 10px; }
.lightbox-caption { color: #f5ede0; text-align: center; max-width: 720px; }
.lightbox-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.15); color: #fff; border: none; font-size: 1.6rem; padding: 0.6rem 0.9rem; border-radius: 999px; cursor: pointer; }
.lightbox-nav.prev { left: 1rem; }
.lightbox-nav.next { right: 1rem; }
.lightbox-close { position: fixed; top: 1rem; right: 1rem; background: rgba(255,255,255,0.15); color: #fff; border: none; font-size: 1.4rem; padding: 0.5rem 0.8rem; border-radius: 999px; cursor: pointer; }

/* ==========================================================================
   Timeline
   ========================================================================== */

.timeline-day { margin-bottom: 2rem; }
.timeline-day h3 { border-bottom: 2px solid var(--accent); display: inline-block; padding-bottom: 0.2rem; }
.timeline-item {
  display: flex; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px dashed var(--border);
  align-items: flex-start;
}
.timeline-item img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; flex-shrink: 0; cursor: pointer; }
.timeline-item.highlight { background: var(--surface-alt); border-radius: 12px; }
.timeline-section { background: var(--surface-alt); border-radius: 14px; padding: 1rem 1.25rem; margin: 1rem 0; }

/* ==========================================================================
   Karte
   ========================================================================== */

#karte { height: 60vh; min-height: 360px; border-radius: 18px; border: 1px solid var(--border); }
.map-controls { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; align-items: center; }
.leaflet-popup-content { font-family: inherit; }
.album-marker-badge {
  background: var(--primary); color: var(--primary-contrast);
  border-radius: 999px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35); white-space: nowrap;
}

/* ==========================================================================
   Upload
   ========================================================================== */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 18px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-alt);
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--primary); color: var(--text); }
.upload-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.5rem; }
.upload-item { display: flex; align-items: center; gap: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.5rem 0.75rem; }
.upload-item .name { flex: 1; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; width: 100px; }
.progress-bar > span { display: block; height: 100%; background: var(--secondary); width: 0%; transition: width 0.15s; }
.status-ok { color: var(--success); }
.status-fehler { color: var(--danger); }
.status-duplikat { color: var(--warning); }
.overall-progress { margin: 1rem 0; }
.upload-panel-collapsed { display: none; }
.back-link { display: inline-block; margin-bottom: 1rem; }

/* ==========================================================================
   Fusszeile
   ========================================================================== */

.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.site-footer a { color: var(--text-muted); }
.site-footer .version { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Utility
   ========================================================================== */

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mt-lg { margin-top: 2rem; }
.mb-lg { margin-bottom: 2rem; }
.text-muted { color: var(--text-muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.1rem; }
.stat-tile .num { font-size: 1.7rem; font-weight: 700; }
.stat-tile .label { color: var(--text-muted); font-size: 0.85rem; }

@media (max-width: 640px) {
  .header-top { gap: 0.5rem; }
  .brand-logo { height: 2rem; }
  .theme-switch button { padding: 0.3rem 0.45rem; font-size: 0.9rem; }
  .main-nav { width: 100%; justify-content: space-between; }
  .hero { padding: 2.5rem 0 2rem; }
  .card-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.4rem; }
  .lightbox-nav { font-size: 1.3rem; padding: 0.5rem 0.7rem; }
  .lightbox-content img { max-height: 62vh; }
}
