/**
 * DASEIN SOCIAL — Design System
 * 
 * FILOSOFIA:
 * - Preto como âncora (#0a0a0a)
 * - Branco como ação (#ffffff)
 * - Cinza como hierarquia (#888, #444, #222)
 * - Transparência como profundidade
 * 
 * ESTRUTURA:
 * 1. Variables (cores, timing, sizing)
 * 2. Reset & Base
 * 3. Typography
 * 4. Layout (screens, containers)
 * 5. Components (buttons, inputs)
 * 6. Camera-specific
 * 7. Animations & Feedback
 */

/* ===========================================
   1. VARIABLES
   =========================================== */

:root {
  /* Cores principais */
  --color-bg: #0a0a0a;
  --color-bg-elevated: #111111;
  --color-surface: #1a1a1a;
  
  --color-text-primary: #ffffff;
  --color-text-secondary: #888888;
  --color-text-tertiary: #444444;
  
  --color-border: #222222;
  --color-border-focus: #333333;
  
  /* Feedback */
  --color-success: #22c55e;
  --color-error: #ef4444;
  
  /* Timing — easeOutExpo para sensação premium */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  
  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  
  /* Sizing */
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 32px;
  --spacing-xl: 48px;
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Safe areas (iOS notch) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}


/* ===========================================
   2. RESET & BASE
   =========================================== */

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  background: var(--color-bg);
  color: var(--color-text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}


/* ===========================================
   3. TYPOGRAPHY
   =========================================== */

.text-title {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.5px;
}

.text-heading {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.3px;
}

.text-body {
  font-size: 15px;
  font-weight: 300;
  line-height: 1.5;
}

.text-caption {
  font-size: 13px;
  font-weight: 300;
  color: var(--color-text-secondary);
}

.text-micro {
  font-size: 11px;
  font-weight: 300;
  color: var(--color-text-tertiary);
  letter-spacing: 0.5px;
}


/* ===========================================
   4. LAYOUT
   =========================================== */

/* Screens — estados de navegação */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: 
    opacity var(--duration-normal) var(--ease-out),
    visibility var(--duration-normal);
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Container padrão */
.container {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* Centralização */
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}


/* ===========================================
   5. COMPONENTS
   =========================================== */

/* Botão primário */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 48px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  background: var(--color-text-primary);
  color: var(--color-bg);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: 
    transform var(--duration-instant) var(--ease-out),
    opacity var(--duration-instant);
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.95);
  opacity: 0.8;
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Botão secundário */
.btn-secondary {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-secondary:active {
  background: var(--color-surface);
}

/* Botão ghost (texto apenas) */
.btn-ghost {
  background: none;
  color: var(--color-text-primary);
  padding: 12px 24px;
  border: none;
}

/* Botão circular (ícones) */
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
  border: none;
  font-size: 18px;
  cursor: pointer;
  transition: 
    transform var(--duration-instant) var(--ease-out),
    background var(--duration-fast);
}

.btn-icon:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.2);
}

/* Input */
.input {
  width: 100%;
  padding: 12px 0;
  font-family: inherit;
  font-size: 16px;
  font-weight: 300;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  outline: none;
  transition: border-color var(--duration-fast);
}

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

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


/* ===========================================
   6. CAMERA-SPECIFIC
   =========================================== */

/* Viewfinder — área da câmera */
.camera-viewfinder {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}

.camera-viewfinder video,
.camera-viewfinder canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Espelhar câmera frontal */
.camera-viewfinder video.mirror {
  transform: scaleX(-1);
}

/* Controles da câmera */
.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: var(--spacing-md);
  padding-bottom: calc(var(--spacing-md) + var(--safe-bottom));
  background: var(--color-bg);
}

/* Shutter — botão de captura */
.shutter {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--color-text-primary);
  border: 4px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform var(--duration-instant) var(--ease-out);
  animation: shutter-breathe 3s var(--ease-in-out) infinite;
  position: relative;
}

/* Inner circle for depth */
.shutter::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: var(--radius-full);
  background: var(--color-text-primary);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform var(--duration-instant) var(--ease-out);
}

.shutter:active {
  transform: scale(0.85);
  animation: none;
}

.shutter:active::before {
  transform: scale(0.9);
}

/* Visual feedback on capture */
.shutter.captured {
  transform: scale(0.8);
  animation: none;
}

.shutter.captured::before {
  transform: scale(0.85);
  background: #ddd;
}

/* Shutter "respira" quando pronto */
@keyframes shutter-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Flash de captura */
.capture-flash {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
}

.capture-flash.flash {
  animation: flash var(--duration-instant) var(--ease-out);
}

@keyframes flash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* Preview da foto */
.preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  position: relative;
  overflow: hidden;
  /* Permite scroll vertical, captura horizontal */
  touch-action: pan-y;
  cursor: grab;
}

.preview-container:active {
  cursor: grabbing;
}

.preview-image {
  max-width: 100%;
  max-height: 65vh;
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: scale(0.95);
  transition: 
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
  /* Evita que a imagem capture eventos de touch */
  pointer-events: none;
}

.preview-image.loaded {
  opacity: 1;
  transform: scale(1);
}

/* Nome do filtro — aparece no swipe */
.filter-label {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-primary);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  pointer-events: none;
}

.filter-label.visible {
  opacity: 1;
}

/* Indicador de filtros (barras verticais) */
.filter-indicators {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  padding: var(--spacing-sm);
  height: 32px;
}

.filter-bar {
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: #555;
  transition: 
    background var(--duration-fast),
    height var(--duration-fast) var(--ease-out);
}

.filter-bar.active {
  background: var(--color-text-primary);
  height: 24px;
}


/* ===========================================
   7. ANIMATIONS & FEEDBACK
   =========================================== */

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-text-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: 
    opacity var(--duration-fast),
    visibility var(--duration-fast);
  z-index: 2000;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Success checkmark */
.success-check {
  width: 64px;
  height: 64px;
  margin-bottom: var(--spacing-md);
}

.success-check circle {
  fill: none;
  stroke: var(--color-success);
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: circle-draw 0.6s var(--ease-out) forwards;
}

.success-check path {
  fill: none;
  stroke: var(--color-success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: check-draw 0.3s var(--ease-out) 0.4s forwards;
}

@keyframes circle-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes check-draw {
  to { stroke-dashoffset: 0; }
}

/* Fade in up — para elementos que entram */
.fade-in-up {
  animation: fadeInUp var(--duration-normal) var(--ease-out) forwards;
}

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