/* Button Loading Spinner & Premium Info Status */
.button.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.button.is-loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: button-spinner 0.6s linear infinite;
}

.button.outline.is-loading::after,
.button.ghost.is-loading::after {
  border: 2px solid rgba(0, 155, 219, 0.15);
  border-top-color: var(--blue);
}

.status.info {
  color: var(--blue);
}

@keyframes button-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Compact Admin Navigation Bar */
.admin-page .topbar {
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  font-size: 0.78rem !important;
}

.admin-header {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  min-height: 48px !important;
}

.admin-header-actions {
  gap: 12px;
}

.admin-header-actions .button.ghost {
  min-height: 28px !important;
  padding: 0 10px !important;
  font-size: 0.78rem !important;
}

.admin-sync-status {
  min-height: 28px !important;
  font-size: 0.78rem !important;
  padding: 0 10px !important;
}

/* ==========================================================================
   Estilos de Impresión para Ficha de Socio (A4 Portrait)
   ========================================================================== */
@media screen {
  .print-only {
    display: none !important;
  }
}

@media print {
  /* Ocurre una segunda página en blanco debido a la retención de espacio de visibility: hidden.
     Ocultamos físicamente los componentes de pantalla del flujo de maquetación (layout flow). */
  .topbar,
  .site-header,
  .admin-main,
  .modal-overlay {
    display: none !important;
  }

  html, body {
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  .print-only {
    display: block !important;
    position: relative !important;
    width: 100%;
    color: #1d2b35 !important;
    background: #ffffff !important;
    font-family: 'Google Sans', Arial, Helvetica, sans-serif;
    font-size: 10pt;
    line-height: 1.4;
    padding: 0;
    margin: 0;
  }

  /* Configuración de página A4 con márgenes */
  @page {
    size: A4 portrait;
    margin: 1.5cm;
  }

  /* Encabezado del Dossier */
  .print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #1d2b35;
    padding-bottom: 12px;
    margin-bottom: 24px;
  }

  .print-header-logo img {
    height: 50px !important;
    display: block;
  }

  .print-header-title {
    text-align: right;
  }

  .print-header-title h1 {
    font-size: 16pt;
    font-weight: 700;
    margin: 0;
    color: #1d2b35;
  }

  .print-date {
    font-size: 8.5pt;
    color: #667783;
    margin: 4px 0 0 0;
  }

  /* Secciones y espaciados */
  .print-section {
    page-break-inside: avoid;
    margin-bottom: 24px;
  }

  .print-section h2 {
    font-size: 11pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #1d2b35;
    border-bottom: 1px solid #dbe6eb;
    padding-bottom: 6px;
    margin: 0 0 12px 0;
  }

  /* Tablas de Datos del Socio (Ahorro de tinta y alto contraste) */
  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
  }

  .print-table th,
  .print-table td {
    padding: 6px 8px;
    border: 1px solid #dbe6eb;
    text-align: left;
    vertical-align: top;
  }

  .print-table th {
    background: #f2f7f9 !important;
    color: #1d2b35;
    font-weight: 600;
    font-size: 9pt;
    width: 25%;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-table td {
    font-size: 9.5pt;
    background: #ffffff !important;
  }

  /* Tablas del Historial de Actividad (Compactas) */
  .print-table.compact th,
  .print-table.compact td {
    padding: 4px 6px;
    font-size: 8.5pt;
  }

  .print-table.compact thead th {
    background: #eaf7fc !important;
    font-weight: 700;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-empty {
    font-size: 9pt;
    color: #667783;
    font-style: italic;
    margin: 0 0 12px 0;
  }

  /* Advertencia de Privacidad y Confidencialidad (RGPD) */
  .print-footer {
    border-top: 1px dashed #667783;
    padding-top: 10px;
    margin-top: 30px;
    font-size: 7.5pt;
    color: #667783;
    line-height: 1.3;
    text-align: justify;
    page-break-inside: avoid;
  }

  .print-footer p {
    margin: 0 0 6px 0;
  }

  .print-footer p:last-child {
    margin: 0;
  }
}

/* ==========================================================================
   ESTILOS DE ANALÍTICAS Y ESTADÍSTICAS - PREMIUM
   ========================================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 16px;
}

.analytics-card {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(16, 57, 78, 0.07);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(16, 57, 78, 0.03);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.analytics-card-wide {
  grid-column: 1 / -1;
}

.member-growth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(16, 57, 78, 0.06);
}

.member-growth-card-header h4 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
}

.analytics-card-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.member-growth-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.member-growth-filter-group {
  position: relative;
  display: inline-flex;
}

.member-growth-select {
  height: 34px;
  padding: 0 28px 0 10px;
  color: #334155;
  background-color: #f8fafc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.member-growth-select:hover {
  background-color: #ffffff;
  border-color: var(--blue);
}

.member-growth-select:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 155, 219, 0.18);
}

.member-growth-view-toggle {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}

.member-growth-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.member-growth-toggle-btn:hover {
  color: var(--ink);
}

.member-growth-toggle-btn.is-active {
  color: var(--blue);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.member-growth-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  color: #64748b;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.member-growth-reset-btn:hover {
  color: #dc2626;
  border-color: #dc2626;
  background: #fef2f2;
}

.member-growth-reset-btn.is-hidden {
  display: none !important;
}

.member-growth-chart {
  position: relative;
  min-height: 0;
}

.member-growth-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.member-growth-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--blue);
  border-radius: 8px;
}

.member-growth-metric strong {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.member-growth-metric strong.is-positive {
  color: #10b981;
}

.member-growth-metric span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.member-growth-plot-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  user-select: none;
}

.member-growth-plot {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 5.2;
  min-height: 240px;
}

.member-growth-grid line {
  stroke: rgba(16, 57, 78, 0.07);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.member-growth-grid text,
.member-growth-x-label {
  fill: #647887;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
}

.member-growth-area {
  fill: url(#memberGrowthArea);
}

.member-growth-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.member-growth-endpoint {
  fill: #10b981;
  stroke: #ffffff;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.member-growth-bar {
  fill: #009bdb;
  rx: 3px;
  ry: 3px;
  transition: fill 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.member-growth-bar:hover,
.member-growth-bar.is-active {
  fill: #0284c7;
  filter: brightness(1.1);
}

.member-growth-crosshair {
  stroke: rgba(2, 132, 199, 0.45);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.member-growth-hover-dot {
  fill: #0284c7;
  stroke: #ffffff;
  stroke-width: 3;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  pointer-events: none;
  transition: r 0.15s ease;
}

/* Tooltip Interactivo */
.member-growth-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 13px;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  font-family: inherit;
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  transform: translate(-50%, -115%);
  transition: opacity 0.12s ease, transform 0.08s ease;
  opacity: 0;
}

.member-growth-tooltip.is-visible {
  opacity: 1;
}

.member-growth-tooltip-date {
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.member-growth-tooltip-val {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #38bdf8;
}

.member-growth-tooltip-val small {
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
}

.member-growth-tooltip-sub {
  color: #a7f3d0;
  font-size: 0.72rem;
  font-weight: 700;
}

.member-growth-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.analytics-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(16, 57, 78, 0.06);
  border-color: rgba(0, 155, 219, 0.2);
}

.analytics-card h4 {
  margin: 0 0 20px 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
  border-bottom: 1px solid rgba(16, 57, 78, 0.04);
  padding-bottom: 12px;
}

.chart-container {
  min-height: 150px;
}

/* Gráficos y barras */
.bar-track {
  position: relative;
  background: rgba(16, 57, 78, 0.04);
  border-radius: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.bar-chart-row:last-child {
  margin-bottom: 0;
}

.segment-row {
  margin-bottom: 16px;
}

.segment-row:last-child {
  margin-bottom: 0;
}

.voting-stat-row {
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(16, 57, 78, 0.05);
  padding-bottom: 16px;
}

.voting-stat-row:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

/* Adaptación responsive para Analytics */
@media (max-width: 1024px) {
  .analytics-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

@media (max-width: 640px) {
  .member-growth-summary {
    grid-template-columns: 1fr;
  }

  .member-growth-plot-wrap {
    overflow-x: auto;
  }

  .member-growth-plot {
    width: 760px;
    max-width: none;
  }
}

/* ==========================================================================
   ESTILOS PARA PESTAÑAS EN EL MODAL DE DETALLE DE SOCIO
   ========================================================================== */
.admin-modal-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-modal-tabs::-webkit-scrollbar {
  display: none;
}
.admin-modal-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
  white-space: nowrap;
}
.admin-modal-tab:hover {
  color: var(--blue);
}
.admin-modal-tab.is-active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
.admin-modal-tab-pane {
  display: none;
}
.admin-modal-tab-pane.is-active {
  display: block;
}

/* Estilo premium para visualización de IBAN / Cuenta Bancaria */
.admin-iban {
  display: inline-block;
  min-height: auto;
  padding: 3px 8px;
  background: var(--soft-blue);
  border: 1px solid rgba(0, 155, 219, 0.22);
  color: var(--ink);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 6px;
  letter-spacing: 0.03em;
}
.admin-table .admin-iban {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

