/* SugarSlay — components.css
   Piezas reutilizables. Todo con variables de theme.css: ni un color escrito a
   mano, o el día que el admin cambie el dorado quedarán trozos del anterior. */

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 20px;
  border: var(--bw) solid transparent;
  border-radius: var(--radius-pill);
  background: transparent; color: var(--text);
  font-size: .95rem; font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, filter .15s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--accent-grad); color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-outline { border-color: var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost   { border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-plain   { color: var(--muted); }
.btn-plain:hover { color: var(--text); }
.btn-danger  { background: var(--danger); color: #fff; }

.btn-sm  { min-height: 38px; padding: 8px 14px; font-size: .85rem; }
.btn-lg  { min-height: 54px; padding: 15px 28px; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }
.btn-icon { min-height: 44px; width: 44px; padding: 0; border-radius: 50%; }

/* ── Tarjetas ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-gold  { border-color: var(--accent-line); }
.card-head  { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 1.05rem; }

.page-head { margin: 4px 0 18px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p  { color: var(--muted); margin: 0; }

/* ── Campos ──────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.label { display: block; margin-bottom: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 13px 15px;
  background: var(--surface-2);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.textarea { min-height: 110px; resize: vertical; }
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.field-hint  { display: block; margin-top: 6px; font-size: .78rem; color: var(--muted); }
.field-error { display: block; margin-top: 6px; font-size: .8rem; color: var(--danger); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }

.input-group { position: relative; }
.input-group .input { padding-right: 50px; }
.input-affix {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 50%;
}

/* Casilla. El área tocable es la etiqueta entera, no el cuadrito. */
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
.check span { font-size: .92rem; }

/* ── Opciones tocables (mejor que un <select> en celular) ─────────────────── */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 62px; padding: 12px 10px;
  background: var(--surface-2);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center; font-size: .9rem; font-weight: 500;
  transition: border-color .14s ease, background .14s ease, transform .1s ease;
}
.choice:active .choice-box { transform: scale(.97); }
.choice input:checked + .choice-box {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent);
}
[data-theme="dark"] .choice input:checked + .choice-box { color: var(--accent); }
.choice input:focus-visible + .choice-box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fichas: la versión compacta, para listas largas como idiomas o música. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; min-height: 40px;
  border: var(--bw) solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface-2); font-size: .88rem; cursor: pointer;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .chip:has(input:checked) { color: var(--accent); }

/* ── Deslizador ──────────────────────────────────────────────────────────── */
.slider { display: flex; align-items: center; gap: 14px; }
.slider input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; background: var(--border); outline: none;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.35); cursor: pointer;
}
.slider input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); cursor: pointer;
}
.slider-value { min-width: 76px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Distintivos y avisos ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: var(--bw) solid var(--border);
  font-size: .74rem; font-weight: 600; line-height: 1.5;
}
.badge-gold    { background: var(--accent-grad); color: var(--accent-ink); border-color: transparent; }
.badge-success { color: var(--success); border-color: var(--success); }
.badge-warning { color: var(--warning); border-color: var(--warning); }
.badge-danger  { color: var(--danger);  border-color: var(--danger); }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px 16px; margin-bottom: 16px;
  border: var(--bw) solid var(--border); border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: .92rem;
}
.alert-success { border-left-color: var(--success); }
.alert-warning { border-left-color: var(--warning); }
.alert-danger  { border-left-color: var(--danger); }
.alert-info    { border-left-color: var(--info); }

/* ── Avatares ────────────────────────────────────────────────────────────── */
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; background: var(--surface-2);
  border: var(--bw) solid var(--border); flex: none;
}
.avatar-empty {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85em; color: var(--accent); letter-spacing: .5px;
}
.avatar-sm { width: 34px; height: 34px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 96px; height: 96px; }

/* ── Tarjeta de perfil (el corazón del buscador) ─────────────────────────── */
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px)  { .profile-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .profile-grid { grid-template-columns: repeat(4, 1fr); } }

.pcard {
  position: relative; display: block;
  aspect-ratio: 9 / 16;                 /* el mismo encuadre con el que se sube */
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: var(--bw) solid var(--border);
  text-decoration: none; color: #fff;
  isolation: isolate;
}
.pcard:hover { text-decoration: none; }
.pcard img { width: 100%; height: 100%; object-fit: cover; }
.pcard::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 62%;
  background: linear-gradient(to top, rgba(0,0,0,.86), rgba(0,0,0,.35) 45%, transparent);
  pointer-events: none;
}
.pcard-body { position: absolute; left: 12px; right: 12px; bottom: 11px; z-index: 1; }
.pcard-name { font-weight: 600; font-size: 1rem; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.pcard-meta { display: flex; gap: 8px; align-items: center; font-size: .76rem; opacity: .92; }
.pcard-top  { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 1; display: flex; justify-content: space-between; gap: 6px; }
.pcard-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); }

.online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px rgba(0,0,0,.35); flex: none; }

/* ── Fotos del perfil ────────────────────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 700px) { .photo-grid { grid-template-columns: repeat(5, 1fr); } }
.photo-slot {
  position: relative; aspect-ratio: 9 / 16;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: var(--bw) dashed var(--border);
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot.is-filled { border-style: solid; }
.photo-del {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.62); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.photo-main {
  position: absolute; bottom: 6px; left: 6px; z-index: 2;
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--accent-ink); font-size: .66rem; font-weight: 700;
}
.photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 100%; border: 0; background: none; color: var(--muted); font-size: .74rem;
}

/* ── Recortador ──────────────────────────────────────────────────────────── */
.cropper { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.94); display: flex; flex-direction: column; }
.cropper[hidden] { display: none; }
.cropper-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.cropper-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cropper-bar { display: flex; align-items: center; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: #0a0a0a; }
.cropper-bar .slider { flex: 1; }
.cropper-hint { padding: 10px 16px 0; color: #b9b2a4; font-size: .82rem; text-align: center; }

/* ── Estados ─────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .ic { color: var(--accent); opacity: .55; margin: 0 auto 12px; }
.empty h3 { color: var(--text); }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
            background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes sk { to { background-position: -200% 0; } }

.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent-grad); transition: width .3s ease; }

/* ── Pasos del alta ──────────────────────────────────────────────────────── */
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.step-dot { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.step-dot.is-done { background: var(--accent); }
.step-count { font-size: .78rem; color: var(--muted); margin-bottom: 6px; }

/* ── Tabla (panel del admin) ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: var(--bw) solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

/* ── Pestañas ────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 20px;
        border-bottom: var(--bw) solid var(--border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 16px; white-space: nowrap; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: .9rem; font-weight: 500; text-decoration: none;
}
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); text-decoration: none; }

/* ── Avisos flotantes ────────────────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translateX(-50%);
          z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast {
  padding: 13px 17px; border-radius: var(--radius-sm);
  background: var(--surface); border: var(--bw) solid var(--border);
  box-shadow: var(--shadow); font-size: .9rem;
  animation: toast-in .22s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-danger  { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ── Hoja inferior (en celular los diálogos salen de abajo) ───────────────── */
.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-veil { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet-box {
  position: relative; width: 100%; max-width: 520px;
  max-height: 88dvh; overflow-y: auto;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: var(--bw) solid var(--border); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: sheet-up .24s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-box { border-radius: var(--radius-lg); border-bottom: var(--bw) solid var(--border); animation: none; }
}
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: -6px auto 14px; }
.sheet-title { margin-bottom: 12px; }
