/* ============================================================
   TERRALAGOS QR - ESTILOS
   Mobile-first, optimizado para escaneo QR desde celular.
   ============================================================ */

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

:root {
  --color-primary: #1e3a5f;
  --color-primary-light: #2d5a8e;
  --color-primary-lighter: #e8f0fe;
  --color-accent: #3b82f6;
  --color-accent-dark: #2563eb;

  --color-success: #059669;
  --color-success-light: #d1fae5;
  --color-error: #dc2626;
  --color-error-light: #fef2f2;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-security: #7c3aed;
  --color-security-light: #ede9fe;
  --color-whatsapp: #25d366;
  --color-whatsapp-dark: #1ebe5d;
  --color-animal: #ea580c;
  --color-animal-light: #fff7ed;
  --color-animal-border: #fed7aa;
  --color-canil: #7c3aed;
  --color-canil-light: #f5f3ff;
  --color-canil-border: #ddd6fe;
  --color-object: #2563eb;
  --color-object-light: #eff6ff;
  --color-object-border: #bfdbfe;
  --color-guard: #0891b2;
  --color-guard-light: #ecfeff;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-page: #f1f5f9;
  --bg-hover: #f1f5f9;

  --border-color: #e2e8f0;
  --border-radius: 14px;
  --border-radius-sm: 10px;
  --border-radius-lg: 20px;
  --border-radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px -12px rgba(0,0,0,0.12);

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  height: 100%;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ────────────────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  background: var(--bg-primary);
}

.screen.active {
  display: flex;
  animation: screenIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.screen-content {
  flex: 1;
  padding: 28px 24px 44px;
  display: flex;
  flex-direction: column;
}

.screen-content.center {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 28px;
}

/* ── Typography ────────────────────────────────────────────── */
h2 {
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 8px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

p {
  font-size: 0.938rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

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

.footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: auto;
  padding-top: 24px;
}

/* ── Brand Header ──────────────────────────────────────────── */
.brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.brand-logo-loading {
  width: 80px;
  height: 80px;
  background: var(--color-primary);
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  margin-bottom: 32px;
  box-shadow: var(--shadow-lg);
}

/* ── GPS Status ────────────────────────────────────────────── */
.gps-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  width: fit-content;
  transition: all 0.3s ease;
}

.gps-status.active {
  background: var(--color-success-light);
  border-color: #a7f3d0;
  color: var(--color-success);
}

.gps-status.error {
  background: var(--color-error-light);
  border-color: #fecaca;
  color: var(--color-error);
}

.gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: gpsPulse 2s ease-in-out infinite;
}

.gps-status.active .gps-dot {
  background: var(--color-success);
  animation: none;
}

.gps-status.error .gps-dot {
  background: var(--color-error);
  animation: none;
}

@keyframes gpsPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 28px;
}

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

/* ── Icon Circles ──────────────────────────────────────────── */
.icon-circle {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.icon-circle.success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.icon-circle.error {
  background: var(--color-error-light);
  color: var(--color-error);
}

.icon-circle.guard {
  background: var(--color-guard-light);
  color: var(--color-guard);
}

/* Success animation */
.success-animation .icon-circle {
  animation: successPop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes successPop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Header Badges ─────────────────────────────────────────── */
.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: var(--border-radius-full);
  font-size: 0.813rem;
  font-weight: 600;
  margin-bottom: 20px;
  width: fit-content;
  letter-spacing: 0.01em;
}

.header-badge.animal {
  background: var(--color-animal-light);
  color: var(--color-animal);
  border: 1px solid var(--color-animal-border);
}

.header-badge.object {
  background: var(--color-object-light);
  color: var(--color-object);
  border: 1px solid var(--color-object-border);
}

.header-badge.inside {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid #a7f3d0;
}

.header-badge.outside {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid #fde68a;
}

/* ── Item Preview Card ─────────────────────────────────────── */
.item-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.item-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.item-icon .item-icon-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.item-icon.animal {
  background: var(--color-animal-light);
  color: var(--color-animal);
  border: 1px solid var(--color-animal-border);
}

.item-icon.object {
  background: var(--color-object-light);
  color: var(--color-object);
  border: 1px solid var(--color-object-border);
}

.item-details h3 {
  margin-bottom: 4px;
}

.item-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.5;
}

.item-lot {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0;
  font-weight: 500;
}

/* ── Location Buttons ──────────────────────────────────────── */
.location-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.btn-location {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.btn-location:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.btn-location:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-xs);
}

.btn-location .btn-icon {
  width: 52px;
  height: 52px;
  min-width: 52px;
  background: var(--color-primary-lighter);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  transition: all 0.2s ease;
}

.btn-location .btn-icon.outside {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.btn-location:hover .btn-icon {
  background: var(--color-primary);
  color: var(--text-inverse);
}

.btn-location:hover .btn-icon.outside {
  background: var(--color-warning);
  color: var(--text-inverse);
}

.btn-text-group {
  display: flex;
  flex-direction: column;
}

.btn-location .btn-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-location .btn-desc {
  font-size: 0.813rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── General Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 24px;
  border-radius: var(--border-radius-sm);
  font-size: 0.938rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: var(--font-family);
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-light);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: #cbd5e1;
}

.btn-whatsapp {
  background: var(--color-whatsapp);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-whatsapp:hover {
  background: var(--color-whatsapp-dark);
  box-shadow: var(--shadow-md);
}

/* Button loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.85;
}

.btn.loading::after {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 4px;
}

/* ── Back Button ───────────────────────────────────────────── */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 20px;
  font-family: var(--font-family);
  transition: color 0.2s ease;
}

.btn-back:hover {
  color: var(--text-primary);
}

/* ── Security Alert ────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 24px;
  animation: alertIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes alertIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-security {
  background: var(--color-security-light);
  border: 1px solid #c4b5fd;
}

.alert-security .alert-icon {
  color: var(--color-security);
  min-width: 24px;
  padding-top: 1px;
}

.alert-text strong {
  font-size: 0.875rem;
  color: var(--color-security);
  display: block;
}

.alert-text p {
  font-size: 0.813rem;
  color: #6d28d9;
  margin-bottom: 0;
  margin-top: 4px;
  line-height: 1.5;
}

/* ── Action Cards ──────────────────────────────────────────── */
.action-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 18px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(59, 130, 246, 0.06);
}

.action-card:active {
  transform: scale(0.98);
}

.action-icon {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-icon.notify {
  background: var(--color-object-light);
  color: var(--color-object);
  border: 1px solid var(--color-object-border);
}

.action-icon.guard {
  background: var(--color-guard-light);
  color: var(--color-guard);
  border: 1px solid #a5f3fc;
}

.action-icon.canil {
  background: var(--color-canil-light);
  color: var(--color-canil);
  border: 1px solid var(--color-canil-border);
}

.action-text {
  flex: 1;
}

.action-text h3 {
  margin-bottom: 4px;
}

.action-text p {
  font-size: 0.813rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.4;
}

.action-arrow {
  color: var(--text-muted);
  min-width: 20px;
  transition: transform 0.2s ease;
}

.action-card:hover .action-arrow {
  transform: translateX(3px);
  color: var(--color-accent);
}

.action-card-back {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  opacity: 0.8;
}

.action-card-back h3 {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.action-icon.back {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.item-subdescription {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-style: italic;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: all 0.2s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

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

/* Textarea específico */
.textarea-field {
  resize: vertical;
  min-height: 80px;
  max-height: 200px;
  line-height: 1.5;
}

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* ── Checkbox ──────────────────────────────────────────────── */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent);
  cursor: pointer;
  border-radius: 4px;
}

/* ── Divider ───────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.divider span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ── Guard Info ────────────────────────────────────────────── */
.guard-info {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 20px;
  margin: 24px 0;
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.guard-info p {
  margin-bottom: 4px;
}

.guard-info p:last-child {
  margin-bottom: 0;
}

/* ── Success Summary ───────────────────────────────────────── */
.success-summary {
  width: 100%;
  max-width: 320px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  padding: 4px 18px;
  margin-top: 28px;
  border: 1px solid var(--border-color);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-label {
  font-size: 0.813rem;
  color: var(--text-muted);
}

.summary-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (min-width: 481px) {
  body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 20px;
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
  }

  #app {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    min-height: auto;
  }

  .screen {
    min-height: 640px;
  }
}

/* ── GPS Capture Screen ────────────────────────────────────── */
.gps-capture-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--color-primary-lighter);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  animation: gpsScan 2s ease-in-out infinite;
}

.gps-capture-icon.error {
  background: var(--color-error-light);
  color: var(--color-error);
  animation: none;
}

@keyframes gpsScan {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 58, 95, 0.15); }
  50% { box-shadow: 0 0 0 20px rgba(30, 58, 95, 0); }
}

/* Opción: enviar descripción en lugar de ubicación (usuario rechazó GPS) */
.gps-fallback {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  width: 100%;
  max-width: 320px;
}
.gps-fallback-label {
  display: block;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.gps-fallback-input {
  width: 100%;
  margin-bottom: 12px;
}
.gps-fallback-btn {
  width: 100%;
}

/* ── Safe area (iPhone notch) ──────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .screen-content {
    padding-top: calc(28px + env(safe-area-inset-top));
    padding-bottom: calc(44px + env(safe-area-inset-bottom));
  }
}
