/* Estructura general de la app (header, sidebar, bottom nav y contenedor principal) */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-family-base);
  font-size: 16px;
  line-height: var(--line-height-base);
  color: var(--color-brand-slate-text);
  background-color: var(--color-brand-bg-light);
  min-height: 100vh;
  width: 100%;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Contenedor principal de la app */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  padding-top: var(--header-height);
}

/* Header fijo superior */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 50;
  background-color: var(--color-brand-navy);
  color: #FFFFFF;
  box-shadow: var(--shadow-md);
  padding: 0;
}

/* Barra superior del header */
.header-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.85rem;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #FFFFFF;
  flex-shrink: 0;
  min-width: 0;
}

.header-logo {
  width: 36px;
  height: 36px;
  background: var(--color-brand-emerald);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #FFFFFF;
  flex-shrink: 0;
}

.header-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-app-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
}

.header-zone-tag {
  font-size: 0.72rem;
  color: #93C5FD;
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
}

/* Acciones del header */
.header-top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  padding-right: 0.2rem;
}

/* Indicador de conexión a internet */
.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  min-height: 36px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  transition: var(--transition-fast);
  touch-action: manipulation;
}

.network-badge:hover {
  background: rgba(255, 255, 255, 0.2);
}

.network-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--color-semantic-success);
  box-shadow: 0 0 8px var(--color-semantic-success);
  flex-shrink: 0;
}

.network-badge.offline .network-dot {
  background-color: var(--color-semantic-danger);
  box-shadow: 0 0 8px var(--color-semantic-danger);
}

/* Botón de notificaciones y acciones */
.btn-header-action {
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: var(--radius-md);
  color: #FFFFFF;
  cursor: pointer;
  transition: var(--transition-fast);
  touch-action: manipulation;
  box-sizing: border-box;
}

.btn-header-action:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-header-action:active {
  transform: scale(0.95);
}

.btn-header-action:focus-visible {
  outline: 3px solid #6EE7B7;
}

.notification-pill {
  position: absolute;
  top: 3px;
  right: 3px;
  background-color: var(--color-semantic-danger);
  color: #FFFFFF;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-brand-navy);
}

/* Ajustes de header para pantallas pequeñas */
@media (max-width: 520px) {
  .header-top-bar {
    padding: 0 0.5rem;
  }
  .header-brand {
    gap: 0.45rem;
  }
  .header-logo {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .header-app-title {
    font-size: 0.95rem;
  }
  .header-zone-tag {
    font-size: 0.65rem;
  }
  .header-top-actions {
    gap: 0.35rem;
    padding-right: 0;
  }
  .network-badge {
    padding: 0;
    width: 36px;
    height: 36px;
    min-width: 36px;
    justify-content: center;
    border-radius: 50%;
  }
  .network-label-text {
    display: none;
  }
  .btn-header-action {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }
}

@media (max-width: 360px) {
  .header-zone-tag {
    display: none;
  }
}

/* Contenido principal */
.app-body {
  display: flex;
  align-items: flex-start;
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.app-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 1rem 0.75rem 5rem 0.75rem; /* Margen inferior para Bottom Nav en móviles */
}

/* Barra de navegación inferior (móvil) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 35;
  background: #FFFFFF;
  border-top: 1px solid var(--color-brand-border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
  width: 100%;
  box-sizing: border-box;
}

.bottom-nav-item {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target-min);
  padding: 0.25rem 0.15rem;
  color: var(--color-brand-muted-text);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  touch-action: manipulation;
  box-sizing: border-box;
  text-align: center;
}

.bottom-nav-item span {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.68rem;
  line-height: 1.2;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--color-brand-navy);
  font-weight: 700;
}

.bottom-nav-item.active .nav-icon-wrap {
  color: var(--color-brand-emerald);
}

.nav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  flex-shrink: 0;
}

/* Menú lateral (tablets y escritorio) */
.app-sidebar {
  display: none;
  width: 240px;
  background: #FFFFFF;
  border-right: 1px solid var(--color-brand-border);
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-brand-muted-text);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.sidebar-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--color-brand-muted-text);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
}

.sidebar-nav-item:hover {
  background-color: var(--color-brand-surface-subtle);
  color: var(--color-brand-navy);
}

.sidebar-nav-item.active {
  background-color: #EFF6FF;
  color: var(--color-brand-navy);
  border-color: #BFDBFE;
  font-weight: 700;
}

.sidebar-nav-icon {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.sidebar-nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  display: block;
}

@media (min-width: 768px) {
  .app-sidebar {
    display: block;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    align-self: flex-start;
    overflow-y: auto;
  }
  .bottom-nav {
    display: none;
  }
  .app-main {
    min-height: calc(100vh - var(--header-height));
    padding-bottom: 2rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

