/* ============================================================================
   HELP SIDEBAR
   Right-edge panel for User Guide + Tally AI
   ============================================================================ */

/* ===== Sidebar Container ===== */
.help-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    z-index: 9500;
    background: var(--bg-primary, #0f172a);
    border-left: 1px solid var(--border-color, #334155);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    font-family: var(--font-family, 'Inter', sans-serif);
}

.help-sidebar.open {
    transform: translateX(0);
}

/* ===== Header / Tab Bar ===== */
.help-sidebar__header {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border-color, #334155);
    background: var(--bg-secondary, #1e293b);
    flex-shrink: 0;
    min-height: 48px;
}

.help-sidebar__tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    white-space: nowrap;
}

.help-sidebar__tab:hover {
    color: var(--text-primary, #e2e8f0);
    background: var(--bg-tertiary, #334155);
}

.help-sidebar__tab.active {
    color: var(--accent-primary, #3b82f6);
    border-bottom-color: var(--accent-primary, #3b82f6);
}

.help-sidebar__tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Disabled tab (no AI module license) */
.help-sidebar__tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.help-sidebar__close {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    padding: 0.625rem;
    margin-right: 0.25rem;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.help-sidebar__close:hover {
    background: var(--bg-tertiary, #334155);
    color: var(--text-primary, #e2e8f0);
}

.help-sidebar__close svg {
    width: 18px;
    height: 18px;
}

/* ===== Guide Content Panel ===== */
.help-sidebar__guide-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

.help-sidebar__guide-content::-webkit-scrollbar {
    width: 6px;
}

.help-sidebar__guide-content::-webkit-scrollbar-track {
    background: transparent;
}

.help-sidebar__guide-content::-webkit-scrollbar-thumb {
    background: var(--border-color, #334155);
    border-radius: 3px;
}

/* Page header inside guide */
.help-sidebar__page-header {
    margin-bottom: 1rem;
}

.help-sidebar__page-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.help-sidebar__module-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.help-sidebar__page-overview {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
}

.help-sidebar__page-divider {
    height: 1px;
    background: var(--border-color, #334155);
    margin: 1rem 0;
}

/* Full guide link at bottom of guide content */
.help-sidebar__full-guide-link {
    display: block;
    text-align: center;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--accent-primary, #3b82f6);
    text-decoration: none;
    border: 1px solid var(--border-color, #334155);
    border-radius: 8px;
    transition: all 0.15s ease;
}

.help-sidebar__full-guide-link:hover {
    background: var(--bg-secondary, #1e293b);
    border-color: var(--accent-primary, #3b82f6);
}

/* Empty state when no guide found */
.help-sidebar__empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted, #64748b);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.help-sidebar__empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ===== Scoped overrides for ug-* classes inside sidebar ===== */
.help-sidebar .ug-section-block {
    margin-bottom: 1rem;
}

.help-sidebar .ug-section-title {
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.help-sidebar .ug-section-text {
    font-size: 0.8125rem;
    line-height: 1.6;
}

.help-sidebar .ug-widget-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.help-sidebar .ug-widget-card {
    padding: 0.75rem;
}

.help-sidebar .ug-widget-card-name {
    font-size: 0.8125rem;
}

.help-sidebar .ug-widget-card-desc {
    font-size: 0.75rem;
}

.help-sidebar .ug-widget-features-list {
    font-size: 0.75rem;
}

.help-sidebar .ug-widget-indicator-text,
.help-sidebar .ug-widget-section-text {
    font-size: 0.75rem;
}

.help-sidebar .ug-widget-section-label {
    font-size: 0.6875rem;
}

.help-sidebar .ug-workflow-step {
    padding: 0.5rem 0;
}

.help-sidebar .ug-workflow-number {
    width: 24px;
    height: 24px;
    font-size: 0.6875rem;
}

.help-sidebar .ug-workflow-step-title {
    font-size: 0.8125rem;
}

.help-sidebar .ug-workflow-step-desc {
    font-size: 0.75rem;
}

.help-sidebar .ug-callout {
    padding: 0.75rem;
    font-size: 0.75rem;
}

.help-sidebar .ug-callout-title {
    font-size: 0.8125rem;
}

.help-sidebar .ug-callout-text {
    font-size: 0.75rem;
}

.help-sidebar .ug-route-link {
    font-size: inherit;
}

/* ===== Tally AI Panel ===== */
.help-sidebar__tally {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.help-sidebar__tally-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.help-sidebar__tally-welcome {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.help-sidebar__tally-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary, #3b82f6) 0%, #14b8a6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.help-sidebar__tally-avatar svg {
    width: 20px;
    height: 20px;
}

.help-sidebar__tally-bubble {
    flex: 1;
}

.help-sidebar__tally-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 0.375rem;
}

.help-sidebar__tally-text {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
}

/* Quick prompt chips */
.help-sidebar__tally-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1rem;
}

.help-sidebar__tally-chip {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 20px;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.help-sidebar__tally-chip:hover {
    background: var(--bg-tertiary, #334155);
    color: var(--text-primary, #e2e8f0);
    border-color: var(--accent-primary, #3b82f6);
}

/* Chat input bar */
.help-sidebar__tally-input-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #334155);
    background: var(--bg-secondary, #1e293b);
    flex-shrink: 0;
}

.help-sidebar__tally-input {
    flex: 1;
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border-color, #334155);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-primary, #e2e8f0);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.help-sidebar__tally-input::placeholder {
    color: var(--text-muted, #64748b);
}

.help-sidebar__tally-input:focus {
    border-color: var(--accent-primary, #3b82f6);
}

.help-sidebar__tally-send {
    background: var(--accent-primary, #3b82f6);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.help-sidebar__tally-send:hover {
    background: var(--accent-primary-hover, #2563eb);
}

.help-sidebar__tally-send svg {
    width: 18px;
    height: 18px;
}

/* ===== Picker Menu (shown above FAB when AI module available) ===== */
.help-sidebar__picker {
    position: fixed;
    bottom: 84px;
    right: 24px;
    z-index: 9001;
    background: var(--bg-secondary, #1e293b);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    overflow: hidden;
    animation: helpPickerSlideUp 0.15s ease;
}

@keyframes helpPickerSlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.help-sidebar__picker-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.help-sidebar__picker-item:first-child {
    border-bottom: 1px solid var(--border-color, #334155);
}

.help-sidebar__picker-item:hover {
    background: var(--bg-tertiary, #334155);
    color: var(--text-primary, #e2e8f0);
}

.help-sidebar__picker-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.help-sidebar__picker-item--ai svg {
    color: #14b8a6;
}

.help-sidebar__picker-item--guide svg {
    color: var(--accent-primary, #3b82f6);
}

/* Disabled picker item (no AI module license) */
.help-sidebar__picker-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.help-sidebar__picker-badge {
    margin-left: auto;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--border-color, #334155);
    color: var(--text-muted, #64748b);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .help-sidebar {
        width: 100%;
    }

    .help-sidebar__picker {
        bottom: 76px;
        right: 16px;
    }
}

/* ===== Print ===== */
@media print {
    .help-sidebar,
    .help-sidebar__picker {
        display: none !important;
    }
}

/* ===== Reduce motion ===== */
@media (prefers-reduced-motion: reduce) {
    .help-sidebar {
        transition: none;
    }

    .help-sidebar__picker {
        animation: none;
    }
}

/* ===== Light Theme ===== */
[data-theme="light"] .help-sidebar {
    background: var(--bg-card, #ffffff);
    border-left-color: var(--border-color, #e2e8f0);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .help-sidebar__header {
    background: var(--bg-tertiary, #f8fafc);
}

[data-theme="light"] .help-sidebar__tab {
    color: var(--text-secondary, #64748b);
}

[data-theme="light"] .help-sidebar__tab:hover {
    color: var(--text-primary, #1e293b);
    background: var(--bg-secondary, #f0f5fa);
}

[data-theme="light"] .help-sidebar__close {
    color: var(--text-secondary, #64748b);
}

[data-theme="light"] .help-sidebar__close:hover {
    background: var(--bg-secondary, #f0f5fa);
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .help-sidebar__page-title {
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .help-sidebar__page-overview {
    color: var(--text-secondary, #64748b);
}

[data-theme="light"] .help-sidebar__full-guide-link {
    border-color: var(--border-color, #e2e8f0);
}

[data-theme="light"] .help-sidebar__full-guide-link:hover {
    background: var(--bg-tertiary, #f8fafc);
}

[data-theme="light"] .help-sidebar__empty {
    color: var(--text-muted, #94a3b8);
}

[data-theme="light"] .help-sidebar__tally-welcome {
    background: var(--bg-tertiary, #f8fafc);
    border-color: var(--border-color, #e2e8f0);
}

[data-theme="light"] .help-sidebar__tally-name {
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .help-sidebar__tally-text {
    color: var(--text-secondary, #64748b);
}

[data-theme="light"] .help-sidebar__tally-chip {
    background: var(--bg-tertiary, #f8fafc);
    border-color: var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
}

[data-theme="light"] .help-sidebar__tally-chip:hover {
    background: var(--bg-secondary, #f0f5fa);
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .help-sidebar__tally-input-bar {
    background: var(--bg-tertiary, #f8fafc);
    border-top-color: var(--border-color, #e2e8f0);
}

[data-theme="light"] .help-sidebar__tally-input {
    background: var(--bg-card, #ffffff);
    border-color: var(--border-color, #e2e8f0);
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .help-sidebar__tally-input::placeholder {
    color: var(--text-muted, #94a3b8);
}

[data-theme="light"] .help-sidebar__picker {
    background: var(--bg-card, #ffffff);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .help-sidebar__picker-item {
    color: var(--text-secondary, #64748b);
}

[data-theme="light"] .help-sidebar__picker-item:first-child {
    border-bottom-color: var(--border-color, #e2e8f0);
}

[data-theme="light"] .help-sidebar__picker-item:hover {
    background: var(--bg-tertiary, #f8fafc);
    color: var(--text-primary, #1e293b);
}

[data-theme="light"] .help-sidebar__picker-badge {
    background: var(--border-color, #e2e8f0);
    color: var(--text-muted, #94a3b8);
}
