/* ============================================================
   Gastillo — Componentes: cards, botones, inputs, nav, modales,
   semáforo, toast, badges, FAB, avatares, progress ring.
   ============================================================ */

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: var(--s-5);
}
.card-flat { box-shadow: none; }
.card-tight { padding: var(--s-4); }

/* ---------- Hero (gradiente de marca) ---------- */
.hero {
  background: var(--brand-gradient);
  color: #fff;
  border-radius: var(--r-xl);
  padding: var(--s-6);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero .hero-amount {
  font-size: clamp(40px, 12vw, 56px);
  font-weight: 700;
  line-height: 1;
}
.hero .glass {
  background: rgba(255,255,255,.16);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 16px;
  border: 1px solid transparent;
  transition: transform var(--t-fast), background var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-strong); text-decoration: none; }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; text-decoration: none; }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-lg { padding: 16px 24px; font-size: 18px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: var(--s-5);
  bottom: calc(var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom));
  width: 60px; height: 60px;
  border-radius: var(--r-full);
  background: var(--brand-gradient);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-fab);
  transition: transform var(--t-fast);
}
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field > label { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.textarea { resize: vertical; min-height: 80px; }
.input-error { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 13px; }

/* Input con sufijo de divisa */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .suffix {
  position: absolute; right: 14px; font-weight: 600; color: var(--text-muted);
  pointer-events: none;
}

/* ---------- Semáforo ---------- */
.semaphore {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-full);
  font-weight: 600; font-size: 14px;
}
.semaphore .dot { width: 12px; height: 12px; border-radius: var(--r-full); }
.semaphore.green { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.semaphore.green .dot { background: var(--success); }
.semaphore.amber { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.semaphore.amber .dot { background: var(--warning); }
.semaphore.red { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.semaphore.red .dot { background: var(--danger); }
/* Variante sobre hero (fondo gradiente) */
.semaphore.on-hero { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text-muted);
}
.badge-pending { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; font-weight: 500;
  transition: all var(--t-fast);
}
.chip.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

/* ---------- Avatar ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: var(--r-full);
  background: var(--brand-gradient); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }

/* ---------- Progress ring ---------- */
.ring { transform: rotate(-90deg); }
.ring .ring-track { stroke: rgba(255,255,255,.25); fill: none; }
.ring .ring-fill { stroke: #fff; fill: none; stroke-linecap: round; transition: stroke-dashoffset var(--t-med); }

/* Mini barra (category breakdown) */
.bar-track { background: var(--surface-2); border-radius: var(--r-full); height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: var(--primary); transition: width var(--t-med); }

/* ---------- List item ---------- */
.list-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.list-item:hover { background: var(--surface-2); }
.list-item .icon-circle {
  width: 40px; height: 40px; border-radius: var(--r-full);
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2);
}

/* ---------- Nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface-translucent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; z-index: var(--z-nav);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; font-weight: 500; color: var(--text-muted);
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav svg { width: 24px; height: 24px; }

.app-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4);
}

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--text);
  transition: background var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(0,0,0,.45);
  display: grid; place-items: end center;
  padding: 0;
  animation: fade-in var(--t-fast);
}
.modal {
  background: var(--surface);
  width: 100%; max-width: var(--content-max);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-5);
  padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: slide-up var(--t-med);
  max-height: 90dvh; overflow-y: auto;
}
@media (min-width: 480px) {
  .modal-backdrop { place-items: center; padding: var(--s-4); }
  .modal { border-radius: var(--r-xl); }
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-4); pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  max-width: var(--content-max); pointer-events: auto;
  animation: slide-up var(--t-fast);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Spinner ---------- */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: var(--s-8) var(--s-5);
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 48px; margin-bottom: var(--s-3); }
