/* ══════════════════════════════════════════════
   FotoGestión — Design System
   Level: Apple / Linear / Vercel
   ══════════════════════════════════════════════ */

:root {
  --bg-base: #0a0a0a;
  --bg-surface: #111111;
  --bg-elevated: #171717;
  --bg-input: #0f0f0f;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.1);
  --text-primary: #f5f5f5;
  --text-secondary: #a1a1a1;
  --text-tertiary: #555555;
  --emerald: #10b981;
  --emerald-light: #34d399;
  --emerald-dim: rgba(16,185,129,0.15);
  --blue: #6366f1;
  --blue-dim: rgba(99,102,241,0.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245,158,11,0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset & Base ── */
* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Smooth transitions on all interactive elements ── */
button, a, input, select, textarea {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--emerald) !important;
  box-shadow: 0 0 0 3px var(--emerald-dim);
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ══════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(6px); }
}
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes ripple-ring {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes checkmark-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
@keyframes border-rotate {
  to { --border-angle: 360deg; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}
@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ── Animation Utilities ── */
.anim-fadeIn { animation: fadeIn 0.3s ease both; }
.anim-fadeInUp { animation: fadeInUp 0.4s ease both; }
.anim-slideUp { animation: slideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.anim-scaleIn { animation: scaleIn 0.3s ease both; }
.anim-shake { animation: shake 0.5s ease; }
.anim-pulse { animation: pulse-soft 2s ease-in-out infinite; }
.anim-spin { animation: spin 1s linear infinite; }
.anim-float { animation: float 3s ease-in-out infinite; }

/* Staggered entrance — set --i via style="--i:0" etc. */
.stagger {
  opacity: 0;
  animation: fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* ══════════════════════════════════════════════
   GLASS & SURFACE EFFECTS
   ══════════════════════════════════════════════ */

.glass {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.glass-hover:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.surface {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ── Glow Effects ── */
.glow-emerald {
  box-shadow: 0 0 24px rgba(16,185,129,0.15), 0 0 80px rgba(16,185,129,0.06);
}
.glow-blue {
  box-shadow: 0 0 24px rgba(99,102,241,0.15), 0 0 80px rgba(99,102,241,0.06);
}
.glow-red {
  box-shadow: 0 0 24px rgba(239,68,68,0.18), 0 0 80px rgba(239,68,68,0.06);
}
.glow-amber {
  box-shadow: 0 0 24px rgba(245,158,11,0.15), 0 0 80px rgba(245,158,11,0.06);
}

/* ══════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════ */

#toast-container {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}
.toast {
  pointer-events: auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.toast-exit {
  animation: toast-out 0.2s ease both;
}
.toast-success {
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.2);
  color: #34d399;
}
.toast-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.2);
  color: #f87171;
}
.toast-info {
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  color: #a5b4fc;
}
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* ══════════════════════════════════════════════
   TAB BAR (iOS-style bottom nav)
   ══════════════════════════════════════════════ */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  z-index: 100;
}
.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 6px;
  color: #555;
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}
.tab-bar-item:hover, .tab-bar-item:active {
  color: #888;
}
.tab-bar-item.active {
  color: var(--emerald);
}
.tab-bar-item svg {
  width: 22px;
  height: 22px;
}
.tab-bar-spacer {
  height: calc(76px + var(--safe-bottom));
}

/* ══════════════════════════════════════════════
   RECORDING / VOICE
   ══════════════════════════════════════════════ */

.record-btn {
  position: relative;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.3s;
}
.record-btn:active {
  transform: scale(0.95);
}
.record-btn.is-recording {
  transform: scale(1.05);
}

/* Pulsing rings during recording */
.record-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--red);
  opacity: 0;
}
.is-recording .record-ring {
  animation: ripple-ring 1.5s ease-out infinite;
}
.is-recording .record-ring:nth-child(2) {
  animation-delay: 0.5s;
}
.is-recording .record-ring:nth-child(3) {
  animation-delay: 1s;
}

/* Audio wave bars */
.wave-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
}
.wave-bar {
  width: 3px;
  border-radius: 1.5px;
  background: currentColor;
  transform-origin: center;
}
.is-recording .wave-bar {
  animation: wave 0.8s ease-in-out infinite;
}
.wave-bar:nth-child(1) { height: 12px; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 28px; animation-delay: 0.15s; }
.wave-bar:nth-child(4) { height: 36px; animation-delay: 0.2s; }
.wave-bar:nth-child(5) { height: 28px; animation-delay: 0.25s; }
.wave-bar:nth-child(6) { height: 20px; animation-delay: 0.3s; }
.wave-bar:nth-child(7) { height: 12px; animation-delay: 0.35s; }

/* ══════════════════════════════════════════════
   PROCESSING / PROGRESS
   ══════════════════════════════════════════════ */

.progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--emerald), var(--emerald-light));
  transition: width 0.5s ease;
}
.progress-indeterminate .progress-bar-fill {
  width: 30%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* AI Sparkle spinner */
.ai-spinner {
  width: 48px;
  height: 48px;
  animation: spin 3s linear infinite;
}
.ai-spinner path {
  fill: var(--emerald);
}

/* ══════════════════════════════════════════════
   CONFIDENCE INDICATORS
   ══════════════════════════════════════════════ */

.confidence-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}
.confidence-high { background: var(--emerald); }
.confidence-med  { background: var(--amber); }
.confidence-low  { background: var(--red); }

.field-warning {
  background: var(--amber-dim);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-md);
}

/* ══════════════════════════════════════════════
   DROP ZONE
   ══════════════════════════════════════════════ */

.drop-zone {
  border: 2px dashed rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  transition: border-color 0.3s, background 0.3s;
}
.drop-zone:hover, .drop-zone.active {
  border-color: rgba(99,102,241,0.3);
  background: rgba(99,102,241,0.04);
}

/* ══════════════════════════════════════════════
   PIN KEYPAD
   ══════════════════════════════════════════════ */

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pin-dot.filled {
  background: var(--emerald);
  border-color: var(--emerald);
  transform: scale(1.15);
}

.keypad-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}
.keypad-btn:hover {
  background: rgba(255,255,255,0.06);
}
.keypad-btn:active {
  background: rgba(255,255,255,0.1);
  transform: scale(0.93);
}

/* ══════════════════════════════════════════════
   SUCCESS OVERLAY
   ══════════════════════════════════════════════ */

.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.success-checkmark {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(16,185,129,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.success-checkmark svg {
  width: 40px;
  height: 40px;
  stroke: var(--emerald);
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
  animation: checkmark-draw 0.4s ease 0.2s forwards;
}

/* ══════════════════════════════════════════════
   MISC
   ══════════════════════════════════════════════ */

/* Gradient text */
.text-gradient-emerald {
  background: linear-gradient(135deg, #10b981, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Hide scrollbar for horizontal scroll */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* iOS-safe form inputs */
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  font-size: 16px; /* Prevents zoom on iOS */
}

/* Prevent overscroll bounce */
.page-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
