/**
 * Agenda — scroll de página hacia abajo (calendario completo),
 * sin hueco encima del título "Agenda".
 *
 * - padding-top: 0  → no se puede “subir” a zona vacía sobre Agenda
 * - overflow-y: auto en content-wrapper → se baja a ver todo el calendario
 * - iframe crece con el contenido (JS syncHeight) → sin scroll interno del mes
 *
 * NO toca .wrapper background (protege sidebar).
 */
:root {
  --cn-ag-header-h: var(--cn-header-height, 50px);
  --cn-ag-footer-h: 42px;
  --cn-ag-sidebar-w: var(--cn-sidebar-width, 240px);
  --cn-ag-sidebar-mini-w: 50px;
}

html:has(#cuerpo > .cn-agenda-page),
body:has(#cuerpo > .cn-agenda-page),
html.cn-agenda-active,
body.cn-agenda-active {
  height: 100% !important;
  overflow: hidden !important; /* scroll solo en content-wrapper */
}

body:has(#cuerpo > .cn-agenda-page) .wrapper,
body.cn-agenda-active .wrapper {
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Tope en header: sin padding fantasma; scroll hacia abajo permitido */
body.fixed .content-wrapper:has(#cuerpo > .cn-agenda-page),
body.skin-blue.fixed .content-wrapper:has(#cuerpo > .cn-agenda-page),
body.fixed.cn-agenda-active .content-wrapper,
body.skin-blue.fixed.cn-agenda-active .content-wrapper,
.content-wrapper:has(#cuerpo > .cn-agenda-page),
body.cn-agenda-active .content-wrapper {
  display: block !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  min-height: 0 !important;
  margin-top: var(--cn-ag-header-h) !important;
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-bottom: calc(var(--cn-ag-footer-h) + 28px) !important;
  height: calc(100vh - var(--cn-ag-header-h)) !important;
  max-height: calc(100vh - var(--cn-ag-header-h)) !important;
  margin-bottom: 0 !important;
  background: #eff4fa !important;
  box-shadow: none !important;
  border: none !important;
}

.content-wrapper:has(#cuerpo > .cn-agenda-page) > .content,
body.cn-agenda-active .content-wrapper > .content {
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.content-wrapper:has(#cuerpo > .cn-agenda-page) > .content > .row,
body.cn-agenda-active .content-wrapper > .content > .row {
  display: block !important;
  margin: 0 !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
}

.content-wrapper:has(#cuerpo > .cn-agenda-page) > .content > .row > .box,
.content-wrapper:has(#cuerpo > .cn-agenda-page) .cn-gestion-host-box,
body.cn-agenda-active .content-wrapper > .content > .row > .box,
body.cn-agenda-active .cn-gestion-host-box {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
}

#cuerpo:has(> .cn-agenda-page),
body.cn-agenda-active #cuerpo {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
}

body:has(#cuerpo > .cn-agenda-page) .main-footer,
body.cn-agenda-active .main-footer {
  position: fixed !important;
  left: var(--cn-ag-sidebar-w) !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: var(--cn-ag-footer-h) !important;
  margin: 0 !important;
  margin-left: 0 !important;
  padding: 10px 15px !important;
  z-index: 830 !important;
  background: #fff !important;
  border-top: 1px solid #e2e8f0 !important;
  box-shadow: none !important;
  line-height: 20px !important;
  overflow: hidden !important;
}

body.sidebar-mini.sidebar-collapse:has(#cuerpo > .cn-agenda-page) .main-footer,
body.cn-agenda-active.sidebar-mini.sidebar-collapse .main-footer {
  left: var(--cn-ag-sidebar-mini-w) !important;
}

/* Página: flujo natural (baja a ver calendario completo) */
#cuerpo > .cn-module-page.cn-agenda-page {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 4px 10px 16px !important;
  box-sizing: border-box !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

#cuerpo > .cn-agenda-page > .cn-module-header {
  margin: 0 0 8px !important;
  padding: 0 !important;
}

#cuerpo > .cn-agenda-page > .cn-agenda-body {
  display: block !important;
  overflow: visible !important;
  height: auto !important;
}

#cuerpo > .cn-agenda-page .content.cn-agenda-section {
  display: block !important;
  padding: 0 !important;
  margin: 0 0 10px !important;
  min-height: 0 !important;
  height: auto !important;
}

#cuerpo > .cn-agenda-page .cn-agenda-section--calendar {
  margin-bottom: 0 !important;
}

#cuerpo > .cn-agenda-page .cn-agenda-section--calendar > .cn-agenda-box,
#cuerpo > .cn-agenda-page .cn-agenda-section--calendar .x_content {
  display: block !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  padding: 0 !important;
}

#cuerpo > .cn-agenda-page .cn-agenda-tabla-asignadas {
  max-height: 180px !important;
  overflow-y: auto !important;
}

#cuerpo > .cn-agenda-page .cn-agenda-calendar-wrap {
  display: block !important;
  margin: 0 !important;
  padding: 0 4px 8px !important;
  overflow: visible !important;
  height: auto !important;
  min-height: 0 !important;
}

#cuerpo > .cn-agenda-page .cn-agenda-section-head--calendar {
  padding: 4px 4px 6px !important;
  margin: 0 !important;
}

/* Iframe: alto lo define JS syncHeight (sin scroll interno) */
#cuerpo > .cn-agenda-page .custom-calendar-iframe,
#cuerpo > .cn-agenda-page .cn-agenda-calendar-iframe {
  display: block !important;
  width: 100% !important;
  min-height: 620px !important;
  height: 620px;
  max-height: none !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: #f3f6fa !important;
  overflow: hidden !important;
}

@media (max-width: 767px) {
  body:has(#cuerpo > .cn-agenda-page) .main-footer,
  body.cn-agenda-active .main-footer {
    left: 0 !important;
  }

  #cuerpo > .cn-module-page.cn-agenda-page {
    padding: 4px 6px 12px !important;
  }
}
