/* Layout Styles (Linear / Plane 2026 SaaS Aesthetic) */

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

body {
  font-family: var(--font-family-base);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Navigation */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(53, 140, 203, 0.4));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-family-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--brand-primary);
  letter-spacing: 0.08em;
}

/* User Card in Sidebar */
.sidebar-user-card {
  margin: 0.85rem 0.85rem 0.4rem 0.85rem;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
}

.user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Navigation Items */
.sidebar-nav {
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  overflow-y: auto;
}

.nav-group-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 0.75rem 0.6rem 0.25rem 0.6rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(53, 140, 203, 0.18), rgba(27, 37, 90, 0.3));
  color: var(--text-primary);
  border-left: 3px solid var(--brand-primary);
  border-color: rgba(53, 140, 203, 0.35);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

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

.nav-label {
  flex: 1;
}

.nav-badge {
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.nav-badge.badge-warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-card-subtle);
}

.depot-indicator {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 4px;
}

.status-dot.online {
  background-color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.depot-text {
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
  line-height: 1.25;
}

.depot-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.depot-text small {
  color: var(--text-secondary);
  font-size: 0.65rem;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-app);
  height: 100vh;
  overflow-y: auto;
}

/* Top Header Bar */
.top-header {
  padding: 0.85rem 1.75rem;
  background-color: rgba(12, 16, 36, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-title-container {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-family: var(--font-family-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  cursor: pointer;
}

/* View Viewport Container */
.view-viewport {
  padding: 1.5rem 1.75rem;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
    /* Por encima de los panes de Leaflet (llegan a z 1000 dentro del mapa) */
    z-index: 1200;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .view-viewport {
    padding: 1rem;
  }
}

/* Teléfono: header compacto, sin subtítulo, drawer más angosto */
@media (max-width: 640px) {
  .top-header {
    padding: 0.65rem 0.9rem;
    gap: 0.5rem;
  }

  .page-title {
    font-size: 1.05rem;
  }

  .page-subtitle {
    display: none;
  }

  .sidebar {
    width: min(300px, 84vw);
  }

  .view-viewport {
    padding: 0.75rem;
  }
}
