/* Navigation Rail Component - Material Design 3 */
.navigation-rail {
  position: fixed;
  top: 64px; /* Below toolbar */
  right: 0;
  bottom: 0;
  width: var(--md-nav-rail-width); /* Responsive width */
  z-index: 1000;
  background: linear-gradient(to bottom,
    var(--md-sys-color-surface-container, var(--mat-sys-surface-container)) 0%,
    color-mix(in srgb, var(--md-sys-color-tertiary) 12%, var(--md-sys-color-surface-container, var(--mat-sys-surface-container)) 88%) 100%
  );
  border-left: 1px solid var(--md-sys-color-outline-variant, var(--mat-sys-outline-variant));
  display: flex;
  flex-direction: column;
}

.nav-rail-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px; /* Material Design 3 spacing */
}

.nav-rail-item {
  width: 100%;
  display: flex;
  justify-content: center;
}

.nav-rail-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px; /* Increased for better label space */
  height: 64px; /* Increased height for better text layout */
  min-height: 64px;
  border: none;
  border-radius: 16px; /* Material Design 3 container shape */
  background-color: transparent;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
  padding: 8px 4px;
  
  /* Focus indicator */
  outline: none;
  
  /* State layer container */
  overflow: hidden;
}

/* ===== MATERIAL DESIGN 3 STATE LAYERS ===== */
/* Navigation rail buttons with proper state layer implementation */

/* State layer base setup */
.nav-rail-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  background-color: var(--md-sys-color-on-surface, var(--mat-sys-on-surface));
  opacity: 0;
  transition: opacity var(--md-sys-state-transition-duration) var(--md-sys-state-transition-easing);
  pointer-events: none;
  z-index: 1;
}

/* Hover state layer */
.nav-rail-button:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

/* Focus state layer and ring */
.nav-rail-button:focus-visible::before {
  opacity: var(--md-sys-state-focus-opacity);
}

.nav-rail-button:focus-visible {
  outline: var(--md-sys-state-focus-ring-width, 2px) solid var(--md-sys-color-primary, var(--mat-sys-primary));
  outline-offset: var(--md-sys-state-focus-ring-offset, 2px);
}

/* Pressed state layer */
.nav-rail-button:active::before {
  opacity: var(--md-sys-state-pressed-opacity);
}

/* Selected/Active state layer */
.nav-rail-button[aria-expanded="true"]::before,
.nav-rail-button.active::before {
  background-color: var(--md-sys-color-on-secondary-container, var(--mat-sys-on-secondary-container));
  opacity: var(--md-sys-state-selected-opacity);
}

.nav-rail-button-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-rail-icon {
  font-size: var(--md-sys-typescale-headline-small-font-size);
  width: 24px;
  height: 24px;
  color: var(--md-sys-color-on-surface-variant, var(--mat-sys-on-surface-variant));
  transition: color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.nav-rail-status-indicator {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: var(--md-sys-typescale-body-small-font-size) !important;
  width: 12px !important;
  height: 12px !important;
  background-color: var(--md-sys-color-surface, var(--mat-sys-surface));
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 0 0 1px var(--md-sys-color-surface, var(--mat-sys-surface));
}

.nav-rail-label {
  font-family: var(--md-sys-typescale-font-family-plain);
  font-size: var(--md-sys-typescale-label-small-font-size);
  font-weight: var(--md-sys-typescale-label-small-font-weight);
  line-height: var(--md-sys-typescale-label-small-line-height);
  letter-spacing: var(--md-sys-typescale-label-small-letter-spacing);
  color: var(--md-sys-color-on-surface-variant, var(--mat-sys-on-surface-variant));
  margin-top: 2px;
  text-align: center;
  width: 100%;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
  box-sizing: border-box;
}

/* Status indicator colors - using semantic tokens */
.status-green {
  color: var(--md-sys-color-chat-connected);
}

.status-red {
  color: var(--md-sys-color-chat-disconnected);
}

.status-orange {
  color: var(--md-sys-color-chat-pending);
}

/* Selected/Active state (when sidenav is open) */
.nav-rail-button[aria-expanded="true"],
.nav-rail-button.active {
  background-color: var(--md-sys-color-secondary-container, var(--mat-sys-secondary-container));
}

.nav-rail-button[aria-expanded="true"] .nav-rail-icon,
.nav-rail-button.active .nav-rail-icon {
  color: var(--md-sys-color-on-secondary-container, var(--mat-sys-on-secondary-container));
}

.nav-rail-button[aria-expanded="true"] .nav-rail-label,
.nav-rail-button.active .nav-rail-label {
  color: var(--md-sys-color-on-secondary-container, var(--mat-sys-on-secondary-container));
}

/* Responsive breakpoints using Material Design 3 adaptive tokens */

/* Medium screens (600-839px) - Compact rail */
@media (min-width: 600px) and (max-width: 839px) {
  .nav-rail-button {
    width: 64px;
    height: 56px;
    border-radius: 12px;
  }

  .nav-rail-icon {
    font-size: var(--md-sys-typescale-title-large-font-size);
    width: 20px;
    height: 20px;
  }

  .nav-rail-label {
    font-size: var(--md-sys-typescale-label-small-font-size);
    line-height: 11px;
    max-width: 72px;
  }
}

/* Hide on compact screens (mobile) - use bottom navigation instead */
@media (max-width: 599px) {
  .navigation-rail {
    display: none;
  }
}

/* Dark mode enhancements for better contrast */
@media (prefers-color-scheme: dark) {
  .nav-rail-label {
    color: var(--md-sys-color-on-surface);
  }

  .nav-rail-icon {
    color: var(--md-sys-color-on-surface);
  }

  .navigation-rail {
    border-left-color: var(--md-sys-color-outline);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .navigation-rail {
    border-left-width: 2px;
  }

  .nav-rail-button:focus-visible {
    box-shadow: 0 0 0 3px var(--md-sys-color-primary, var(--mat-sys-primary));
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .nav-rail-button,
  .nav-rail-icon {
    transition: none;
  }
}