/* Vestuario web de Brasa: tema oscuro cálido (brasa) */
:root {
  --bg: #15100d;
  --surface: #211915;
  --surface-2: #2b211b;
  --surface-3: #352920;
  --line: #3d2f26;
  --text: #f7efe9;
  --muted: #bba99b;
  --faint: #8c7b6f;
  --accent: #ff7a3d;
  --accent-2: #ffb054;
  --accent-ink: #200f05;
  --ok: #52d38d;
  --warn: #ffc15a;
  --bad: #ff6767;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(255, 122, 61, 0.14), transparent 62%),
    radial-gradient(900px 480px at 108% -4%, rgba(255, 176, 84, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
.muted { color: var(--muted); }
.note { color: var(--faint); font-size: 13px; }
.hint { color: var(--muted); margin: 4px 2px 14px; font-size: 14px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.noscript { padding: 24px; text-align: center; }

.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; fill: currentColor; }

/* ----- Carga ----- */
.splash { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Entrada ----- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  text-align: center;
}
.gate-card h1 { font-size: 24px; }
.gate-logo {
  width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 10px 30px rgba(255, 122, 61, 0.35);
}
.gate-logo .icon { width: 36px; height: 36px; }
.gate-owner { text-align: left; margin-top: 6px; }
.gate-owner summary { cursor: pointer; color: var(--muted); font-size: 14px; text-align: center; list-style: none; }
.gate-owner summary::-webkit-details-marker { display: none; }
.gate-owner summary:hover { color: var(--text); }
.gate-form { display: flex; gap: 8px; margin-top: 12px; }
.gate-form .input { flex: 1; }
.form-error { color: var(--bad); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }

/* ----- Botones y campos ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 9px 18px; font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 6px 14px; font-size: 14px; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.secondary { background: var(--surface-3); border-color: var(--line); }
.btn.secondary:hover:not(:disabled) { background: #40322a; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: #56443a; }
.btn.danger { background: var(--bad); color: #2a0606; }
.btn.danger-text { color: var(--bad); }
.btn.busy:disabled { opacity: 0.85; }
.btn .icon { width: 18px; height: 18px; }

.dot-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 61, 0.22); }
.input.small { padding: 6px 8px; font-size: 14px; width: auto; }
select.input { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ----- Cabecera ----- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  background: rgba(21, 16, 13, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(61, 47, 38, 0.7);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
}
.brand-logo .icon { width: 26px; height: 26px; }
.brand-text { min-width: 0; }
.title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(82, 211, 141, 0.18); }
.dot.paused { background: var(--warn); }
.who { display: flex; align-items: center; gap: 10px; flex: none; }
.who-name { color: var(--muted); font-size: 14px; }

/* ----- Avisos ----- */
.banners { display: grid; gap: 8px; padding: 12px 16px 0; max-width: 1240px; margin: 0 auto; }
.banners:empty { display: none; }
.banner {
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.banner.warn { border-color: rgba(255, 193, 90, 0.4); background: rgba(255, 193, 90, 0.08); color: #ffe0a8; }

/* ----- Pestañas ----- */
.tabs {
  display: flex; gap: 6px; padding: 14px 16px 4px;
  max-width: 1240px; margin: 0 auto;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface); }
.tab.active { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.tab.active .icon { color: var(--accent); }

/* ----- Contenido ----- */
.view { max-width: 1240px; margin: 0 auto; padding: 12px 16px 40px; }

.toolbar { display: grid; gap: 12px; margin-bottom: 16px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 14px; max-width: 460px;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box .icon { color: var(--faint); width: 18px; height: 18px; }
.search-box .input { border: 0; background: transparent; padding: 10px 0; box-shadow: none; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 14px;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-count {
  font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.chip.active .chip-count { background: rgba(0, 0, 0, 0.12); }

/* Rejilla de tarjetas */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: #574436; box-shadow: var(--shadow); }
.card.worn { border-color: rgba(255, 122, 61, 0.65); box-shadow: 0 0 0 1px rgba(255, 122, 61, 0.35); }
.card-img { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--surface-3); }
.placeholder .icon { width: 46%; height: 46%; color: #4a3a2f; }
.badge {
  position: absolute; top: 8px; left: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px 3px 6px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
}
.badge .icon { width: 14px; height: 14px; }
.badge.star { left: auto; right: 8px; padding: 4px; background: rgba(21, 16, 13, 0.75); color: var(--accent-2); }
.card-body { padding: 10px 12px 4px; flex: 1; }
.card-title {
  font-size: 14px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub { color: var(--faint); font-size: 12px; margin-top: 3px; }
.card-actions { padding: 8px 12px 12px; }
.card-actions .btn { width: 100%; }

.empty { text-align: center; padding: 56px 20px; display: grid; gap: 8px; justify-items: center; grid-column: 1 / -1; }
.empty .icon { width: 54px; height: 54px; color: #4a3a2f; }
.empty h2 { font-size: 18px; }
.empty p { max-width: 420px; }

/* Listas */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { color: var(--faint); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.history .row-title { font-weight: 400; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700;
  background: var(--surface-3); color: var(--accent-2);
}
.tag {
  flex: none; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
}
.tag.done { background: rgba(82, 211, 141, 0.14); color: var(--ok); }
.tag.failed { background: rgba(255, 103, 103, 0.14); color: var(--bad); }
.tag.pending, .tag.sent { background: rgba(255, 193, 90, 0.14); color: var(--warn); }
.live { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--ok); }
.pad { padding: 14px 4px; }

.zones { display: grid; gap: 22px; }
.zone-title { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); margin: 0 2px 10px; }

/* Acceso */
.panels { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: grid; gap: 12px; align-content: start;
}
.panel.wide { grid-column: 1 / -1; }
.panel h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.panel h2 .icon { color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-form { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.invite-form .input:first-child { grid-column: 1 / -1; }
.invite-form .btn { grid-column: 1 / -1; justify-self: start; }
.people .row { background: var(--surface-2); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 44px; height: 26px; border-radius: 999px; flex: none; position: relative;
  background: var(--surface-3); border: 1px solid var(--line); transition: background 0.15s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s ease, background 0.15s ease;
}
.switch-input:checked + .switch-track { background: rgba(255, 122, 61, 0.35); border-color: var(--accent); }
.switch-input:checked + .switch-track::after { transform: translateX(18px); background: var(--accent-2); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ----- Diálogos ----- */
.modal {
  border: 1px solid var(--line); border-radius: 20px; padding: 0;
  background: var(--surface); color: var(--text);
  width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(8, 5, 3, 0.66); backdrop-filter: blur(3px); }
.modal-body { padding: 22px; display: grid; gap: 14px; }
.modal-body h2 { font-size: 18px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ----- Avisos flotantes ----- */
.toasts {
  position: fixed; z-index: 50; right: 16px; bottom: 16px;
  display: grid; gap: 8px; width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--surface-3); border: 1px solid var(--line); border-left: 4px solid var(--accent-2);
  border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px;
  animation: toast-in 0.2s ease;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast.leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ----- Móvil: pestañas abajo ----- */
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .who-name { display: none; }
  .title { font-size: 16px; }
  .tabs {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom);
    background: rgba(28, 21, 17, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    gap: 0; max-width: none;
  }
  .tab {
    flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; border-radius: 12px;
    font-size: 11px; border: 0;
  }
  .tab.active { background: transparent; border: 0; }
  .tab .icon { width: 22px; height: 22px; }
  .view { padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .chips { scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .toasts { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); }
  .invite-form { grid-template-columns: 1fr; }
  .row.person { flex-wrap: wrap; }
  .row.person .row-actions { width: 100%; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
