/* ══════════════════════════════════════════
   CriolloApp — Base Styles
   Reset, app shell, common components
   ══════════════════════════════════════════ */

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }
img { max-width: 100%; display: block; }

/* ── App Shell ── */
.app {
  max-width: var(--content-max);
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  padding-top: var(--safe-top);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-header);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--amber);
  letter-spacing: 0.5px;
}
.topbar-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: -2px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text-muted);
  border: none;
  font-size: 1rem;
  transition: color var(--duration) var(--ease);
  position: relative;
}
.topbar-btn:hover { color: var(--amber); }
.topbar-btn svg { width: 20px; height: 20px; }
.topbar-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: var(--red);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg2);
}

/* ── Main Content ── */
.main {
  flex: 1;
  padding: 16px;
  padding-bottom: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ── Bottom Nav ── */
.nav {
  width: 100%;
  max-width: var(--content-max);
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + var(--safe-bottom));
  z-index: var(--z-header);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 0.63rem;
  font-weight: 500;
  background: none;
  border: none;
  transition: color var(--duration) var(--ease);
  text-decoration: none;
}
.nav-item:hover { color: var(--amber); text-decoration: none; }
.nav-item.active { color: var(--amber); }
.nav-item svg { width: 22px; height: 22px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Section Title ── */
.section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
}
.badge-m { background: var(--male-dim); color: var(--male); }
.badge-f { background: var(--female-dim); color: var(--female); }
.badge-ok { background: var(--green-dim); color: var(--green); }
.badge-warn { background: var(--yellow-dim); color: var(--yellow); }
.badge-alert { background: var(--red-dim); color: var(--red); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  transition: all var(--duration) var(--ease);
}
.btn-primary {
  background: var(--amber);
  color: var(--amber-text);
  width: 100%;
}
.btn-primary:hover { background: var(--amber-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--amber); color: var(--amber); }

/* ── Form ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--duration) var(--ease);
}
.form-input:focus { border-color: var(--amber); }
.form-input::placeholder { color: var(--text-dim); }
select.form-input { -webkit-appearance: none; appearance: none; }

/* ── Alert Cards ── */
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.alert-card.is-red { background: var(--red-dim); border-left: 3px solid var(--red); }
.alert-card.is-yellow { background: var(--yellow-dim); border-left: 3px solid var(--yellow); }
.alert-card.is-green { background: var(--green-dim); border-left: 3px solid var(--green); }
.alert-icon { flex-shrink: 0; width: 20px; height: 20px; }
.alert-text { flex: 1; min-width: 0; }
.alert-title { font-size: 0.85rem; font-weight: 600; }
.alert-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Animal Cards ── */
.animal-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
  text-decoration: none;
  color: var(--text);
}
.animal-card:hover { border-color: var(--amber); text-decoration: none; }
.animal-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--amber-dim);
  display: flex; align-items: center; justify-content: center;
  color: var(--amber);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.animal-info { flex: 1; min-width: 0; }
.animal-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.animal-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.animal-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.animal-chevron { color: var(--text-dim); flex-shrink: 0; font-size: 1.2rem; }

/* ── Toast ── */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.85rem;
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease);
  max-width: calc(var(--content-max) - 32px);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.info { border-color: var(--blue); color: var(--blue); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.4; }
.empty-state p { font-size: 0.85rem; }

/* ── Loading ── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-amber { color: var(--amber); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
