/* AAAHelp — reusable LLM contextual-help widget. */

.aaa-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    padding: 0;
    border: none;
    background: transparent;
    color: #6366f1;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
    vertical-align: middle;
}
.aaa-help-btn:hover {
    background: #ede9fe;
    color: #4338ca;
}
.aaa-help-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.aaa-help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(440px, 92vw);
    background: #fff;
    box-shadow: -8px 0 24px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    animation: aaaHelpSlideIn 0.18s ease-out;
}
.aaa-help-drawer[hidden] { display: none !important; }

@keyframes aaaHelpSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.aaa-help-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}
.aaa-help-titles { flex: 1; min-width: 0; }
.aaa-help-grain {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6366f1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.aaa-help-target {
    margin: 0 0 4px;
    font-size: 1rem;
    color: #1f2937;
    line-height: 1.3;
}
.aaa-help-parent {
    margin: 0;
    font-size: 0.82rem;
    color: #6b7280;
}
.aaa-help-close {
    flex: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    font-size: 1.1rem;
}
.aaa-help-close:hover { background: rgba(255, 255, 255, 0.6); color: #1f2937; }

.aaa-help-context {
    border-bottom: 1px solid #e5e7eb;
    background: #fafafe;
}
.aaa-help-context > summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 18px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #4338ca;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    user-select: none;
}
.aaa-help-context > summary::-webkit-details-marker { display: none; }
.aaa-help-context > summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s ease;
}
.aaa-help-context[open] > summary::before { transform: rotate(90deg); }
.aaa-help-context-body {
    padding: 0 18px 12px;
    font-size: 0.85rem;
    color: #374151;
}
.aaa-help-context-body:empty { display: none; }
.aaa-help-ctx-text {
    margin: 0 0 8px;
    line-height: 1.45;
}
.aaa-help-ctx-block { margin: 8px 0; }
.aaa-help-ctx-block h5 {
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.aaa-help-ctx-block ul {
    margin: 0;
    padding-left: 18px;
    line-height: 1.45;
}
.aaa-help-ctx-block li { margin: 2px 0; }
.aaa-help-ctx-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 6px 0;
}
.aaa-help-ctx-tag {
    padding: 2px 8px;
    background: #ede9fe;
    color: #4338ca;
    border-radius: 4px;
    font-size: 0.74rem;
}
.aaa-help-ctx-tag strong { color: #1e1b4b; }
.aaa-help-ctx-note {
    margin: 6px 0 0;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.78rem;
    line-height: 1.4;
}

.aaa-help-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 12px 18px;
    border-bottom: 1px solid #e5e7eb;
}
.aaa-help-preset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.82rem;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    text-align: left;
}
.aaa-help-preset:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #4338ca;
}
.aaa-help-preset i {
    color: #6366f1;
    font-size: 0.85rem;
}

.aaa-help-thread {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafe;
}
.aaa-help-empty {
    margin: auto;
    text-align: center;
    color: #9ca3af;
    font-size: 0.88rem;
}
.aaa-help-empty i { font-size: 1.6rem; opacity: 0.5; display: block; margin-bottom: 8px; }

.aaa-help-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.aaa-help-msg-role {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}
.aaa-help-msg-content {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #1f2937;
}
.aaa-help-msg-user .aaa-help-msg-content {
    background: #e0e7ff;
    color: #1e1b4b;
    align-self: flex-end;
    max-width: 88%;
}
.aaa-help-msg-user { align-items: flex-end; }
.aaa-help-msg-user .aaa-help-msg-role { color: #4338ca; }
.aaa-help-msg-assistant .aaa-help-msg-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    max-width: 95%;
}
.aaa-help-msg-pending .aaa-help-msg-content {
    color: #6b7280;
    font-style: italic;
}

.aaa-help-form {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}
.aaa-help-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 38px;
}
.aaa-help-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.aaa-help-send {
    flex: none;
    width: 40px;
    height: 38px;
    border: none;
    border-radius: 6px;
    background: #6366f1;
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
}
.aaa-help-send:hover { background: #4f46e5; }
.aaa-help-send:disabled { background: #c7d2fe; cursor: not-allowed; }

@media (max-width: 720px) {
    .aaa-help-drawer { width: 100vw; }
    .aaa-help-presets { grid-template-columns: 1fr; }
}
