/* ========================================
   GM Sidebar - Base Structure
   ======================================== 
   Core layout, window styling, tabs, navigation, badges
   ======================================== */

/* StoryFrame GM Sidebar Styles - Drawer Mode */

/* Drawer window styling */
.storyframe.gm-sidebar.drawer {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-left: none !important;
  box-shadow:
    4px 0 20px rgba(0, 0, 0, 0.3),
    -2px 0 10px rgba(0, 0, 0, 0.2) !important;
  /* Override Foundry core max-height constraint to allow full journal height */
  max-height: none !important;
}

/* Hide resize handle for drawer */
.storyframe.gm-sidebar.drawer .window-resize-handle {
  display: none;
}

/* Disable dragging on drawer header */
.storyframe.gm-sidebar.drawer .window-header {
  cursor: default !important;
  -webkit-app-region: no-drag;
}

.storyframe.gm-sidebar.drawer .window-header .window-title {
  cursor: default !important;
}

/* Slide animations removed - were causing positioning issues */

/* Compact header for drawer */
.storyframe.gm-sidebar.drawer .window-header {
  padding: var(--sf-space-xs) var(--sf-space-sm);
  min-height: unset;
}

.storyframe.gm-sidebar.drawer .window-title {
  font-size: var(--sf-font-sm);
}

/* Prevent flash/animation on re-render */
.storyframe.gm-sidebar,
.storyframe.gm-sidebar *,
.storyframe.gm-sidebar .window-content,
.storyframe.gm-sidebar .gm-sidebar-container {
  animation: none !important;
  animation-duration: 0s !important;
}

/* Ensure content is always visible */
.storyframe.gm-sidebar .window-content,
.storyframe.gm-sidebar .window-content > *,
.storyframe.gm-sidebar .gm-sidebar-container,
.storyframe.gm-sidebar .gm-sidebar-container > * {
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}

.gm-sidebar-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  gap: 0;
  background: var(--color-bg-sidebar);
  color: var(--color-text-light-primary);
  overflow: hidden;
  /* Prevent content flash */
  animation: none !important;
}

/* Tab Navigation */
.gm-sidebar .tab-navigation {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.storyframe.gm-sidebar .tab-btn {
  flex: 1;
  padding: 10px 6px;
  background: transparent !important;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--sf-text-secondary);
  font-size: 11px;
  font-weight: 600;
  position: relative;
  box-shadow: none !important;
  outline: none !important;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.storyframe.gm-sidebar .tab-btn:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--sf-text-primary);
  box-shadow: none !important;
  outline: none !important;
}

.storyframe.gm-sidebar .tab-btn.active {
  background: transparent !important;
  border-bottom-color: var(--sf-accent-primary);
  color: var(--sf-text-primary);
  box-shadow: none !important;
  outline: none !important;
}

.storyframe.gm-sidebar .tab-btn:focus {
  outline: none !important;
  box-shadow: none !important;
}

.storyframe.gm-sidebar .tab-btn i {
  font-size: 13px;
}

/* Tab Badges - matches player sidebar design */
.storyframe.gm-sidebar .tab-badge {
  background: var(--sf-accent-warning);
  color: #2e3440;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  animation: badge-pulse 2s ease-in-out infinite;
  margin-left: 4px;
}

.storyframe.gm-sidebar .tab-badge.active-badge {
  background: var(--sf-accent-primary);
  color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

@keyframes badge-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* Tab Content */
.gm-sidebar .tab-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gm-sidebar .tab-content > section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gm-sidebar .tab-content > section.hidden {
  display: none;
}

.gm-sidebar .tab-scroll-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sf-space-sm) var(--sf-space-md);
}

.gm-sidebar .tab-header-actions {
  padding: var(--sf-space-sm) var(--sf-space-md);
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
}

.gm-sidebar .tab-header-actions button {
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--sf-accent-primary), rgba(94, 129, 172, 0.8));
  border: 1px solid rgba(94, 129, 172, 0.6);
  border-radius: var(--sf-radius-md);
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.gm-sidebar .tab-header-actions button:hover {
  background: linear-gradient(135deg, var(--sf-accent-primary-hover), var(--sf-accent-primary));
  border-color: var(--sf-accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(94, 129, 172, 0.5);
}

.gm-sidebar .tab-header-actions button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.gm-sidebar .tab-header-actions button i {
  font-size: 13px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.gm-sidebar .tab-header-actions button.danger {
  background: linear-gradient(135deg, rgba(191, 97, 106, 0.9), rgba(191, 97, 106, 0.7));
  border-color: rgba(191, 97, 106, 0.6);
}

.gm-sidebar .tab-header-actions button.danger:hover {
  background: linear-gradient(135deg, rgba(191, 97, 106, 1), rgba(191, 97, 106, 0.9));
  border-color: rgba(191, 97, 106, 0.8);
  box-shadow: 0 4px 12px rgba(191, 97, 106, 0.5);
}

.gm-sidebar .tab-header-actions button.btn-broadcast {
  background: linear-gradient(135deg, rgba(163, 120, 48, 0.9), rgba(198, 155, 68, 0.7));
  border-color: rgba(198, 155, 68, 0.6);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 8px rgba(198, 155, 68, 0.15);
}

.gm-sidebar .tab-header-actions button.btn-broadcast:hover {
  background: linear-gradient(135deg, rgba(198, 155, 68, 1), rgba(163, 120, 48, 0.9));
  border-color: rgba(198, 155, 68, 0.85);
  box-shadow: 0 4px 12px rgba(198, 155, 68, 0.45);
}

.gm-sidebar .tab-header-actions button.btn-broadcast.active {
  box-shadow: 0 2px 8px rgba(198, 155, 68, 0.5), 0 0 12px rgba(198, 155, 68, 0.3);
  border-color: rgba(198, 155, 68, 0.9);
}

.gm-sidebar .tab-header-actions button.btn-player-broadcast.active {
  background: linear-gradient(135deg, rgba(163, 120, 48, 0.9), rgba(198, 155, 68, 0.7));
  border-color: rgba(198, 155, 68, 0.6);
  box-shadow: 0 2px 8px rgba(198, 155, 68, 0.5), 0 0 12px rgba(198, 155, 68, 0.3);
}

.gm-sidebar .tab-header-actions .grid-lock-toggle {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  padding: 6px 8px;
}

.gm-sidebar .tab-header-actions .grid-lock-toggle.active {
  background: rgba(94, 129, 172, 0.3);
  border-color: rgba(94, 129, 172, 0.5);
}

.gm-sidebar .tab-header-actions .grid-lock-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Only show grid lock in standalone mode */
.gm-sidebar.drawer .tab-header-actions .grid-lock-toggle {
  display: none;
}

/* Grid size slider — wraps to own row below action buttons */
.gm-sidebar .tab-header-actions .grid-size-slider-wrapper {
  flex-basis: 100%;
  order: 99;
  padding: 2px 0;
}

.gm-sidebar .tab-header-actions .grid-size-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.gm-sidebar .tab-header-actions .grid-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sf-accent-primary);
  border: 2px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

.gm-sidebar .tab-header-actions .grid-size-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sf-accent-primary);
  border: 2px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

/* Hidden name indicators */
.speaker-hidden-badge {
  position: absolute !important;
  bottom: 32px !important;
  right: 6px !important;
  top: auto !important;
  left: auto !important;
  font-size: 0.7em;
  background: rgba(0, 0, 0, 0.85);
  padding: 3px 5px;
  border-radius: 3px;
  color: #fff;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.participant-hidden-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 0.7em;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px;
  border-radius: 2px;
  color: white;
  pointer-events: none;
}

.participant-token.name-hidden {
  border: 1px dashed var(--color-border-light-tertiary);
}

