/*
  style.css — Modernes Pastell‑Layout (Mint / Sky) mit Light & Dark Theme
  -----------------------------------------------------------------------
  • Farbthemen via CSS‑Variablen
  • Sanfte Schatten, große Rundungen, angenehme Abstände
  • Responsives Grid für Bild‑Karten
  • Fokus‑Ringe & Reduktion von Motion bei Bedarf

  Anwendung:
  1) <link rel="stylesheet" href="./style.css"> in index.html (im <head>)
  2) Theme setzen:
     - Automatik (System): nichts weiter nötig
     - Manuell: <html data-theme="light"> oder <html data-theme="dark">
*/

/* =============================
   Farbvariablen
   ============================= */
:root {
  /* Basiston (Light) – helle Pastelle Mint/Sky */
  --mint-50:  #edfff8;
  --mint-100: #dbfff0;
  --mint-200: #c4f6e6;
  --mint-300: #a8ead6;
  --mint-400: #86e3c3;
  --mint-500: #5fd7af;
  --mint-600: #36c39a;

  --sky-50:   #f0f9ff;
  --sky-100:  #e0f2fe;
  --sky-200:  #cceafe;
  --sky-300:  #b3ddfd;
  --sky-400:  #93c5fd;
  --sky-500:  #60a5fa;
  --sky-600:  #3b82f6;

  --gray-25:  #fcfcfd;
  --gray-50:  #f6f7f9;
  --gray-100: #eef1f5;
  --gray-200: #e3e8ef;
  --gray-300: #c6ced8;
  --gray-400: #9aa7b8;
  --gray-500: #6b7788;
  --gray-600: #4a5568;
  --gray-700: #364152;
  --gray-800: #273142;
  --gray-900: #1c2535;

  /* Semantic Tokens (Light) */
  --bg:            var(--gray-25);
  --bg-elev:       #ffffff;
  --bg-elev-2:     var(--gray-50);
  --text:          #0f172a;
  --text-muted:    #475569;
  --border:        rgba(4, 120, 87, 0.14); /* mintiger Rand */
  --shadow:        0 8px 24px rgba(0, 0, 0, 0.06);
  --ring:          rgba(59, 130, 246, 0.35); /* sky glow */

  --primary:       var(--mint-500);
  --primary-600:   var(--mint-600);
  --primary-50:    var(--mint-50);
  --accent:        var(--sky-500);
  --accent-600:    var(--sky-600);
  --accent-50:     var(--sky-50);

  --radius-sm:     10px;
  --radius-md:     14px;
  --radius-lg:     18px;
  --radius-xl:     22px;

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Dark Theme Overrides */
:root[data-theme="dark"] {
  --bg:          #0b1220;
  --bg-elev:     #101827;
  --bg-elev-2:   #0f172a;
  --text:        #e6eef8;
  --text-muted:  #a9b4c3;
  --border:      rgba(148, 210, 189, 0.20); /* mintiger Rand */
  --shadow:      0 10px 28px rgba(0, 0, 0, 0.55);
  --ring:        rgba(125, 211, 252, 0.45);

  --primary:     #4ad2b5; /* etwas leuchtender in Dark */
  --primary-600: #2fbf9e;
  --primary-50:  rgba(74, 210, 181, 0.10);
  --accent:      #7cc5ff;
  --accent-600:  #58a9ff;
  --accent-50:   rgba(124, 197, 255, 0.10);
}

/* Automatik: falls kein data-theme gesetzt ist */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:          #0b1220;
    --bg-elev:     #101827;
    --bg-elev-2:   #0f172a;
    --text:        #e6eef8;
    --text-muted:  #a9b4c3;
    --border:      rgba(148, 210, 189, 0.20);
    --shadow:      0 10px 28px rgba(0, 0, 0, 0.55);
    --ring:        rgba(125, 211, 252, 0.45);

    --primary:     #4ad2b5;
    --primary-600: #2fbf9e;
    --primary-50:  rgba(74, 210, 181, 0.10);
    --accent:      #7cc5ff;
    --accent-600:  #58a9ff;
    --accent-50:   rgba(124, 197, 255, 0.10);
  }
}

/* =============================
   Base / Reset
   ============================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--accent-50) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, canvas, svg, video { display: block; max-width: 100%; }
button { font: inherit; }
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring), inset 0 0 0 1px var(--bg);
  border-radius: var(--radius-sm);
}

/* Bewegung reduzieren */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =============================
   Layout‑Container & Topbar
   ============================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

header.app-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(1.1) blur(8px);
  background: color-mix(in oklab, var(--bg-elev) 86%, transparent);
  border-bottom: 1px solid var(--border);
}
header.app-header .header-row {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) 0;
}
.app-title {
  font-weight: 700; letter-spacing: 0.2px; font-size: 1.2rem;
}
.header-spacer { flex: 1; }

/* Statusbar unterhalb des Headers */
#statusBar {
  display: none; /* wird per JS auf flex gesetzt */
  align-items: center; flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3);
  margin: var(--space-4) 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
#statusBar .stat {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-md);
  background: var(--primary-50);
  color: var(--text);
}

/* =============================
   Upload / DropArea
   ============================= */
#dropArea {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 200px;
  padding: var(--space-6);
  border: 2px dashed color-mix(in oklab, var(--primary) 50%, var(--text) 10%);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--primary-50) 100%);
  color: var(--text-muted);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
#dropArea.highlight {
  border-color: var(--accent);
  box-shadow: 0 10px 24px color-mix(in oklab, var(--accent) 15%, transparent);
  transform: translateY(-2px);
}
#uploadBtn {
  margin-top: var(--space-3);
}

/* =============================
   Buttons
   ============================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--primary) 86%, white) 0%, var(--primary) 100%);
  color: #053b33;
  border-color: color-mix(in oklab, var(--primary) 60%, transparent);
}
.btn-primary:hover {
  box-shadow: 0 10px 28px color-mix(in oklab, var(--primary) 25%, transparent);
}

.btn-outline {
  background: transparent;
  border-color: color-mix(in oklab, var(--text) 18%, transparent);
}

/* kleine runde Icon‑Buttons (Karten‑Aktionen) */
.image-action-btn {
  width: 36px; height: 36px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}
.image-action-btn:hover { box-shadow: var(--shadow); }

/* =============================
   Grid & Karten
   ============================= */
#imageContainer {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-4);
}
@media (max-width: 1200px) { #imageContainer { grid-template-columns: repeat(9, 1fr); } }
@media (max-width: 900px)  { #imageContainer { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 640px)  { #imageContainer { grid-template-columns: repeat(4, 1fr); } }

.image-card {
  grid-column: span 4;
  position: relative;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.image-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.08); }
.image-card.selected { border-color: color-mix(in oklab, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px var(--accent-50) inset; }

.image-preview { position: relative; overflow: hidden; border-radius: var(--radius-md); background: var(--bg-elev-2); }
.image-preview canvas { width: 100%; height: auto; display: block; }

.image-info {
  font-size: 0.92rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.image-actions { display: inline-flex; gap: var(--space-2); }

/* Dropdown für Formate */
.format-dropdown {
  position: absolute; right: var(--space-3); top: 58px;
  display: none; flex-direction: column; min-width: 160px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-elev); box-shadow: var(--shadow); z-index: 10;
}
.format-dropdown.active { display: flex; }
.format-option {
  padding: 10px 12px; cursor: pointer; color: var(--text);
}
.format-option:hover { background: var(--accent-50); }
.format-option.disabled { cursor: not-allowed; color: var(--text-muted); }

/* Resize‑Panel */
.image-resize-panel {
  max-height: 0; overflow: hidden; border-top: 1px dashed var(--border);
  transition: max-height 220ms ease;
}
.image-resize-panel.active { max-height: 260px; }
.image-resize-controls { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-3); padding-top: var(--space-3); }
.input-group label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; }
.input-group input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
}
.checkbox-group { display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.image-resize-actions { display: flex; gap: var(--space-2); padding-top: var(--space-3); }

/* =============================
   Empty State
   ============================= */
#emptyState {
  display: grid; place-items: center; gap: var(--space-3);
  text-align: center; color: var(--text-muted);
  padding: var(--space-6);
  border: 1px dashed var(--border); border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--accent-50) 100%);
}

/* =============================
   Tooltip / Popup
   ============================= */
#popup {
  position: fixed; pointer-events: none; z-index: 1000;
  opacity: 0; transition: opacity 120ms ease;
  padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: .88rem;
}
#popup .popup-item { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
#popup .popup-label { color: var(--text-muted); }
#popup .popup-value { font-feature-settings: "tnum" 1, "lnum" 1; }

/* =============================
   Modals (PDF & Multi‑Format)
   ============================= */
#pdfSettingsModal, #formatSelectionModal {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 1200;
  background: color-mix(in oklab, var(--bg) 40%, rgba(0,0,0,.35));
  padding: var(--space-5);
}
#pdfSettingsModal.active, #formatSelectionModal.active { display: grid; }

.modal-container {
  width: min(640px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: var(--space-5);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body { display: grid; gap: var(--space-3); }
.modal-footer { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); }

/* PDF Formularfelder */
.modal-body .row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.modal-body input[type="text"],
.modal-body select {
  width: 100%; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text);
}
.modal-body .check { display: flex; align-items: center; gap: 10px; }

/* Format‑Checkboxliste */
#formatCheckboxes { display: grid; gap: 10px; margin: var(--space-2) 0; }
.format-checkbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-elev-2); }
.format-checkbox.disabled { opacity: 0.6; }

/* =============================
   Preview Overlay
   ============================= */
#previewOverlay {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 1100;
  background: color-mix(in oklab, var(--bg) 35%, rgba(0,0,0,.45));
  padding: var(--space-6);
}
#previewOverlay.active { display: grid; }
#previewCanvas {
  max-width: 90vw; max-height: 80vh; border-radius: var(--radius-lg);
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
}
#previewClose {
  position: absolute; top: 22px; right: 22px; z-index: 1;
}

/* =============================
   Loading Indicator
   ============================= */
#loadingIndicator {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 1300;
  background: color-mix(in oklab, var(--bg) 35%, rgba(0,0,0,.45));
}
#loadingIndicator.active { display: grid; }
#loadingIndicator .box {
  display: grid; place-items: center; gap: 10px; padding: 18px 22px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
#loadingIndicator .spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-50); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================
   Browser‑Warnung
   ============================= */
#browserWarning {
  display: none; margin: var(--space-3) 0; padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--accent-50); color: color-mix(in oklab, var(--text) 80%, var(--accent));
  border: 1px solid color-mix(in oklab, var(--accent) 45%, transparent);
}

/* =============================
   Hilfsklassen
   ============================= */
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 999px; background: var(--accent-50); color: var(--text); border: 1px solid var(--border); }

/* =============================
   Theme‑Toggle (optional, falls vorhanden)
   ============================= */
.theme-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev);
}
.theme-toggle:hover { box-shadow: var(--shadow); }
