/* ============================================================
   SoleSistas – Referenzfoto App (Styling) v2
   - 5 Schritte + Collage
   - Live-Overlay im Sucher (anpassbar: quadratisch / hochformatig)
   - Preview mit Overlay-Frame + Pinch-to-Zoom / Pan
   - Collage-Panel nach Schritt 2
   ============================================================ */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #e91e63;
  --danger: #f44336;
  --bg: #121212;
  --surface: #1e1e1e;
  --text: #ffffff;
  --text-secondary: #aaaaaa;
  --radius: 12px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0; left: 0;
}

.screen.active {
  display: flex;
}

/* ===== AUTH SCREEN ===== */
#auth-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
}

#auth-screen h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
}

#auth-screen .subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
}

.auth-form h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #333;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.input-group input:focus {
  border-color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 14px 28px;
  width: 100%;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  width: auto;
  padding: 8px 12px;
  font-size: 20px;
  background: transparent;
  color: var(--text);
}

.auth-toggle {
  text-align: center;
  margin-top: 20px;
}

.auth-toggle a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

/* ===== CAMERA SCREEN ===== */
#camera-screen {
  position: relative;
}

#camera-screen header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  background: var(--bg);
  z-index: 20;
}

#camera-screen h2 {
  font-size: 16px;
  text-align: center;
  flex: 1;
}

.spacer { width: 40px; }

/* Progress dots – 5 Punkte */
.progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #333;
  transition: background 0.2s, transform 0.2s;
}

.dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.dot.done {
  background: #4caf50;
}

/* Camera container – full viewport */
.camera-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

/* Fullscreen video – object-fit: cover */
#video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Live-Overlay im Sucher */
.overlay-masking {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none;
}

/* Standard-Overlay (quadratisch) – zwei Gradients */
.overlay-masking.square {
  background:
    linear-gradient(
      to right,
      rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.6) 25%,
      transparent 25%, transparent 75%,
      rgba(0,0,0,0.6) 75%, rgba(0,0,0,0.6) 100%
    ),
    linear-gradient(
      to bottom,
      rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.6) 25%,
      transparent 25%, transparent 75%,
      rgba(0,0,0,0.6) 75%, rgba(0,0,0,0.6) 100%
    );
}

/* Hochformat-Overlay (Full Body: ~9:16) */
.overlay-masking.portrait {
  background:
    linear-gradient(
      to right,
      rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.6) 25%,
      transparent 25%, transparent 75%,
      rgba(0,0,0,0.6) 75%, rgba(0,0,0,0.6) 100%
    ),
    linear-gradient(
      to bottom,
      rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.6) 37.5%,
      transparent 37.5%, transparent 62.5%,
      rgba(0,0,0,0.6) 62.5%, rgba(0,0,0,0.6) 100%
    );
}

/* Pinker Rahmen */
.overlay-border {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  border: 3px solid var(--primary);
  pointer-events: none;
}

/* Portrait-Rahmen (Full Body) */
.overlay-border.portrait {
  width: calc(min(100vw, 100vh) * 0.49);
  height: min(100vw, 100vh);
}

/* Camera switch button */
.btn-flip {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 22px;
  padding: 0;
  border: none;
  cursor: pointer;
  z-index: 10;
}

.btn-flip:active { opacity: 0.7; }

/* Capture button */
.camera-controls {
  display: flex;
  justify-content: center;
  padding: 16px 0;
  background: var(--bg);
}

.btn-capture {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  padding: 0;
  border: 4px solid rgba(255,255,255,0.3);
}

/* Instruction */
.instruction {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 24px 8px;
}

/* ===== PREVIEW PANEL ===== */
.preview-panel {
  background: var(--surface);
  padding: 16px;
}

.preview-panel h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

/* Preview viewer – Vollbild-Foto mit Overlay-Frame */
.preview-viewer {
  position: relative;
  width: 100%;
  aspect-ratio: var(--viewer-ar, 1);
  background: #000;
  overflow: hidden;
  touch-action: none; /* verhindert Browser-Zoom */
}

.preview-viewer img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain; /* Bild passt in den Container */
  transform-origin: center center;
  transition: transform 0.1s ease-out; /* sanftes Zoomen */
}

/* Overlay-Frame im Preview – zeigt den Crop-Ausschnitt an */
#overlay-frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: var(--overlay-w, 100%);
  height: var(--overlay-h, 100%);
  border: 2px solid rgba(255,255,255,0.7);
  pointer-events: none;
}

/* Semi-transparente Maske um den Overlay-Frame */
#overlay-frame::before {
  content: '';
  position: absolute;
  inset: -50vmax; /* Maske geht über den gesamten Container */
  background: rgba(0,0,0,0.5);
  clip-path: var(--clip-rect); /* transparenter Bereich = Overlay */
  pointer-events: none;
}

/* Retake / Confirm */
.preview-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.preview-actions .btn { flex: 1; }

/* Gallery */
.gallery {
  display: flex;
  gap: 6px;
  padding: 12px 0 0;
  overflow-x: auto;
}

.gallery-item {
  width: 56px; height: 56px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--primary);
}

.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ===== COLLAGE PANEL ===== */
.collage-panel {
  background: var(--surface);
  padding: 16px;
}

.collage-panel h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.collage-viewer {
  width: 100%;
  aspect-ratio: 1; /* Collage ist quadratisch */
}

.collage-viewer canvas {
  width: 100%;
  height: 100%;
}

/* Upload button */
#upload-btn {
  margin: 12px 24px;
}

/* ===== SUCCESS SCREEN ===== */
#success-screen {
  justify-content: center;
  align-items: center;
}

#success-screen h1 { font-size: 80px; color: #4caf50; }
#success-screen p { margin-top: 16px; font-size: 18px; color: var(--text-secondary); }
#success-screen .btn { margin-top: 32px; max-width: 280px; }

/* ===== LOADING OVERLAY ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid #333;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}
