/* Da identidad visual a cada zona y hace más suave el cambio entre secciones. */
:root { --zone-accent: #a9c942; }
#view-inicio { --zone-accent: #b8d743; }
#view-agenda { --zone-accent: #38a6a3; }
#view-perfil { --zone-accent: #8a78c8; }
#view-evaluacion { --zone-accent: #dc9b47; }
#view-salud { --zone-accent: #e17b88; }
#view-fotos { --zone-accent: #708bd2; }
#view-nutricion { --zone-accent: #55a978; }
#view-documentos { --zone-accent: #728493; }
#view-progreso { --zone-accent: #d07d4b; }
#view-reto { --zone-accent: #de7a3e; }
#view-comunidad { --zone-accent: #9b78be; }
#view-clientes { --zone-accent: #9dbb38; }
.view.active > .page-title { animation: sectionEnter .32s ease-out both; }
.view.active .card { border-top: 3px solid var(--zone-accent); animation: sectionEnter .38s ease-out both; }
.view.active .card:nth-of-type(2) { animation-delay: .04s; }
.view.active .card:nth-of-type(3) { animation-delay: .08s; }
.calendar-day.has-birthday { border-color: #e9a33b; background: #fff8e9; color: #574017; font-weight: 750; }
.calendar-day.has-birthday.selected { background: var(--forest); color: #fff; border-color: var(--lime2); }
.birthday-list { display: grid; gap: 8px; margin-top: 14px; padding: 13px 15px; border: 1px solid #f0dca8; border-radius: 13px; background: linear-gradient(120deg, #fff9e9, #fff 70%); }
.birthday-list-title { color: #654d1d; font-size: 12px; }
.birthday-list-row { display: flex; justify-content: center; gap: 7px 16px; flex-wrap: wrap; padding: 7px 4px; border-top: 1px solid #f2e9d5; font-size: 12px; }
.birthday-list-row span:first-child { color: #80631f; font-weight: 700; }
.birthday-list-row span:last-child { color: #303525; font-weight: 650; }
.whatsapp-community-card { overflow: hidden; background: radial-gradient(ellipse at 50% 24%, #e9ffef 0, #fff 52%); }
.whatsapp-community-content { display: grid; justify-items: center; gap: 13px; padding: 12px 12px 8px; text-align: center; }
.whatsapp-community-heading { display: grid; justify-items: center; gap: 7px; max-width: 600px; }
.whatsapp-bubble { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(145deg, #36d675, #16a45a); color: white; box-shadow: 0 8px 20px #16a45a35; font-size: 29px; animation: whatsappFloat 2.8s ease-in-out infinite; }
.whatsapp-community-heading .eyebrow { margin: 2px 0 0; color: #16824b !important; }
.whatsapp-community-heading h3 { margin: 0; font-size: clamp(18px, 2.2vw, 23px); }
.whatsapp-community-heading p { max-width: 480px; margin: 0; color: var(--muted); line-height: 1.5; }
.whatsapp-qr-frame { display: grid; place-items: center; padding: 8px; border: 1px solid #d8efdf; border-radius: 19px; background: #fff; box-shadow: 0 12px 30px #244a2b16; }
.whatsapp-community-card .whatsappQr { width: min(100%, 260px); height: 260px; border: 0; border-radius: 13px; }
.whatsapp-join { min-height: 46px; padding: 12px 20px; border-radius: 12px; text-decoration: none; box-shadow: 0 8px 22px #b8d74344; }
.whatsapp-join span { margin-left: 6px; }
.whatsapp-caption { color: var(--muted); font-size: 11px; }
@keyframes whatsappFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .whatsapp-bubble { animation: none; } }
@media (max-width: 600px) { .whatsapp-community-content { padding: 6px 0 3px; } .whatsapp-join { width: 100%; justify-content: center; } .birthday-list-row { justify-content: flex-start; } }
.page-title h2 { display: flex; align-items: center; gap: 9px; }
.page-title h2::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--zone-accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--zone-accent) 18%, transparent); }
@keyframes sectionEnter { from { opacity: .35; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .view.active > .page-title, .view.active .card { animation: none; } }

/* En teléfono, muestra todas las secciones en una barra inferior compacta. */
@media (max-width: 600px) {
  .app { padding-bottom: 158px !important; }
  .sidebar {
    position: fixed;
    z-index: 20;
    inset: auto 0 0;
    width: 100%;
    height: auto !important;
    min-height: 0;
    gap: 0;
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom)) !important;
  }
  .sidebar > .logo,
  .sidebar .nav-label,
  .sidebar-bottom { display: none !important; }
  .sidebar > div:nth-child(2) { flex: 1 1 auto; min-width: 0; width: 100%; }
  .nav {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
    overflow: visible !important;
  }
  .nav button {
    display: flex;
    flex: none !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-width: 0 !important;
    min-height: 46px;
    height: 46px;
    gap: 2px;
    padding: 3px 2px !important;
    white-space: normal;
  }
  .nav .ico { width: auto; font-size: 16px; line-height: 1; }
  .nav button .navtext {
    display: block !important;
    max-width: 100%;
    font-size: 10px !important;
    line-height: 1.08;
    text-align: center;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  .content { padding-bottom: calc(158px + env(safe-area-inset-bottom)) !important; }
  .topbar { padding-left: 12px !important; padding-right: 12px !important; gap: 6px; }
  .topbar > .action { padding: 8px 9px; font-size: 10px; }
  .topright { gap: 6px; }
  #pushNotificationToggle { width: auto; min-width: 38px; border-radius: 20px; padding: 0 9px; }
  #pushNotificationToggle .push-label { display: none; }
}

@media (max-width: 360px) {
  .app { padding-bottom: 150px !important; }
  .nav button { min-height: 43px; height: 43px; }
  .nav button .navtext { font-size: 9px !important; }
  .content { padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important; }
}

/* Fuerza la barra fija completa en Safari móvil y en la app instalada. */
@media screen and (max-width: 600px) {
  html, body { width: 100%; max-width: 100%; overflow-x: clip !important; }
  body .app { display: block !important; width: 100%; min-width: 0; padding-bottom: calc(188px + env(safe-area-inset-bottom)) !important; }
  body .app aside.sidebar {
    position: fixed !important; inset: auto 0 0 0 !important; z-index: 1000 !important;
    display: block !important; width: 100% !important; max-width: 100% !important;
    min-width: 0 !important; min-height: 0 !important; height: auto !important;
    padding: 5px 5px calc(7px + env(safe-area-inset-bottom)) !important;
    overflow: visible !important; box-sizing: border-box !important;
  }
  body .app aside.sidebar > div:nth-child(2) { display: block !important; width: 100% !important; min-width: 0 !important; }
  body .app aside.sidebar > .logo,
  body .app aside.sidebar .nav-label,
  body .app aside.sidebar .sidebar-bottom { display: none !important; }
  body .app aside.sidebar nav#nav {
    display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important; grid-auto-rows: 54px !important;
    gap: 2px !important; width: 100% !important; min-width: 0 !important;
    height: auto !important; max-height: none !important; overflow: visible !important;
    white-space: normal !important; transform: none !important;
  }
  body .app aside.sidebar nav#nav > button {
    display: flex !important; position: relative !important; float: none !important;
    width: 100% !important; min-width: 0 !important; max-width: 100% !important;
    height: 54px !important; min-height: 54px !important; margin: 0 !important;
    padding: 3px 2px !important; flex-direction: column !important;
    justify-content: center !important; align-items: center !important; gap: 3px !important;
    overflow: hidden !important; white-space: normal !important; transform: none !important;
    border-radius: 9px !important; font-size: 10px !important; line-height: 1.05 !important;
  }
  body .app aside.sidebar nav#nav > button .ico { display: block !important; flex: none !important; width: auto !important; font-size: 16px !important; line-height: 1 !important; }
  body .app aside.sidebar nav#nav > button .navtext {
    display: block !important; width: 100% !important; max-width: 100% !important;
    font-size: 9px !important; line-height: 1.05 !important; text-align: center !important;
    white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important;
  }
  body .app .content { padding-bottom: calc(188px + env(safe-area-inset-bottom)) !important; }
}

/* La navegación móvil solo aparece tras autenticarse y permanece fija durante el desplazamiento. */
@media screen and (max-width: 600px) {
  body:not(.authenticated) .app { display: none !important; }
  body:not(.authenticated) .app aside.sidebar { display: none !important; }
  body:not(.authenticated) #authGate { display: grid !important; }
  body.authenticated #authGate { display: none !important; }
  body.authenticated .app {
    display: block !important;
    width: 100% !important;
    min-height: 100vh;
    padding: 0 0 calc(188px + env(safe-area-inset-bottom)) !important;
  }
  body.authenticated .app aside.sidebar {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    z-index: 1000 !important;
    display: block !important;
    transform: none !important;
    transition: none !important;
    will-change: auto !important;
  }
  body.authenticated .app .content {
    padding-bottom: 28px !important;
  }
}
