/**
 * Estructura de Layout Principal
 * Mobile-first: Barra inferior en móvil y sidebar en desktop.
 */

/* Contenedor principal de la aplicación */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  position: relative;
  overflow-x: hidden;
  background-color: var(--bg-app);
}

/* Envoltura del contenido principal */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Cabecera Superior */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.85rem;
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  box-sizing: border-box;
  gap: 0.5rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.brand-icon {
  width: 44px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--border-radius-sm);
  background: #0b0f17;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px 4px;
}

.brand-icon img,
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-text-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-accent {
  color: #ef4444;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Indicador de Estado de Red (Online / Offline) */
.header-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  padding: 0.32rem 0.65rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-pill);
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

#network-status-text {
  white-space: nowrap;
  display: inline-block;
}

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

.status-dot.offline {
  background-color: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

/* Contenido Principal */
.app-content {
  flex: 1;
  padding: 1rem 0.85rem;
  padding-bottom: calc(var(--nav-height-mobile) + env(safe-area-inset-bottom, 0px) + 2rem);
  max-width: 1400px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  min-width: 0;
}

/* Vistas de sección */
.view-section {
  display: none;
  width: 100%;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Barra de Navegación Inferior (Móvil) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  height: calc(var(--nav-height-mobile) + env(safe-area-inset-bottom, 0px));
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex !important;
  justify-content: space-around;
  align-items: stretch;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  backdrop-filter: blur(8px);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: var(--min-touch-target);
  color: var(--text-muted);
  gap: 0.2rem;
  transition: all var(--transition-fast);
  position: relative;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  box-sizing: border-box;
}

.nav-item:hover {
  color: var(--text-main);
  text-decoration: none;
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background-color: var(--color-brand);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 0 8px var(--color-brand);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 24px);
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: var(--border-radius-pill);
  background-color: var(--border-strong);
  color: var(--text-muted);
}

/* Sidebar para Desktop (oculto completamente en móvil) */
.sidebar {
  display: none !important;
}
