/* ============================================
   Pet Roulette Styles
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #ff6b6b;
  --primary-dark: #ee5a52;
  --secondary: #4ecdc4;
  --background: #f7f7f7;
  --surface: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #ecf0f1;
  --success: #2ecc71;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============== NAVBAR ============== */

.navbar {
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.navbar-menu {
  display: flex;
  gap: 1rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.nav-btn:hover {
  color: var(--primary);
}

.nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============== MAIN CONTENT ============== */

.container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.view {
  display: none;
  width: 100%;
  max-width: 700px;
  animation: fadeIn 0.3s;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============== FEED VIEW (VS MODE) ============== */

.versus-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0;
}

.vs-slot {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 4 / 3;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--border);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.4s;
  touch-action: manipulation;
}

.vs-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

.vs-choose-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.38);
  color: white;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
}

.vs-slot:hover .vs-choose-hint {
  opacity: 1;
}

.vs-slot:hover {
  transform: scale(1.01);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.vs-divider {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
  background: var(--surface);
  border: 3px solid var(--primary);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  margin: -10px 0;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

@keyframes winnerPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7); }
  60%  { box-shadow: 0 0 0 18px rgba(255, 107, 107, 0); transform: scale(1.03); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); transform: scale(1); }
}

@keyframes holdFill {
  from { box-shadow: inset 0 0 0 0 rgba(255,107,107,0.0), 0 0 0 0 rgba(255,107,107,0); }
  to   { box-shadow: inset 0 0 0 4px rgba(255,107,107,0.9), 0 0 0 6px rgba(255,107,107,0.25); }
}

.vs-slot.hold-progress {
  animation: holdFill 1.5s linear forwards;
}

.vs-slot.winner {
  animation: winnerPulse 0.6s ease-out forwards;
  border: 3px solid var(--primary);
}

.vs-slot.loser {
  opacity: 0.35;
  transform: scale(0.97);
}

.vs-slot.loading {
  opacity: 0.5;
}

.report-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  /* Touch: immer leicht sichtbar */
  opacity: 0.45;
  transition: opacity 0.2s, background 0.2s;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  padding: 0;
}

/* Desktop mit echter Maus: nur bei Hover zeigen */
@media (hover: hover) {
  .report-btn {
    opacity: 0;
  }
  .vs-slot:hover .report-btn {
    opacity: 1;
  }
}

.report-btn:hover {
  background: rgba(180, 0, 0, 0.65);
}

/* Inline-Bestätigung nach Long-Press */
.report-confirm {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 20;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius);
}

.report-confirm.visible {
  display: flex;
}

.report-confirm-text {
  color: white;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.report-confirm-btns {
  display: flex;
  gap: 0.75rem;
}

.report-confirm-btns .btn {
  padding: 0.55rem 1.25rem;
  font-size: 0.9rem;
}

/* No-Matches-Karte wenn alle Gegner bereits besiegt */
.no-matches-card {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--surface);
  z-index: 15;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-radius: var(--radius);
}

.no-matches-card.visible {
  display: flex;
}

.no-matches-icon {
  font-size: 2.5rem;
}

.no-matches-text {
  color: var(--text-light);
  font-size: 0.85rem;
  line-height: 1.5;
}

.no-matches-reset-btn {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  padding: 0.5rem 1.1rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #ddd;
  transform: translateY(-2px);
}

/* ============== UPLOAD VIEW ============== */

.upload-container {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.upload-container h2 {
  margin-bottom: 1.5rem;
  color: var(--primary);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(255, 107, 107, 0.05);
}

.drop-zone p {
  color: var(--text-light);
  margin: 0;
}

.preview-container {
  margin-top: 1.5rem;
}

#preview-image {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.preview-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid var(--border);
}

.category-selection {
  background: var(--background);
  padding: 1.5rem;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.category-selection h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.category-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cat-btn {
  padding: 0.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.cat-btn:hover {
  border-color: var(--primary);
}

.cat-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.selected-cats {
  padding: 0.5rem 0;
  color: var(--text-light);
  font-size: 0.9rem;
}

.dsgvo-check {
  background: rgba(255, 107, 107, 0.06);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.dsgvo-check label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
}

.dsgvo-check input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--primary);
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

.btn-large {
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
}

.upload-status {
  text-align: center;
  padding: 2rem;
}

.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#status-message {
  color: var(--text-light);
}

.success-message {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  animation: slideIn 0.3s;
}

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============== STATS VIEW ============== */

.stats-container {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-container h2 {
  margin-bottom: 2rem;
  color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--background);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

/* ============== LEADERBOARD ============== */

.leaderboard-container {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.leaderboard-container h2 {
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.leaderboard-hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.leaderboard-empty {
  color: var(--text-light);
  text-align: center;
  padding: 2rem 0;
}

.lb-card {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--border);
}

.lb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lb-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.85rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.62));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.lb-rank {
  font-size: 1.3rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.lb-likes {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ============== MEINE FOTOS ============== */

.mine-container {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.mine-container h2 {
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.mine-hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.mine-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mine-empty {
  color: var(--text-light);
  text-align: center;
  padding: 2rem 0;
}

.mine-entry {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 500px;
  margin: 0 auto;
}

.mine-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--border);
}

.mine-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mine-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.85rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.62));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.mine-likes {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.mine-ttl {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.mine-expired-card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
  border: 1px solid var(--border);
}

.mine-expired-inner {
  color: var(--text-light);
  font-size: 1rem;
  font-weight: 600;
}

.mine-date {
  font-size: 0.78rem;
  color: var(--text-light);
  text-align: center;
}



@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .container {
    padding: 1rem;
  }

  .category-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .controls {
    flex-wrap: wrap;
  }

  .btn {
    flex: 1;
    min-width: 100px;
  }
}

/* ============== CROP MODAL ============== */

.crop-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.crop-modal-inner {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.crop-counter {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.crop-hint {
  font-size: 0.82rem;
  color: var(--text-light);
  margin: -0.5rem 0 0;
}

.crop-viewport {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  position: relative;
  cursor: grab;
  background: #000;
  border-radius: var(--radius);
  touch-action: none;
  border: 2px solid var(--border);
}

.crop-viewport:active {
  cursor: grabbing;
}

#crop-img {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  pointer-events: none;
  transform-origin: top left;
  max-width: none;
}

.crop-modal-btns {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.crop-modal-btns .btn {
  flex: 1;
}

/* ============== ACCESSIBILITY ============== */

#report-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.88);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}

#report-toast.toast-visible {
  opacity: 1;
}

/* ============== ACCESSIBILITY ============== */

button:focus,
input:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
