/* ============================================================
   POOL BALANCE — LAYOUT SYSTEM
   App shell, sidebar, bottom nav, main content areas
   ============================================================ */

/* ═══════════════════════════════════════════
   BRAND TOPBAR — Mobile / Tablet (< 1024px)
   Logo + nombre siempre visible en portrait
═══════════════════════════════════════════ */

:root {
  --topbar-height: 80px;
}

.brand-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  /* Degradado: marino → cristal con acento coral en borde inferior */
  background: linear-gradient(105deg, #0E4569 0%, #1a6a96 60%, #0e5a7a 100%);
  border-bottom: 3px solid #E8664A;
  box-shadow: 0 3px 20px rgba(14, 69, 105, 0.35);
  display: flex;
  align-items: center;
  gap: 14px;
  padding-left: 18px;
  padding-right: 18px;
  z-index: 150;
  overflow: hidden;
}

/* Acento decorativo cristal — esquina derecha */
.brand-topbar::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(111,184,198,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.brand-topbar-logo {
  width: 46px;
  height: 46px;
  object-fit: cover;
  /* Círculo perfecto que integra el logo aunque tenga fondo blanco */
  border-radius: 50%;
  flex-shrink: 0;
  /* Borde cristal sutil */
  border: 2px solid rgba(111, 184, 198, 0.6);
  box-shadow: 0 0 0 3px rgba(111,184,198,0.18), 0 2px 10px rgba(0,0,0,0.25);
}

.brand-topbar-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-topbar-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

/* "Balance" en coral para el contraste de color */
.brand-topbar-name em {
  font-style: normal;
  color: #E8664A;
}

.brand-topbar-sub {
  font-size: 0.63rem;
  font-weight: 600;
  /* Cristal claro sobre el marino */
  color: rgba(111, 184, 198, 0.9);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════
   APP SHELL — Mobile First
═══════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100dvh;
  position: relative;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  min-height: 100dvh;
  padding-bottom: var(--bottom-nav-height);
  overflow-x: hidden;
  /* offset: safe area abajo + topbar arriba */
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
}

/* Contenedor de vistas */
#view-container {
  min-height: 100%;
}

/* ═══════════════════════════════════════════
   BOTTOM NAVIGATION — Mobile / Tablet
═══════════════════════════════════════════ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-nav);
  display: flex;
  align-items: stretch;
  z-index: var(--z-nav);
  /* Safe area iOS */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid rgba(14, 69, 105, 0.07);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-base);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  padding: 8px 4px;
}

.bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--color-arcilla);
  border-radius: 0 0 99px 99px;
  transition: width var(--transition-spring);
}

.bottom-nav-item.active {
  color: var(--color-marino);
}

.bottom-nav-item.active::before {
  width: 32px;
}

.bottom-nav-item.active .bottom-nav-icon {
  color: var(--color-arcilla);
  transform: translateY(-1px);
}

.bottom-nav-icon {
  font-size: 1.2rem;
  transition: transform var(--transition-spring), color var(--transition-base);
  display: block;
}

.bottom-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  font-family: 'Bricolage Grotesque', sans-serif;
}

/* ═══════════════════════════════════════════
   SIDEBAR — Desktop (lg: 1024px+)
═══════════════════════════════════════════ */

.sidebar {
  display: none; /* Hidden on mobile */
  width: var(--sidebar-width);
  min-height: 100dvh;
  background: #fff;
  box-shadow: var(--shadow-sidebar);
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  border-right: 1px solid rgba(14, 69, 105, 0.07);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 20px 20px;
  border-bottom: 1px solid rgba(14, 69, 105, 0.07);
  margin-bottom: 12px;
}

.sidebar-logo-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-marino);
  line-height: 1.1;
}

.sidebar-brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Nav links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.sidebar-link::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-marino-xlight);
  opacity: 0;
  border-radius: inherit;
  transition: opacity var(--transition-base);
}

.sidebar-link:hover::after { opacity: 1; }
.sidebar-link:hover { color: var(--color-marino); }

.sidebar-link.active {
  background: var(--color-marino);
  color: #fff;
}

.sidebar-link.active .sidebar-link-icon {
  color: var(--color-cristal);
}

.sidebar-link:hover.active::after { opacity: 0; }

.sidebar-link-icon {
  width: 18px;
  text-align: center;
  font-size: 0.9375rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.sidebar-link span {
  position: relative;
  z-index: 1;
}

/* CTA bottom sidebar */
.sidebar-cta {
  padding: 16px 12px 28px;
  border-top: 1px solid rgba(14, 69, 105, 0.07);
  margin-top: auto;
}

.sidebar-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 16px;
  background: var(--color-arcilla);
  color: #fff;
  border-radius: var(--radius-lg);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-btn);
}

.sidebar-cta-btn:hover {
  background: var(--color-arcilla-dark);
  transform: translateY(-1px);
}

.sidebar-cta-schedule {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ── Desktop breakpoint: mostrar sidebar, ocultar topbar + bottom nav ── */
@media (min-width: 1024px) {
  .brand-topbar {
    display: none;
  }

  .sidebar {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  .main-content {
    margin-left: var(--sidebar-width);
    padding-bottom: 0;
    /* Sin topbar en desktop: quitar el padding-top mobile */
    padding-top: 0;
  }

  .app-layout {
    padding-left: 0;
  }
}

/* ═══════════════════════════════════════════
   MODO SOLO PORTAL (portal-only)
   Oculta la navegación de los módulos aún no
   terminados (Inicio, Servicios, Biblioteca) y
   deja la app dedicada al Portal del Cliente.
═══════════════════════════════════════════ */

/* Móvil / tablet: sin barra inferior → recuperar el espacio */
body.portal-only .bottom-nav {
  display: none !important;
}

body.portal-only .main-content {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Escritorio: ocultar los enlaces de módulos del sidebar.
   Se conserva el logo y el CTA de WhatsApp. */
body.portal-only .sidebar-nav {
  display: none !important;
}

/* ═══════════════════════════════════════════
   PAGE / VIEW CONTAINERS
═══════════════════════════════════════════ */

.view-page {
  min-height: 100dvh;
  animation: fadeIn 0.35s ease both;
}

.page-section {
  padding: 40px 20px;
}

.page-section-lg {
  padding: 56px 20px;
}

@media (min-width: 768px) {
  .page-section { padding: 48px 32px; }
  .page-section-lg { padding: 72px 32px; }
}

@media (min-width: 1024px) {
  .page-section { padding: 56px 48px; }
  .page-section-lg { padding: 80px 56px; }
}

/* Ancho máximo del contenido en desktop */
.content-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* ═══════════════════════════════════════════
   GRIDS RESPONSIVOS
═══════════════════════════════════════════ */

.grid-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .grid-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-cards-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-cards-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ═══════════════════════════════════════════
   STICKY PAGE HEADER (para sub-navegación)
═══════════════════════════════════════════ */

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(238, 241, 245, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(14, 69, 105, 0.08);
  padding: 14px 20px;
}

@media (min-width: 1024px) {
  .sticky-header { padding: 14px 48px; }
}

/* ═══════════════════════════════════════════
   SAFE AREA UTILITIES
═══════════════════════════════════════════ */

.pb-safe {
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
}
