/* ============================================
   HELP DRAWER - Contextual help side panel
   ============================================ */

/* Help toggle button — sits in the nav tab bar */
.help-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  border: none;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--info);
  color: var(--text-inverse);
  margin-left: auto;
  align-self: center;
  white-space: nowrap;
}

.help-toggle-btn:hover {
  background: var(--info-bg);
  color: var(--info);
  outline: 1px solid var(--info);
}

.help-toggle-btn.active {
  background: var(--info-bg);
  color: var(--info);
  outline: 1px solid var(--info);
}

/* Tab layout wrapper when drawer is open */
#dashboard-tab .stats-container,
#analytics-tab .stats-container,
#planning-tab .stats-container,
#reports-tab .stats-container,
#todos-tab .todos-container {
  display: flex;
  transition: all var(--transition-slow);
}

#dashboard-tab .stats-container .dashboard-main-content,
#analytics-tab .stats-container .dashboard-main-content,
#planning-tab .stats-container .dashboard-main-content,
#reports-tab .stats-container .dashboard-main-content,
#todos-tab .todos-container .dashboard-main-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Help Drawer Panel */
.help-drawer {
  width: 0;
  overflow: hidden;
  background: var(--bg-elevated);
  border-left: none;
  transition: width var(--transition-slow), padding var(--transition-slow);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.help-drawer.open {
  width: 340px;
  padding: 16px;
}

/* Drawer header */
.help-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.help-drawer-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--info);
}

.help-drawer-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.help-drawer-close:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

/* Search input */
.help-drawer-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--bg-subtle);
  color: var(--text);
  margin-bottom: 16px;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.help-drawer-search:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Scrollable content area */
.help-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* Section headers */
.help-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
  margin: 16px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.help-section:first-child .help-section-title {
  margin-top: 0;
}

/* Individual help entries */
.help-entry {
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  cursor: default;
}

.help-entry:hover {
  background: var(--bg-subtle);
}

.help-entry.highlighted {
  border-left-color: var(--info);
  background: var(--info-bg);
  animation: help-flash 1.5s ease;
}

@keyframes help-flash {
  0% { background: rgba(14, 165, 233, 0.2); }
  100% { background: var(--info-bg); }
}

.help-entry-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.help-entry-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.help-entry-formula {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  display: block;
  line-height: 1.4;
}

.help-entry-thresholds {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 6px;
  padding: 4px 0;
  line-height: 1.5;
}

/* Reverse-highlight: flash dashboard element when clicking a help entry */
.help-highlight {
  outline: 3px solid var(--info) !important;
  outline-offset: 4px;
  animation: dashboard-pulse 2.5s ease;
  position: relative;
  z-index: 1;
  border-radius: var(--radius-md);
}

@keyframes dashboard-pulse {
  0%   { transform: scale(1);    outline-color: var(--info); box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.5);  }
  8%   { transform: scale(1.02);  box-shadow: 0 0 20px 8px rgba(14, 165, 233, 0.35); }
  16%  { transform: scale(1);     box-shadow: 0 0 8px 3px rgba(14, 165, 233, 0.2);  }
  30%  { transform: scale(1.015); box-shadow: 0 0 18px 6px rgba(14, 165, 233, 0.3);  }
  44%  { transform: scale(1);     box-shadow: 0 0 6px 2px rgba(14, 165, 233, 0.15); }
  60%  { box-shadow: 0 0 14px 5px rgba(14, 165, 233, 0.25); }
  80%  { box-shadow: 0 0 6px 2px rgba(14, 165, 233, 0.1);  }
  100% { outline-color: transparent; box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

/* Hidden entries (search filter) */
.help-entry.hidden,
.help-section.hidden {
  display: none;
}

/* Mobile: full-width overlay */
@media (max-width: 768px) {
  .help-drawer.open {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    border-left: none;
    border-radius: 0;
    padding: 16px;
  }

  .help-drawer-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
  }

  .help-drawer-backdrop.active {
    display: block;
  }
}
