/* ========================================
   Help Drawer — shared styles for GEX Studio and Dashboard.
   Extracted from gex-components.css so both pages can use the
   same searchable help drawer without loading the full component CSS.

   Theme variable mapping: the drawer uses --theme-* vars from gex-components.
   Dashboard maps them from Bootstrap --bs-* vars via the fallback scope below.
   ======================================== */

/* --- Fallback: map --bs-* to --theme-* for pages without themes.css --- */
.help-drawer {
    --theme-bg-secondary: var(--bs-body-bg, #161b22);
    --theme-bg-primary: var(--bs-tertiary-bg, #1a1a2e);
    --theme-text-primary: var(--bs-body-color, #e6edf3);
    --theme-text-secondary: var(--bs-secondary-color, #8b949e);
    --theme-border-color: var(--bs-border-color, #30363d);
    --theme-border-subtle: rgba(128,128,128,0.15);
    --theme-accent-color: #0d6efd;
    --theme-help-expanded-bg: rgba(128,128,128,0.06);
    --theme-help-expanded-border: #58a6ff;
    --theme-help-expanded-title: #58a6ff;
}

/* --- Offcanvas Override --- */
.help-drawer {
    width: 380px;
    border-left: 1px solid var(--theme-border-color, #dee2e6);
    background-color: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
    z-index: 10050;
}

.help-drawer-header {
    border-bottom: 1px solid var(--theme-border-color, #dee2e6);
    padding: 16px 20px;
    background-color: var(--theme-bg-secondary);
}

.help-drawer-header .offcanvas-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.help-drawer-body {
    padding: 16px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Search Input --- */
.help-search-container .form-control {
    background-color: var(--theme-bg-primary);
    border-color: var(--theme-border-color);
    color: var(--theme-text-primary);
    font-size: 0.875rem;
}

.help-search-container .form-control::placeholder {
    color: var(--theme-text-secondary);
}

.help-search-container .form-control:focus {
    border-color: var(--theme-accent-color, #0d6efd);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* --- Category Accordion --- */
.help-accordion {
    margin-top: 4px;
}

.help-category {
    margin-bottom: 2px;
}

.help-category-header {
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.15));
    user-select: none;
    transition: opacity 0.15s;
}

.help-category-header:hover {
    opacity: 0.8;
}

.help-category-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.help-category-label {
    flex: 1;
}

.help-category-count {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 6px;
}

.help-category-chevron {
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    flex-shrink: 0;
}

/* --- Category Body (entries container) --- */
.help-category-body {
    padding-left: 12px;
    border-left: 2px solid var(--theme-border-subtle, rgba(128,128,128,0.18));
    margin-left: 6px;
}

/* --- Entry Card --- */
.help-entry,
.help-search-result {
    padding: 8px 0;
    border-bottom: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.1));
    cursor: pointer;
    transition: background-color 0.15s;
}

.help-entry:last-child,
.help-search-result:last-child {
    border-bottom: none;
}

.help-entry:hover,
.help-search-result:hover {
    background-color: rgba(128,128,128,0.05);
}

.help-entry-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--theme-text-primary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-entry-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Marker color classes for inline text references */
.mk-pos  { color: #28a745; font-weight: 600; }
.mk-neg  { color: #dc3545; font-weight: 600; }
.mk-abs  { color: #6c00cd; font-weight: 600; }
.mk-flip { color: #ff00ff; font-weight: 600; }
.mk-mp   { color: #007bff; font-weight: 600; }
.mk-gc   { color: #ff8c00; font-weight: 600; }

.help-entry-summary {
    font-size: 0.8rem;
    color: var(--theme-text-secondary);
    margin-bottom: 0;
    line-height: 1.4;
}

.help-entry-body {
    display: none;
    font-size: 0.8rem;
    color: var(--theme-text-primary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.1));
    line-height: 1.5;
}

.help-entry-body p {
    margin-bottom: 8px;
}

.help-entry-body ul {
    padding-left: 18px;
    margin-bottom: 8px;
}

.help-entry-body li {
    margin-bottom: 4px;
}

.help-entry-body kbd {
    background-color: rgba(128,128,128,0.15);
    border: 1px solid rgba(128,128,128,0.3);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.8em;
    font-family: monospace;
}

.help-entry.expanded .help-entry-body,
.help-search-result.expanded .help-entry-body {
    display: block;
}

.help-entry.expanded,
.help-search-result.expanded {
    background-color: var(--theme-help-expanded-bg);
    border-radius: 4px;
    padding-left: 8px;
    padding-right: 6px;
    border-left: 2px solid var(--theme-help-expanded-border);
}

.help-entry.expanded .help-entry-title,
.help-search-result.expanded .help-entry-title {
    color: var(--theme-help-expanded-title);
}

/* --- Related Links --- */
.help-entry-related {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--theme-border-subtle, rgba(128,128,128,0.1));
}

.help-related-label {
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    margin-right: 4px;
}

.help-related-link {
    font-size: 0.75rem;
    color: #58a6ff;
    cursor: pointer;
}

.help-related-link:hover {
    text-decoration: underline;
}

/* --- Scroll-to-Entry Highlight --- */
.help-entry-highlight {
    animation: helpEntryFlash 1.5s ease;
}

@keyframes helpEntryFlash {
    0% { background-color: rgba(13, 110, 253, 0.2); }
    100% { background-color: transparent; }
}

/* --- Search Results --- */
.help-search-result .help-entry-category {
    font-size: 0.7rem;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.help-search-result mark {
    background-color: rgba(255, 193, 7, 0.3);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* --- Tippy "Learn more" link --- */
.tippy-learn-more {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid rgba(128,128,128,0.3);
    font-size: 0.75rem;
    color: #58a6ff;
    cursor: pointer;
}

.tippy-learn-more:hover {
    text-decoration: underline;
}

/* --- Mobile: Full-width drawer --- */
@media (max-width: 767.98px) {
    .help-drawer {
        width: 100% !important;
    }
}
