/* Componentes reutilizables. */

/* ---------- Cabecera ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
}
.app-header.is-scrolled { border-bottom-color: var(--border); }
.app-header__inner {
  height: 100%; max-width: 560px; margin: 0 auto;
  padding: 0 var(--sp-4);
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
}
.app-header__inner--brand { grid-template-columns: 1fr auto; }
.app-header__title { text-align: center; font-size: var(--fs-lg); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: var(--sp-2); text-decoration: none; color: var(--green-900); font-weight: 800; font-size: var(--fs-lg); }
.brand svg { width: 28px; height: 28px; }
@media (min-width: 768px) { .app-header__inner { max-width: 720px; padding: 0 var(--sp-6); } }
@media (min-width: 1024px) { .app-header__inner { max-width: 880px; } }

.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%; cursor: pointer; color: var(--text);
  text-decoration: none;
}
.icon-btn:hover { background: rgba(20, 83, 45, .07); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Navegación inferior / lateral ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--accent); }
.bottom-nav .brand { display: none; }

@media (min-width: 1024px) {
  .bottom-nav {
    position: sticky; top: 0; height: 100dvh; width: 232px; flex-shrink: 0;
    display: flex; flex-direction: column; gap: var(--sp-1);
    padding: var(--sp-5) var(--sp-3);
    border-top: 0; border-right: 1px solid var(--border);
  }
  .bottom-nav .brand {
    display: flex; flex-direction: row; justify-content: flex-start; gap: var(--sp-2);
    padding: 0 var(--sp-3) var(--sp-5); color: var(--green-900); font-size: var(--fs-lg); font-weight: 800;
  }
  .bottom-nav a:not(.brand) {
    flex-direction: row; justify-content: flex-start; gap: var(--sp-3);
    padding: var(--sp-3); border-radius: var(--radius-sm); font-size: var(--fs-sm);
  }
  .bottom-nav a:not(.brand):hover { background: var(--green-50); }
  .bottom-nav a[aria-current="page"] { background: var(--red-50); }
  .has-sidenav .app-header .brand-slot { visibility: hidden; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 48px; padding: 0 var(--sp-5);
  border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 700; font-size: var(--fs-md); text-decoration: none; cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: var(--white); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--surface-alt); border-color: #DCCFB8; }
.btn--soft { background: var(--green-100); color: var(--green-900); border-color: #CBE5D3; }
.btn--soft:hover { background: #D5EADB; }
.btn--danger { background: var(--surface); color: var(--red-600); border-color: #F3C4C4; }
.btn--danger:hover { background: var(--red-50); }
.btn--sm { min-height: 38px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.divider-text { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-muted); font-size: var(--fs-sm); }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-4); box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; overflow: hidden; }
.card__title { font-size: var(--fs-lg); font-weight: 700; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.section-title h2 { font-size: var(--fs-lg); font-weight: 700; }

.group-card {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.group-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.group-card--active { border-color: var(--red-600); border-width: 1.5px; }
.group-card__icon { width: 48px; height: 48px; flex-shrink: 0; }
.group-card__name { font-weight: 700; }
.group-card__meta { font-size: var(--fs-sm); color: var(--text-muted); }
.chev { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border);
  text-decoration: none; color: inherit;
}
.list li:first-child .list-row { border-top: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-alt); }
button.list-row { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: transparent; text-align: left; cursor: pointer; }

/* ---------- Insignias ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
.badge--pendiente  { background: var(--st-pendiente-bg);  color: var(--st-pendiente-fg); }
.badge--activo     { background: var(--st-activo-bg);     color: var(--st-activo-fg); }
.badge--sorteado   { background: var(--st-sorteado-bg);   color: var(--st-sorteado-fg); }
.badge--finalizado { background: var(--st-finalizado-bg); color: var(--st-finalizado-fg); }
.badge--admin      { background: var(--green-100); color: var(--green-900); }
.badge--ok         { background: var(--green-100); color: var(--green-900); }
.badge--warn       { background: var(--gold-100);  color: #7A5A16; }

/* ---------- Avatar ---------- */
.avatar {
  --c: var(--green-700);
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--c); color: var(--white);
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .02em;
}
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar--xl { width: 84px; height: 84px; font-size: var(--fs-2xl); }
.avatar-btn { border: 0; padding: 0; cursor: pointer; background: none; border-radius: 50%; }
.avatar-btn .avatar { --c: #B23A3A; width: 38px; height: 38px; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: var(--fs-sm); font-weight: 600; }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(22, 128, 74, .18);
}
.input[aria-invalid="true"] { border-color: var(--red-600); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: var(--sp-4); top: 50%; transform: translateY(-50%); color: var(--text-muted); font-weight: 600; }
.input-prefix .input { padding-left: 44px; }
.hint { font-size: var(--fs-xs); color: var(--text-muted); }
.error { font-size: var(--fs-xs); color: var(--red-600); font-weight: 600; }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--sp-3); }
.check { display: flex; align-items: flex-start; gap: var(--sp-3); font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green-700); margin-top: 1px; }


/* ---------- Avisos ---------- */
.notice {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); border-radius: var(--radius); font-size: var(--fs-sm);
}
.notice svg { width: 22px; height: 22px; flex-shrink: 0; }
.notice--green { background: var(--green-100); color: var(--green-900); }
.notice--red   { background: var(--red-100);   color: #7F1D1D; }
.notice--gold  { background: var(--gold-100);  color: #6B4E12; }
.notice--blue  { background: var(--blue-50);   color: var(--blue-700); }

.demo-flag {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px var(--sp-3); border-radius: var(--radius-sm);
  background: var(--gold-100); color: #6B4E12; font-size: var(--fs-xs); font-weight: 600;
}
.demo-flag svg { width: 16px; height: 16px; }

/* ---------- Pestañas ---------- */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--sp-2); padding: 4px; background: var(--cream-200); border-radius: var(--radius); }
.tabs a {
  text-align: center; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  font-weight: 700; text-decoration: none; color: var(--text-muted);
}
.tabs a[aria-current="page"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ---------- Estadísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--sp-3) var(--sp-2); text-align: center; font-size: var(--fs-xs); color: var(--text-muted); }
.stat + .stat { border-left: 1px solid var(--border); }
.stat svg { width: 22px; height: 22px; color: var(--green-900); }
.stat strong { color: var(--text); font-size: var(--fs-sm); }

/* ---------- Pasos / checklist ---------- */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.checklist li { display: flex; gap: var(--sp-3); align-items: flex-start; }
.checklist svg { width: 22px; height: 22px; flex-shrink: 0; color: var(--green-700); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 30, 20, .45);
  display: grid; place-items: end center; padding: var(--sp-4);
  animation: fadeIn .2s var(--ease);
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface);
  border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow-lg);
  animation: sheetIn .25s var(--ease);
}
@media (min-width: 640px) { .modal-backdrop { place-items: center; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(20px); opacity: 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sp-4)); z-index: 60;
  transform: translateX(-50%);
  background: var(--green-900); color: var(--white);
  padding: var(--sp-3) var(--sp-5); border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-lg);
  animation: sheetIn .25s var(--ease);
  max-width: calc(100% - 32px);
}
