/* ============================================================
   Gestión Club Amistad — Sistema de diseño v2
   Registro: producto (herramienta interna, escritorio primero)
   Paleta oficial del manual de marca:
     Azul     #00398b  (Pantone Ref. BlueC)  acento y marca
     Morado   #85007c  (Pantone 2415C)       secundario puntual
     Amarillo #efcd41  (Pantone 123C)        acciones primarias
   Fondo azul claro; superficies blancas que destacan.
   Densidad alta: es una herramienta de mostrador.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Marca */
  --ca-blue:        #00398b;
  --ca-blue-dark:   #002a69;
  --ca-blue-soft:   #e8eef7;
  --ca-purple:      #85007c;
  --ca-purple-soft: #faecf8;
  --ca-yellow:      #efcd41;
  --ca-yellow-dark: #d9b724;
  --ca-yellow-soft: #fef6d1;

  /* Fondo de aplicación: azul claro de marca. Las tarjetas blancas
     flotan claramente sobre él. */
  --ca-bg:        #d7e2f0;
  --ca-surface:   #ffffff;
  --ca-surface-2: #f4f8fc;   /* cabeceras de tarjeta y de tabla */

  --ca-gray-50:  #f8fafc;
  --ca-gray-100: #f1f5f9;
  --ca-gray-200: #e2e8f0;
  --ca-gray-300: #cbd5e1;
  --ca-gray-400: #94a3b8;
  --ca-gray-500: #64748b;
  --ca-gray-600: #475569;
  --ca-gray-700: #334155;
  --ca-gray-800: #1e293b;
  --ca-gray-900: #0f172a;

  --ca-success:      #059669;
  --ca-success-soft: #d1fae5;
  --ca-warn:         #b45309;
  --ca-warn-soft:    #fef3c7;
  --ca-danger:       #dc2626;
  --ca-danger-soft:  #fee2e2;

  --ca-border: #d4deea;      /* borde de tarjeta con tinte azul */

  --ca-shadow-sm: 0 1px 2px rgba(0, 42, 105, 0.08);
  --ca-shadow:    0 1px 3px rgba(0, 42, 105, 0.10), 0 1px 2px rgba(0, 42, 105, 0.06);
  --ca-shadow-md: 0 6px 16px rgba(0, 42, 105, 0.12), 0 2px 4px rgba(0, 42, 105, 0.06);

  --ca-radius-sm: 6px;
  --ca-radius:    8px;
  --ca-radius-lg: 12px;

  --z-dropdown: 100;
  --z-sticky:   200;
  --z-backdrop: 300;
  --z-modal:    400;
  --z-toast:    500;

  --topbar-h: 52px;
  --bottombar-h: 58px;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--ca-bg);
  color: var(--ca-gray-900);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* Firma de marca: línea superior azul → amarillo */
body::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--ca-blue) 0%, var(--ca-blue) 70%, var(--ca-yellow) 100%);
  position: relative;
  z-index: calc(var(--z-sticky) + 1);
}

h1, h2, h3, h4 {
  margin: 0;
  letter-spacing: -0.015em;
  font-weight: 700;
  color: var(--ca-gray-900);
  text-wrap: balance;
}
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

a { color: var(--ca-blue); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }

svg.icon {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  vertical-align: -0.26em;
}
svg.icon-sm { width: 15px; height: 15px; }

/* ============================================================
   Barra superior
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--topbar-h);
  background: var(--ca-blue);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.1rem;
  box-shadow: 0 2px 10px rgba(0, 42, 105, 0.28);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.02rem;
  color: #fff;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand .icon { width: 23px; height: 23px; color: var(--ca-yellow); }
.topbar-brand small {
  font-weight: 500;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
}

.topbar nav {
  display: flex;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  align-self: stretch;
  align-items: stretch;
}
.topbar nav::-webkit-scrollbar { display: none; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0 0.8rem;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.nav-link.active { color: #fff; background: rgba(255, 255, 255, 0.1); }
.nav-link.active::after {
  content: '';
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ca-yellow);
}
.nav-link .icon { width: 17px; height: 17px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.83rem;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}
.topbar-user button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--ca-radius);
  display: flex;
  transition: background-color 0.15s;
}
.topbar-user button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* ============================================================
   Barra inferior móvil
   ============================================================ */

.bottombar { display: none; }

@media (max-width: 767px) {
  .topbar nav { display: none; }
  .topbar-user span { display: none; }

  .bottombar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--ca-surface);
    border-top: 1px solid var(--ca-border);
    box-shadow: 0 -2px 10px rgba(0, 42, 105, 0.10);
  }
  .bottombar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ca-gray-500);
  }
  .bottombar a:hover { text-decoration: none; }
  .bottombar a.active { color: var(--ca-blue); }
  .bottombar a.active .icon { color: var(--ca-blue); }
  .bottombar a .icon { width: 21px; height: 21px; }

  main.page { padding-bottom: calc(var(--bottombar-h) + 1.5rem) !important; }
}

/* ============================================================
   Layout de página
   ============================================================ */

main.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 2.25rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.page-head h1::after {
  content: '';
  display: block;
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background: var(--ca-yellow);
  margin-top: 5px;
}
.page-head p { margin: 0.3rem 0 0; color: var(--ca-gray-600); font-size: 0.88rem; }

.card {
  background: var(--ca-surface);
  border: 1px solid var(--ca-border);
  border-radius: var(--ca-radius-lg);
  box-shadow: var(--ca-shadow);
  overflow: hidden;
}
.card-pad { padding: 0.95rem 1.1rem; }
.card + .card { margin-top: 0.8rem; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.1rem;
  background: var(--ca-surface-2);
  border-bottom: 1px solid var(--ca-border);
}
.card-head h3 { display: flex; align-items: center; gap: 0.45rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ============================================================
   Formularios
   ============================================================ */

.field { display: flex; flex-direction: column; gap: 0.22rem; min-width: 0; }
.field label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ca-gray-600);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input[type='text'], input[type='search'], input[type='email'], input[type='tel'],
input[type='number'], input[type='date'], input[type='time'], input[type='password'],
select, textarea {
  font: inherit;
  font-size: 0.92rem;
  color: var(--ca-gray-900);
  background: var(--ca-gray-50);
  border: 1px solid var(--ca-gray-300);
  border-radius: var(--ca-radius-sm);
  padding: 0.4rem 0.6rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--ca-gray-500); }
input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--ca-surface);
  border-color: var(--ca-blue);
  box-shadow: 0 0 0 3px var(--ca-blue-soft);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--ca-gray-100);
  color: var(--ca-gray-500);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; }

.field-inline { display: flex; align-items: center; gap: 0.45rem; }
.field-inline input[type='checkbox'] { width: 17px; height: 17px; accent-color: var(--ca-blue); }
.field-inline label { text-transform: none; letter-spacing: 0; font-size: 0.9rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.6rem 0.8rem;
}
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid .span-2 { grid-column: span 1; } }

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

/* ============================================================
   Botones
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.87rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--ca-radius);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.06s;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ca-blue-soft), 0 0 0 1px var(--ca-blue); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .icon { width: 17px; height: 17px; }

/* Primario: amarillo del club con texto azul (decisión de Alberto) */
.btn-primary {
  background: var(--ca-yellow);
  border-color: var(--ca-yellow-dark);
  color: var(--ca-blue);
  box-shadow: var(--ca-shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--ca-yellow-dark); }

.btn-secondary { background: var(--ca-surface); border-color: var(--ca-gray-300); color: var(--ca-gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--ca-gray-50); border-color: var(--ca-gray-400); }

.btn-danger { background: var(--ca-danger); border-color: var(--ca-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost { background: none; border-color: transparent; color: var(--ca-gray-500); padding: 0.3rem 0.5rem; font-weight: 600; }
.btn-ghost:hover:not(:disabled) { background: var(--ca-blue-soft); color: var(--ca-blue); }

.btn-sm { padding: 0.26rem 0.6rem; font-size: 0.8rem; }

.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-primary .spinner { border-color: rgba(0, 57, 139, 0.3); border-top-color: var(--ca-blue); }
.btn-secondary .spinner { border-color: var(--ca-gray-300); border-top-color: var(--ca-gray-600); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Tablas
   ============================================================ */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
  background: var(--ca-surface);
}
table.data th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ca-gray-600);
  background: var(--ca-surface-2);
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--ca-border);
  white-space: nowrap;
}
table.data td {
  padding: 0.38rem 0.75rem;
  border-bottom: 1px solid var(--ca-gray-100);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--ca-blue-soft); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.data td.actions { text-align: right; white-space: nowrap; }
table.data tfoot td {
  font-weight: 700;
  background: var(--ca-surface-2);
  border-top: 1px solid var(--ca-border);
  border-bottom: none;
}

/* Inputs dentro de tablas (configuración): más compactos */
table.data input, table.data select {
  padding: 0.28rem 0.5rem;
  font-size: 0.87rem;
}

/* ============================================================
   Pestañas
   ============================================================ */

.tabs {
  display: flex;
  gap: 0.1rem;
  border-bottom: 1px solid var(--ca-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ca-gray-600);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.tab:hover { color: var(--ca-blue); background: var(--ca-gray-50); }
.tab.active { color: var(--ca-blue); border-bottom-color: var(--ca-yellow); font-weight: 700; }
.tab .icon { width: 16px; height: 16px; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-blue    { background: var(--ca-blue-soft);    color: var(--ca-blue-dark); }
.badge-purple  { background: var(--ca-purple-soft);  color: var(--ca-purple); }
.badge-success { background: var(--ca-success-soft); color: #065f46; }
.badge-warn    { background: var(--ca-warn-soft);    color: var(--ca-warn); }
.badge-danger  { background: var(--ca-danger-soft);  color: #991b1b; }
.badge-gray    { background: var(--ca-gray-100);     color: var(--ca-gray-600); }

/* ============================================================
   Autocompletado (buscador central)
   ============================================================ */

.search-box { position: relative; }
.search-box > .icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ca-gray-400);
  pointer-events: none;
}
.search-box input { padding-left: 2.25rem; }

.ac-list {
  position: fixed;
  z-index: var(--z-dropdown);
  background: var(--ca-surface);
  border: 1px solid var(--ca-border);
  border-radius: var(--ca-radius);
  box-shadow: var(--ca-shadow-md);
  max-height: 320px;
  overflow-y: auto;
  animation: dropdown-in 0.13s ease-out;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.ac-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.ac-item small { color: var(--ca-gray-500); }
.ac-item:hover, .ac-item.selected { background: var(--ca-blue-soft); }
.ac-empty { padding: 0.6rem 0.75rem; color: var(--ca-gray-500); font-size: 0.87rem; }

/* ============================================================
   Estados vacíos
   ============================================================ */

.empty {
  text-align: center;
  padding: 2.25rem 1.5rem;
  color: var(--ca-gray-500);
}
.empty .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.5;
  color: var(--ca-gray-300);
  margin-bottom: 0.6rem;
}
.empty p { margin: 0; max-width: 40ch; margin-inline: auto; font-size: 0.92rem; }

/* ============================================================
   Modales (dialog nativo)
   ============================================================ */

dialog {
  border: none;
  border-radius: var(--ca-radius-lg);
  box-shadow: var(--ca-shadow-md);
  padding: 1.25rem 1.4rem;
  max-width: 460px;
  width: calc(100vw - 2rem);
  color: var(--ca-gray-900);
}
dialog::backdrop { background: rgba(0, 42, 105, 0.5); }
dialog h3 { margin-bottom: 0.4rem; }
dialog p { color: var(--ca-gray-600); margin: 0 0 1rem; font-size: 0.92rem; }

/* ============================================================
   Toasts
   ============================================================ */

#toasts {
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
@media (max-width: 767px) {
  #toasts { bottom: calc(var(--bottombar-h) + 0.9rem); left: 1.1rem; }
}
.toast {
  background: var(--ca-gray-900);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.55rem 0.9rem;
  border-radius: var(--ca-radius);
  box-shadow: var(--ca-shadow-md);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  animation: dropdown-in 0.15s ease-out;
}
.toast.error { background: var(--ca-danger); }
.toast .icon { width: 16px; height: 16px; color: var(--ca-yellow); }
.toast.error .icon { color: #fff; }

/* ============================================================
   Login
   ============================================================ */

.login-wrap {
  min-height: calc(100vh - 3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(255, 255, 255, 0.14), transparent 55%),
    var(--ca-blue);
}
.login-card {
  background: var(--ca-surface);
  border-radius: var(--ca-radius-lg);
  box-shadow: var(--ca-shadow-md);
  padding: 2rem 1.9rem;
  width: 100%;
  max-width: 390px;
}
.login-card .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
  color: var(--ca-blue);
  font-weight: 800;
  font-size: 1.2rem;
}
.login-card .brand .icon { width: 28px; height: 28px; }
.login-card > p { color: var(--ca-gray-600); margin: 0 0 1.25rem; font-size: 0.9rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }

.form-error {
  background: var(--ca-danger-soft);
  color: #991b1b;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.55rem 0.75rem;
  border-radius: var(--ca-radius-sm);
  display: none;
}
.form-error.visible { display: block; }

/* ============================================================
   Utilidades
   ============================================================ */

.muted { color: var(--ca-gray-500); }
.small { font-size: 0.83rem; }
.num { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 0.5rem; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-1 { margin-top: 0.8rem; }
.hidden { display: none !important; }

.filters {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filters .field { min-width: 140px; flex: 0 1 auto; }

.skeleton {
  background: linear-gradient(90deg, var(--ca-gray-100) 25%, var(--ca-gray-200) 50%, var(--ca-gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--ca-radius-sm);
  height: 1rem;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   Impresión (listados)
   ============================================================ */

@media print {
  body::before, .topbar, .bottombar, .filters, .form-actions,
  .btn, #toasts, .no-print { display: none !important; }
  body { background: #fff; }
  main.page { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; }
  table.data th { background: #fff; }
  table.data th, table.data td { padding: 0.25rem 0.45rem; }
}

/* ============================================================
   Movimiento reducido
   ============================================================ */

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