/* =============================================
   📸 Fotos Hugo — Design System
   PWA de Captura Fotográfica para Eventos
   ============================================= */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* ── Design Tokens ── */
:root {
  /* Colors — Dark party theme with neon accents */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --bg-glass-hover: rgba(255, 255, 255, 0.1);

  --accent-primary: #e040fb;    /* Magenta neon */
  --accent-secondary: #00e5ff;  /* Cyan neon */
  --accent-warm: #ff6d00;       /* Orange fire */
  --accent-success: #00e676;    /* Green success */
  --accent-danger: #ff1744;     /* Red danger */

  --text-primary: #f5f5f7;
  --text-secondary: rgba(245, 245, 247, 0.6);
  --text-muted: rgba(245, 245, 247, 0.35);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(224, 64, 251, 0.3);

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #e040fb 0%, #00e5ff 50%, #e040fb 100%);
  --gradient-button: linear-gradient(135deg, #e040fb 0%, #ab47bc 100%);
  --gradient-button-hover: linear-gradient(135deg, #ea80fc 0%, #ce93d8 100%);
  --gradient-warm: linear-gradient(135deg, #ff6d00 0%, #e040fb 100%);
  --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(224, 64, 251, 0.08) 0%, transparent 50%),
                 radial-gradient(ellipse at 80% 20%, rgba(0, 229, 255, 0.06) 0%, transparent 50%);

  /* Typography */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-glow: 0 0 30px rgba(224, 64, 251, 0.2);
  --shadow-glow-intense: 0 0 60px rgba(224, 64, 251, 0.35);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 200ms;
  --duration-normal: 350ms;
  --duration-slow: 600ms;

  /* Layout */
  --max-width: 480px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  background-image: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
}

h1 { font-size: 2.25rem; letter-spacing: -0.03em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; }

.text-gradient {
  background: var(--gradient-hero);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  to { background-position: 200% center; }
}

.text-muted { color: var(--text-secondary); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }

/* ── Layout Utilities ── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: calc(var(--space-3xl) + var(--safe-bottom));
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ── Glass Card ── */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.glass-elevated {
  background: var(--bg-glass);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-smooth);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-button);
  color: white;
  box-shadow: var(--shadow-glow);
  min-height: 64px;
  font-size: 1.25rem;
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-glow-intense);
}

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--gradient-button-hover);
    box-shadow: var(--shadow-glow-intense);
    transform: translateY(-2px);
  }
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(10px);
}

.btn-secondary:active {
  background: var(--bg-glass-hover);
  transform: scale(0.97);
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-full);
  font-size: 1.25rem;
}

.btn-xl {
  min-height: 72px;
  font-size: 1.5rem;
  padding: var(--space-lg) var(--space-2xl);
  width: 100%;
  border-radius: var(--radius-xl);
}

/* Button ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
}

.btn:active::after {
  opacity: 1;
}

/* ── Input ── */
.input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-smooth),
              box-shadow var(--duration-fast) var(--ease-smooth);
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(224, 64, 251, 0.15);
}

/* ── Progress Bar ── */
.progress-container {
  width: 100%;
  height: 6px;
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.progress-container.active {
  opacity: 1;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-hero);
  background-size: 200% auto;
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.3s ease-out;
  animation: shimmer 2s linear infinite;
}

/* ── Status Messages ── */
.status {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideUp 0.4s var(--ease-spring);
}

.status.visible {
  display: flex;
}

.status-success {
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid rgba(0, 230, 118, 0.2);
  color: var(--accent-success);
}

.status-error {
  background: rgba(255, 23, 68, 0.1);
  border: 1px solid rgba(255, 23, 68, 0.2);
  color: var(--accent-danger);
}

.status-uploading {
  background: rgba(224, 64, 251, 0.1);
  border: 1px solid rgba(224, 64, 251, 0.2);
  color: var(--accent-primary);
}

/* ── Photo Grid (Masonry) ── */
.photo-grid {
  width: 100%;
  columns: 2;
  column-gap: var(--space-sm);
  padding: var(--space-md);
}

@media (min-width: 600px) {
  .photo-grid { columns: 3; }
}

@media (min-width: 900px) {
  .photo-grid { columns: 4; }
}

/* ── Photo Card ── */
.photo-card {
  break-inside: avoid;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--bg-card);
  animation: fadeInUp 0.6s var(--ease-spring) both;
}

.photo-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-smooth);
}

@media (hover: hover) {
  .photo-card:hover img {
    transform: scale(1.05);
  }
}

.photo-card .photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.photo-card:hover .photo-overlay,
.photo-card:active .photo-overlay {
  opacity: 1;
}

.photo-card .photo-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.photo-card .photo-time {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
}

/* Reaction badge on photo */
.photo-card .reaction-badge {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.photo-card:hover .reaction-badge,
.photo-card .reaction-badge.has-reactions {
  opacity: 1;
}

/* ── Polaroid Entry Animation ── */
@keyframes polaroidDrop {
  0% {
    opacity: 0;
    transform: translateY(-60px) rotate(calc(var(--rot, 0) * 1deg)) scale(0.7);
  }
  60% {
    opacity: 1;
    transform: translateY(8px) rotate(calc(var(--rot, 0) * 0.5deg)) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

.photo-card.polaroid-enter {
  animation: polaroidDrop 0.8s var(--ease-spring) both;
}

/* ── Reaction Popup ── */
.reaction-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-lg) var(--space-lg) calc(var(--space-xl) + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.reaction-popup.open {
  transform: translateY(0);
}

.reaction-popup .emoji-row {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
}

.reaction-popup .emoji-btn {
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-md);
  border-radius: var(--radius-full);
  transition: transform var(--duration-fast) var(--ease-spring),
              background var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}

.reaction-popup .emoji-btn:active {
  transform: scale(1.4);
  background: var(--bg-glass-hover);
}

.reaction-popup .emoji-btn.selected {
  background: var(--bg-glass-hover);
  transform: scale(1.1);
}

/* Reaction overlay (dim background) */
.reaction-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
}

.reaction-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Filter Selector ── */
.filter-strip {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-md) 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-strip::-webkit-scrollbar { display: none; }

.filter-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--duration-fast),
              transform var(--duration-fast) var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}

.filter-thumb.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(224, 64, 251, 0.3);
}

.filter-thumb:active {
  transform: scale(0.92);
}

.filter-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.filter-thumb .filter-label {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* CSS Filters */
.filter-none { filter: none; }
.filter-sepia { filter: sepia(0.8) contrast(1.1) brightness(1.05); }
.filter-bw { filter: grayscale(1) contrast(1.2); }
.filter-vivid { filter: saturate(1.6) contrast(1.1) brightness(1.05); }
.filter-vintage { filter: sepia(0.3) contrast(0.9) brightness(0.95) hue-rotate(-10deg); }
.filter-warm { filter: sepia(0.15) saturate(1.3) brightness(1.05); }

/* ── Slideshow ── */
.slideshow {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 1000;
  overflow: hidden;
}

.slideshow-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
}

.slideshow-image.active {
  opacity: 1;
  animation: kenBurns 8s ease-in-out forwards;
}

@keyframes kenBurns {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.08) translate(-1%, -1%); }
}

.slideshow-info {
  position: absolute;
  bottom: var(--space-2xl);
  left: var(--space-2xl);
  right: var(--space-2xl);
  z-index: 10;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s, transform 0.8s;
}

.slideshow-info.visible {
  opacity: 1;
  transform: translateY(0);
}

.slideshow-info .slide-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}

.slideshow-info .slide-time {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

.slideshow-counter {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  font-family: var(--font-display);
  font-size: 0.875rem;
  color: rgba(255,255,255,0.5);
  z-index: 10;
}

/* ── Confetti Canvas ── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.lightbox.open {
  display: flex;
  opacity: 1;
}

.lightbox img {
  max-width: 95vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox .close-btn {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  font-size: 1.5rem;
  color: white;
  background: rgba(255,255,255,0.1);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Counter Badge ── */
.counter-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.counter-badge .count {
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

.animate-fadeIn { animation: fadeIn 0.6s var(--ease-smooth) both; }
.animate-fadeInUp { animation: fadeInUp 0.6s var(--ease-spring) both; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }

/* Stagger children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 320ms; }

/* ── Loading Spinner ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Header ── */
.app-header {
  width: 100%;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header .logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Navigation Link ── */
.nav-link {
  color: var(--accent-secondary);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.875rem;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  transition: background var(--duration-fast);
}

.nav-link:active {
  background: var(--bg-glass);
}

/* ── Upload Preview ── */
.upload-preview {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: none;
  margin: 0 auto;
}

.upload-preview.visible {
  display: block;
  animation: fadeInUp 0.5s var(--ease-spring);
}

.upload-preview img,
.upload-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Photo Count Ticker ── */
.ticker {
  font-variant-numeric: tabular-nums;
  transition: all 0.3s var(--ease-spring);
}

.ticker.bump {
  transform: scale(1.3);
  color: var(--accent-primary);
}

/* ── No Photos Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  color: var(--text-secondary);
}

.empty-state .emoji {
  font-size: 4rem;
  animation: pulse 3s ease-in-out infinite;
}

/* ── Mobile-safe area adjustments ── */
@supports (padding: max(0px)) {
  .page {
    padding-top: max(var(--space-lg), env(safe-area-inset-top));
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

/* ── Selection ── */
::selection {
  background: rgba(224, 64, 251, 0.3);
  color: white;
}

/* ── Print (hide everything except gallery for printing) ── */
@media print {
  body { background: white; color: black; }
  .app-header, .btn, .nav-link, .counter-badge,
  .reaction-popup, .reaction-overlay { display: none !important; }
  .photo-card { break-inside: avoid; }
}

/* ── Admin Mode ── */
.admin-delete-btn {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(220, 38, 38, 0.85); /* red */
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 20;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

body.admin-mode .admin-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-red 1s infinite alternate;
}

@keyframes pulse-red {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  100% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
}
