/* ==========================================================================
   DESKTOP SIDEBAR STYLES (UNCHANGED FROM ORIGINAL)
   ========================================================================== */

.sidebar-menu {
  display: flex;
  flex-direction: column;
  row-gap: var(--size-1);
  block-size: var(--size-full);
  background: var(--color-bg);
}

.sidebar-menu__button {
  --btn-background: transparent;
  --btn-border-color: transparent;
  --btn-box-shadow: none;
  --btn-font-weight: var(--font-normal);
  --btn-justify-content: start;
  --btn-outline-size: 0;
  --btn-inline-size: var(--size-full);
  --btn-padding: var(--size-1) var(--size-2);

  &[aria-current="page"],
  &:focus-visible {
    --btn-background: var(--color-border-light);
  }

  &:is(summary) {
    &::after {
      background-color: currentColor;
      block-size: var(--size-4);
      content: "";
      inline-size: var(--size-4);
      margin-inline-start: auto;
      mask-image: url("/assets/chevron-right-cefe893c.svg");
      mask-size: cover;
      min-inline-size: var(--size-4);
      transition: transform var(--time-200);
    }

    details[open] > &::after {
      transform: var(--rotate-90);
    }

    &::-webkit-details-marker {
      display: none;
    }
  }
}

.sidebar-menu__content {
  display: flex;
  flex-direction: column;
  row-gap: var(--size-4);
  overflow-y: scroll;
}

.sidebar-menu__group {
  display: flex;
  flex-direction: column;
}

.sidebar-menu__group-label {
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  padding: var(--size-1_5) var(--size-2);
}

.sidebar-menu__items {
  display: flex;
  flex-direction: column;
  row-gap: var(--size-1);
}

.sidebar-menu__sub {
  border-inline-start-width: var(--border);
  display: flex;
  flex-direction: column;
  margin-inline-start: var(--size-4);
  padding: var(--size-0_5) var(--size-2);
  row-gap: var(--size-1);
}

/* ==========================================================================
   MOBILE DRAWER FOUNDATION - FIXED
   ========================================================================== */

.mobile-bottom-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  pointer-events: none;

  &.open {
    pointer-events: auto;
  }
}

/* Backdrop - FIXED */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--time-300) ease, visibility var(--time-300) ease;
  z-index: 998; /* Lower than drawer content */

  &.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

/* Main drawer container - FIXED */
.mobile-drawer {
  position: relative;
  background: var(--color-bg);
  border-top: var(--border) solid var(--color-border);
  box-shadow: 0 -8px 25px -5px rgba(0, 0, 0, 0.1), 0 -10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(calc(100% - 80px));
  transition: transform var(--time-300) cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  pointer-events: auto;
  z-index: 999; /* Higher than backdrop */

  &.open {
    transform: translateY(0);

    .drawer-arrow {
      transform: rotate(180deg);
    }
  }
}

/* ==========================================================================
   MOBILE DRAWER TRIGGER - FIXED
   ========================================================================== */

.mobile-drawer-trigger {
  width: 100%;
  border: none;
  padding: var(--size-4) var(--size-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  touch-action: manipulation;
  cursor: pointer;
  transition: all var(--time-200) ease;
  min-height: 80px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  background: var(--color-bg);
  color: inherit;
  position: relative;
  z-index: 1001; /* Always clickable */

  &:hover {
    transform: translateY(-1px);
  }

  &:active {
    transform: translateY(0);
  }
}

.trigger-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--size-3);
}

.trigger-main {
  display: flex;
  align-items: center;
  gap: var(--size-3);
  flex: 1;
  min-width: 0;
}

.trigger-icon {
  font-size: var(--text-xl);
  line-height: 1;
}

.trigger-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  min-width: 0;
  flex: 1;
}

.trigger-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
}

.drawer-arrow {
  font-size: var(--text-lg);
  transition: transform var(--time-300) ease;
  flex-shrink: 0;
  margin-left: var(--size-2);
}

/* ==========================================================================
   SHARED TEXT ELEMENTS (FROM ORIGINAL)
   ========================================================================== */

.warp-location {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.warp-details {
  font-size: var(--text-xs);
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.warp-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  opacity: 0.9;
  line-height: 1;
}

.warp-points {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1;
  margin-top: var(--size-0_5);
}

/* ==========================================================================
   MOBILE DRAWER CONTENT - FIXED
   ========================================================================== */

.mobile-drawer-content {
  overflow-y: auto;
  max-height: calc(90vh - 80px);
  padding: var(--size-4);
  background: var(--color-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  position: relative;
  z-index: 1000; /* Ensure content is clickable */
  pointer-events: auto; /* Allow all interactions */

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--color-border);
  }
}

.mobile-sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: var(--size-4);
}

/* ==========================================================================
   MOBILE INTERFACE COMPONENTS - FIXED
   ========================================================================== */

/* Warp Button */
.mobile-warp-button {
  --btn-background: var(--color-surface);
  --btn-border-color: var(--color-border);
  --btn-padding: var(--size-3);
  --btn-justify-content: space-between;
  display: flex;
  align-items: center;
  width: 100%;
  pointer-events: auto; /* Ensure clickable */
}

.warp-info {
  display: flex;
  align-items: center;
  gap: var(--size-3);
  flex: 1;
  min-width: 0;
}

.warp-symbol {
  font-size: var(--text-xl);
  flex-shrink: 0;
}

.warp-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.warp-location-text {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
}

.warp-net-text {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.warp-points-info {
  flex-shrink: 0;
}

.points-value {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

/* Score Panel */
.mobile-score-panel {
  --btn-background: var(--color-surface);
  --btn-border-color: var(--color-border);
  --btn-padding: var(--size-3);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  pointer-events: auto; /* Ensure clickable */
}

.score-header {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  margin-bottom: var(--size-2);
  text-align: center;
  color: var(--color-text-subtle);
}

/* ==========================================================================
   STATISTICS AND PROGRESS BARS WITH HP COLORS
   ========================================================================== */

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--size-2);
}

.stat-item--with-bar {
  display: flex;
  align-items: center;
  gap: var(--size-2);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-subtle);
  min-width: var(--size-8);
  flex-shrink: 0;
}

.stat-value {
  font-weight: var(--font-medium);
  font-family: 'Hack', monospace;
  min-width: var(--size-8);
  flex-shrink: 0;
  text-align: center;
}

/* ==========================================================================
   SIDEBAR PROGRESS BAR STYLES WITH NEW HP COLORS
   ========================================================================== */

.stat-progress {
  height: var(--size-1_5);
  flex: 1;
  min-width: var(--size-16);
  border: 1px solid #777;
  background: #3a3a3a;
  appearance: none;
  position: relative;
  overflow: hidden;

  &::-webkit-progress-bar {
    background: #3a3a3a;
  }

  &::-webkit-progress-value {
    background: rgba(187,187,187,0.12);
    transition: background-color var(--time-300) ease;
  }

  &::-moz-progress-bar {
    background: rgba(187,187,187,0.12);
    transition: background-color var(--time-300) ease;
  }
}

/* Critical (0-30%) - Red */
.stat-progress.hp-0,
.stat-progress.hp-10,
.stat-progress.hp-20,
.stat-progress.hp-30 {
  border-color: #cc4444;
  background: #5a1a1a;

  &::-webkit-progress-bar {
    background: #5a1a1a;
  }

  &::-webkit-progress-value {
    background: rgba(255,136,136,0.35);
  }

  &::-moz-progress-bar {
    background: rgba(255,136,136,0.35);
  }
}

/* Warning (40-60%) - Yellow */
.stat-progress.hp-40,
.stat-progress.hp-50,
.stat-progress.hp-60 {
  border-color: #cccc44;
  background: #4a4a1a;

  &::-webkit-progress-bar {
    background: #4a4a1a;
  }

  &::-webkit-progress-value {
    background: rgba(221,221,136,0.35);
  }

  &::-moz-progress-bar {
    background: rgba(221,221,136,0.35);
  }
}

/* Partial (70-90%) - Green */
.stat-progress.hp-70,
.stat-progress.hp-80,
.stat-progress.hp-90 {
  border-color: #44cc44;
  background: #1a4a1a;

  &::-webkit-progress-bar {
    background: #1a4a1a;
  }

  &::-webkit-progress-value {
    background: rgba(136,221,136,0.35);
  }

  &::-moz-progress-bar {
    background: rgba(136,221,136,0.35);
  }
}

/* Full (100%) - Gray */
.stat-progress.hp-100 {
  border-color: #777;
  background: #3a3a3a;

  &::-webkit-progress-bar {
    background: #3a3a3a;
  }

  &::-webkit-progress-value {
    background: rgba(187,187,187,0.12);
  }

  &::-moz-progress-bar {
    background: rgba(187,187,187,0.12);
  }
}

/* ==========================================================================
   ACTION COMPONENTS - FIXED
   ========================================================================== */

.mobile-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--size-2);
}

.mobile-action-btn {
  --btn-background: var(--color-surface);
  --btn-border-color: var(--color-border);
  --btn-padding: var(--size-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--size-1);
  text-align: center;
  min-height: var(--size-16);
  pointer-events: auto; /* Ensure clickable */
}

.action-icon {
  font-size: var(--text-xl);
  line-height: 1;
}

.action-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.mobile-context-actions {
  margin-top: var(--size-2);
}

.mobile-dewarp-btn {
  --btn-padding: var(--size-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--size-2);
  width: 100%;
  pointer-events: auto; /* Ensure clickable */
}

.mobile-citadel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--size-2);
}

/* ==========================================================================
   FAMILIAR STATUS COMPONENT
   ========================================================================== */

.mobile-familiar-status {
  --border-color: var(--color-border);
  border: var(--border) solid var(--border-color);
  padding: var(--size-3);
  background: var(--color-surface);
}

.familiar-header {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  margin-bottom: var(--size-3);
  text-align: center;
  color: var(--color-text-subtle);
}

.familiar-stats {
  display: flex;
  flex-direction: column;
  gap: var(--size-2);
}

.familiar-stat {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
}

.familiar-info {
  margin-top: var(--size-2);
}

.info-line {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  margin-bottom: var(--size-1);
}

.info-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-subtle);
  min-width: var(--size-12);
}

/* ==========================================================================
   USER MENU COMPONENT - FIXED
   ========================================================================== */

.mobile-user-menu {
  --border-color: var(--color-border);
  border: var(--border) solid var(--border-color);
  padding: var(--size-3);
  background: var(--color-surface);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--size-3);
  margin-bottom: var(--size-3);
  padding-bottom: var(--size-3);
  border-bottom: var(--border) solid var(--color-border-light);
}

.user-avatar {
  font-size: var(--text-xl);
  line-height: 1;
}

.user-details {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.user-name {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
}

.user-title {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.user-actions {
  display: flex;
  gap: var(--size-2);
}

.mobile-user-action {
  --btn-background: transparent;
  --btn-border-color: var(--color-border);
  --btn-padding: var(--size-2);
  display: flex;
  align-items: center;
  gap: var(--size-2);
  flex: 1;
  justify-content: center;
  pointer-events: auto; /* Ensure clickable */
}

/* ==========================================================================
   BODY AND LAYOUT STATES (UNCHANGED FROM ORIGINAL)
   ========================================================================== */

body.drawer-open {
  overflow: hidden;
}

body.sidebar-layout {
  padding-bottom: 90px;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (UNCHANGED FROM ORIGINAL)
   ========================================================================== */

@media (min-width: 768px) {
  .mobile-bottom-drawer {
    display: none;
  }

  body.sidebar-layout {
    padding-bottom: 0;
  }
}
