@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

:root {
  /* Paleta tomada del logo (El Aromo del Portal): verde del arbol como
     color de marca, dorado/tostado de las hojas como acento secundario. */
  --primary: #0e3b22;
  --secondary: #155d30;
  --accent: #129b4c;
  --accent-dark: #0c7a3e;
  --gold: #c9a46e;
  --cream: #f8fafc;
  --wine: #7b3f8c;

  --bg: #f4f7fb;
  --card: #ffffff;

  --text: #1f2937;
  --text-light: #6b7280;

  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  font-family: 'Poppins', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-top: 76px;
  background: var(--bg);
  color: var(--text);
}

/* =====================================
   NAVBAR
===================================== */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1050;
  background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
  box-shadow: var(--shadow);
  padding: 14px 22px;
  border-bottom: 3px solid var(--accent);
}

.navbar-logo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

/* =====================================
   SIDEBAR
===================================== */

.sidebar-mobile {
  background: linear-gradient(180deg, var(--primary), #111827);
  box-shadow: var(--shadow);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-desktop {
  width: 250px;
  min-width: 250px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.3s;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85) !important;
}

.nav-link i {
  font-size: 18px;
}

.nav-link:hover {
  background: rgba(244, 122, 34, 0.18);
  color: white !important;
  padding-left: 22px;
  transform: translateX(4px);
}

/* Ítem de la vista visible y submenús Formularios/Tablas (navegacion.js) */
.nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: white !important;
  font-weight: 600;
}

.nav-grupo-chevron {
  font-size: 14px !important;
  transition: transform 0.2s;
}

.nav-grupo-toggle:not(.collapsed) .nav-grupo-chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  padding-left: 18px;
}

.nav-link.nav-subitem {
  padding: 9px 14px;
  font-size: 0.93rem;
}

.nav-link.nav-subitem i {
  font-size: 15px;
}

/* Bloques de otras vistas (una sola vista visible a la vez) */
.vista-oculta {
  display: none !important;
}

.offcanvas {
  background: linear-gradient(180deg, var(--primary), #111827);
  /* Bootstrap fija el ancho con esta variable (400px por defecto) */
  --bs-offcanvas-width: 260px;
  /* Por encima de la navbar fija (z-index 1050), que si no tapa
     el encabezado del menú y su botón de cerrar */
  --bs-offcanvas-zindex: 1060;
}

.offcanvas-backdrop {
  z-index: 1055;
}

/* =====================================
   LAYOUT
===================================== */

.main-content {
  width: 100%;
  display: flex;
  flex-direction: column;
}

#dashboard {
  order: -20;
}

#dashboard_graficos {
  order: -10;
}

#modulo_asistencia {
  order: 30;
}

#asistencias {
  order: 40;
}

#eventos {
  order: 50;
}

#modulo_personas {
  order: 60;
}

#modulo_pagos {
  order: 70;
}

#finanzas {
  order: 80;
}

#multas {
  order: 90;
}

@media (min-width: 992px) {
  .sidebar-desktop {
    position: fixed;
    top: 76px;
    right: 0;
    width: 260px;
    height: calc(100vh - 76px);
    overflow-y: auto;
    z-index: 1040;
  }

  /* Sidebar de escritorio a la derecha */
  .sidebar-desktop .sidebar-mobile {
    border-right: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
  }

  .main-content {
    margin-right: 260px;
    width: calc(100% - 260px);
  }

  /* Botón de la navbar que oculta el sidebar (navegacion.js) */
  body.sidebar-oculto .sidebar-desktop {
    display: none !important; /* gana a .d-lg-block de Bootstrap */
  }

  body.sidebar-oculto .main-content {
    margin-right: 0;
    width: 100%;
  }
}

@media (max-width: 991.98px) {
  body {
    padding-top: 64px;
  }

  .main-content {
    width: 100%;
  }
}

/* =====================================
   MODULOS Y CARDS
===================================== */

.module-section {
  background: white;
  padding: 35px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 35px;
}

.module-section h2 {
  display: flex;
  align-items: center;
  gap: 12px;
}

.module-section + .module-section {
  margin-top: 40px;
}

.card {
  border: none;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: 0.3s;
  cursor: default;
}

.card:hover {
  transform: translateY(-3px);
}

.card-body {
  padding: 24px;
}

.card-body h2 {
  font-size: 38px;
  font-weight: 700;
  margin-top: 12px;
}

.card-title {
  font-size: 15px;
  opacity: 0.85;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-grid > [class*="col-"] {
  width: auto;
  max-width: none;
  padding: 0;
}

.dashboard-grid .card {
  height: 100%;
  min-height: 124px;
}

.dashboard-grid .card-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 124px;
  padding: 18px;
}

.dashboard-grid .card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 2.3em;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.dashboard-grid .card-body h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

/* Resumen del dashboard: tarjetas apiladas en una columna angosta y el
   gráfico Deuda Actual al lado. En pantallas chicas queda uno bajo el otro. */
.dashboard-resumen {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

#grafico_deuda_wrapper .card {
  display: flex;
  flex-direction: column;
}

#grafico_deuda_wrapper .chart-container {
  flex: 1;
}

@media (min-width: 769px) {
  .dashboard-resumen {
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  }

  .dashboard-resumen .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .dashboard-resumen .dashboard-grid .card,
  .dashboard-resumen .dashboard-grid .card-body {
    min-height: 0;
  }

  .dashboard-resumen .dashboard-grid .card-body {
    padding: 14px 18px;
  }

  .dashboard-resumen .dashboard-grid .card-title {
    min-height: 0;
  }
}

.dashboard-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

/* Calendario mensual de actividades (dashboard) */
.calendario-wrapper {
  grid-column: 1 / -1;
}

.calendario-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.calendario-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendario-dia-semana {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  padding: 4px 0;
}

.calendario-dia {
  min-height: 92px;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.calendario-dia-vacio {
  background: transparent;
}

.calendario-hoy {
  outline: 2px solid var(--accent);
}

.calendario-numero {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.calendario-evento {
  font-size: 0.72rem;
  line-height: 1.2;
  color: white;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

.calendario-evento-partido {
  background: var(--wine);
}

.calendario-evento-reunion {
  background: var(--primary);
}

.dashboard-chart-grid > [class*="col-"] {
  width: auto;
  max-width: none;
  padding: 0;
  margin: 0 !important;
}

h2 {
  font-size: 34px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 28px;
}

/* =====================================
   GRAFICOS
===================================== */

.chart-container {
  position: relative;
  min-height: 320px;
}

canvas {
  max-width: 100% !important;
}

/* =====================================
   TABLAS
===================================== */

.table {
  background: white;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 0;
  min-width: 720px;
}

.table thead {
  background: var(--primary);
  color: white;
}

.table tbody tr {
  transition: 0.2s;
}

.table tbody tr:hover {
  background: rgba(244, 122, 34, 0.07);
}

.table td,
.table th {
  border-color: rgba(0, 0, 0, 0.05);
  vertical-align: middle;
}

.table th,
.table .badge {
  white-space: nowrap;
}

.table-responsive {
  border-radius: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.table .btn-group-sm .btn {
  min-width: 2.1rem;
  min-height: 2rem;
  padding: 0.25rem 0.45rem;
  line-height: 1;
}

#tabla_personas_wrapper .table {
  min-width: 900px;
}

#tabla_eventos_wrapper .table {
  min-width: 920px;
}

#tabla_pagos_wrapper .table,
#tabla_cuotas_wrapper .table,
#tabla_finanzas_wrapper .table {
  min-width: 760px;
}

#tabla_asistencias_wrapper .table,
#tabla_multas_wrapper .table {
  min-width: 640px;
}

#tabla_eventos_wrapper td:nth-child(5) {
  min-width: 220px;
  white-space: normal;
}

#tabla_personas_wrapper th:last-child,
#tabla_personas_wrapper td:last-child,
#tabla_eventos_wrapper th:last-child,
#tabla_eventos_wrapper td:last-child,
#tabla_pagos_wrapper th:last-child,
#tabla_pagos_wrapper td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  box-shadow: -8px 0 12px rgba(15, 23, 42, 0.06);
}

#tabla_personas_wrapper td:last-child,
#tabla_eventos_wrapper td:last-child,
#tabla_pagos_wrapper td:last-child {
  background: white;
}

#tabla_personas_wrapper th:last-child,
#tabla_eventos_wrapper th:last-child,
#tabla_pagos_wrapper th:last-child {
  background: var(--primary);
  color: white;
  z-index: 3;
}

/* =====================================
   FORMULARIOS Y BOTONES
===================================== */

.form-control,
.form-select {
  border-radius: 14px;
  min-height: 48px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(244, 122, 34, 0.15);
}

.btn {
  border-radius: 12px;
  font-weight: 500;
  transition: 0.25s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary,
.btn-success {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.btn-primary:hover,
.btn-success:hover {
  background-color: var(--accent-dark) !important;
  border-color: var(--accent-dark) !important;
}

.qr-attendance-panel {
  background: #f8fafc;
  border: 1px solid rgba(18, 155, 76, 0.18);
  border-radius: 18px;
  padding: 18px;
}

.qr-attendance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.qr-scanner-wrapper {
  position: relative;
  background: #0f172a;
  border-radius: 16px;
  margin-top: 16px;
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.qr-scanner-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scanner-wrapper::after {
  content: '';
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  box-shadow:
    0 0 0 999px rgba(15, 23, 42, 0.18),
    0 0 22px rgba(244, 122, 34, 0.28);
  pointer-events: none;
}

.qr-attendance-status {
  font-size: 0.95rem;
}

/* =====================================
   Logo cliente configurado
===================================== */

.cliente-logo,
img[data-config-img="cliente.logo"] {
  width: 44px;
  height: 44px;
  max-width: 44px;
  max-height: 44px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  flex: 0 0 auto;
}

/* =====================================
   FOOTER
===================================== */

.app-footer {
  background: var(--primary);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

/* =====================================
   RESPONSIVE
===================================== */

@media (max-width: 768px) {
  .sidebar-mobile {
    min-height: auto !important;
    padding: 15px !important;
  }

  .btn-mobile-full {
    width: 100%;
  }

  .card-body h2 {
    font-size: 28px;
  }

  .main-content {
    width: 100% !important;
    margin-left: 0 !important;
    padding: 18px !important;
  }

  .module-section {
    padding: 20px;
    border-radius: 20px;
  }

  h2 {
    font-size: 28px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .dashboard-grid .card {
    min-height: 104px;
    border-radius: 16px;
  }

  .dashboard-grid .card-body {
    min-height: 104px;
    padding: 14px;
  }

  .dashboard-grid .card-title {
    min-height: 2.4em;
    font-size: 0.72rem;
  }

  .dashboard-grid .card-body h2 {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
  }

  .dashboard-chart-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .calendario-dia {
    min-height: 64px;
  }

  .calendario-evento {
    font-size: 0.62rem;
  }

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

  .table {
    font-size: 0.86rem;
  }

  .table td,
  .table th {
    padding: 0.6rem 0.7rem;
  }

  .table .btn-group-sm .btn {
    min-width: 2rem;
    min-height: 1.9rem;
  }

  /* =====================================
   Logo cliente configurado
  ===================================== */

  .cliente-logo,
  img[data-config-img="cliente.logo"] {
    width: 34px;
    height: 34px;
    max-width: 34px;
    max-height: 34px;
  }

}



