:root {
  /* Ancho del contenedor general. En mobile es el "celular"; en desktop pasa
     a ser casi todo el monitor (ver el media query de abajo). */
  --shell-width: 430px;
  /* Ancho de las hojas modales y la barra inferior — se mantiene compacto
     incluso en desktop, para que no se conviertan en carteles gigantes. */
  --sheet-width: 430px;
  /* Alto del nav y ancho de la barra lateral fija — solo se usan en desktop,
     pero declarados acá para tenerlos en un solo lugar. */
  --nav-h: 64px;
  --sidebar-w: 320px;
}

body { margin: 0; background: var(--color-neutral-300); }
* { -webkit-tap-highlight-color: transparent; }
input, button, textarea { font-family: var(--font-body); color: var(--color-text); }
a { color: var(--color-accent-700); text-decoration: none; }
a:hover { color: var(--color-accent-600); }

@keyframes sheetUp {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.app-shell {
  max-width: var(--shell-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg);
  position: relative;
  overflow: hidden;
  padding-bottom: 96px;
  font-family: var(--font-body);
}

/* — nav: logo + nombre del club + botón de configuración — igual en mobile
   y desktop, arriba de todo. */
.app-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--nav-h);
  padding: var(--space-2) var(--space-4);
  box-sizing: border-box;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-divider);
}
.nav-logo {
  height: 36px;
  width: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex: none;
}
.app-nav .nav-brand { margin: 0; }
.nav-gear {
  margin-left: auto;
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
}
.nav-gear:hover { background: color-mix(in srgb, var(--color-text) 8%, transparent); }

/* — filtros: la fila horizontal de chips (mobile) y el menú vertical
   (desktop) muestran lo mismo; cuál se ve lo decide el media query. */
.filters-horizontal { display: flex; overflow-x: auto; }
.filters-vertical { display: none; }
.filters-vertical-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-neutral-700);
  padding: var(--space-4) var(--space-4) var(--space-1);
}
.nav-filter-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px var(--space-4);
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
}
.nav-filter-btn:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.nav-filter-btn.active {
  background: var(--color-accent);
  color: var(--color-bg);
  font-family: var(--font-heading);
}
.nav-filter-sub {
  padding-left: calc(var(--space-4) + var(--space-3));
  font-size: 13px;
}

.layout { display: block; }
.groups-grid { display: block; }

/* Desktop: dejar de simular un celular angosto y usar el monitor entero —
   un menú lateral FIJO (todo el alto de la pantalla, filtros en vertical) y
   a la derecha los grupos en una grilla que se acomoda sola. */
@media (min-width: 900px) {
  :root {
    --sheet-width: 480px;
  }

  body { padding: 0; }

  .app-shell {
    max-width: none;
    margin: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  .app-nav {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .layout { display: block; }

  .panel-left {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    overflow-y: auto;
    background: var(--color-surface);
    border-right: 1px solid var(--color-divider);
  }

  .panel-right {
    margin-left: var(--sidebar-w);
    padding: 0 var(--space-4);
    box-sizing: border-box;
  }

  .search-bar { box-shadow: none !important; }

  .filters-horizontal { display: none; }
  .filters-vertical { display: block; padding-bottom: var(--space-4); }

  .groups-grid {
    display: grid;
    /* auto-fit (no auto-fill): con pocos grupos, las tarjetas existentes
       estiran para ocupar el ancho libre en vez de dejarlo vacío. */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-content: start;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-4) 0;
  }

  .group-card {
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-md);
    overflow: hidden;
    align-self: start;
  }

  .empty-state {
    grid-column: 1 / -1;
  }

  .cta-bar { left: var(--sidebar-w) !important; }
}

button:disabled { cursor: not-allowed; }

/* Imprimir el QR (botón "Imprimir" del sheet, ver openQr/printQr en app.js):
   se oculta todo menos el propio sheet, que pasa a ocupar toda la hoja. */
@media print {
  body * { visibility: hidden; }
  #qr-print-area, #qr-print-area * { visibility: visible; }
  #qr-print-area {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: none !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: none !important;
    padding: 10mm;
    box-sizing: border-box;
  }
  #qr-print-area button { display: none; }
  #qr-image { width: 70mm !important; height: 70mm !important; }
}
