/* ============================================================
   Help Popup System — Context-sensitive help overlays
   Part of the Helm Design System.
   ============================================================ */

/* ---- Help trigger button ---- */
.helm-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0 0 0 4px;
    border: none;
    background: none;
    color: var(--helm-text-muted, #9CA3AF);
    font-size: 14px;
    line-height: 1;
    cursor: help;
    vertical-align: middle;
    border-radius: 50%;
    transition: color var(--helm-transition, 0.2s ease), background var(--helm-transition, 0.2s ease);
}
.helm-help-btn:hover,
.helm-help-btn:focus-visible {
    color: var(--helm-primary, #1B3A6B);
    background: rgba(27, 58, 107, 0.06);
    outline: none;
}
.helm-help-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(27, 58, 107, 0.25);
}
.helm-help-btn i {
    font-size: inherit;
    line-height: 1;
}

/* Size variants */
.helm-help-btn.size-sm {
    width: 18px;
    height: 18px;
    font-size: 14px;
}
.helm-help-btn.size-md {
    width: 22px;
    height: 22px;
    font-size: 17px;
}
.helm-help-btn.size-lg {
    width: 26px;
    height: 26px;
    font-size: 20px;
}

/* ---- Popup container ---- */
.helm-help-popup {
    position: fixed;
    z-index: 1090;
    width: 360px;
    min-width: 280px;
    max-width: 800px;
    background: var(--helm-surface, #FFFFFF);
    border: 1px solid var(--helm-border, #E2E6EF);
    border-radius: 12px;
    box-shadow: var(--helm-shadow-lg, 0 8px 24px rgba(27, 58, 107, 0.12));
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    --help-scale: 1;
}
.helm-help-popup.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ---- Header (drag handle) ---- */
.helm-help-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    background: var(--helm-surface-subtle, #F0F2F8);
    border-radius: 12px 12px 0 0;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
    gap: 0.5rem;
}
.helm-help-popup-title {
    font-size: calc(0.875rem * var(--help-scale, 1));
    font-weight: 600;
    color: var(--helm-text, #1A1D26);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* ---- Close button ---- */
.helm-help-popup-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: none;
    color: var(--helm-text-secondary, #6B7280);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}
.helm-help-popup-close:hover {
    color: var(--helm-danger, #d73027);
    background: rgba(215, 48, 39, 0.08);
}

/* ---- Body ---- */
.helm-help-popup-body {
    padding: 1rem;
    overflow-y: auto;
    max-height: 400px;
    font-size: calc(0.875rem * var(--help-scale, 1));
    line-height: 1.55;
    color: var(--helm-text, #1A1D26);
}
.helm-help-popup-body p {
    margin: 0 0 0.625rem 0;
}
.helm-help-popup-body p:last-child {
    margin-bottom: 0;
}
.helm-help-popup-body ul,
.helm-help-popup-body ol {
    margin: 0 0 0.625rem 0;
    padding-left: 1.25rem;
}
.helm-help-popup-body li {
    margin-bottom: 0.25rem;
}
.helm-help-popup-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.5rem 0;
}
.helm-help-popup-body code {
    font-size: 0.85em;
    padding: 0.125rem 0.35rem;
    background: var(--helm-surface-subtle, #F0F2F8);
    border-radius: 4px;
    font-family: var(--helm-font-mono, monospace);
}
.helm-help-popup-body strong {
    font-weight: 600;
}

/* ---- Resize handle ---- */
.helm-help-popup-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    opacity: 0.35;
    transition: opacity 0.15s ease;
}
.helm-help-popup-resize:hover {
    opacity: 0.7;
}
.helm-help-popup-resize::before,
.helm-help-popup-resize::after,
.helm-help-popup-resize span {
    content: '';
    position: absolute;
    background: var(--helm-text-muted, #9CA3AF);
    border-radius: 1px;
    transform: rotate(-45deg);
}
.helm-help-popup-resize::before {
    width: 8px;
    height: 1.5px;
    bottom: 3px;
    right: 1px;
}
.helm-help-popup-resize::after {
    width: 12px;
    height: 1.5px;
    bottom: 6px;
    right: 1px;
}
.helm-help-popup-resize span {
    width: 5px;
    height: 1.5px;
    bottom: 9px;
    right: 1px;
}

/* ---- Loading spinner ---- */
.helm-help-popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.helm-help-popup-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--helm-border, #E2E6EF);
    border-top-color: var(--helm-primary, #1B3A6B);
    border-radius: 50%;
    animation: helm-help-spin 0.6s linear infinite;
}
@keyframes helm-help-spin {
    to { transform: rotate(360deg); }
}

/* ---- Error state ---- */
.helm-help-popup-error {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--helm-text-muted, #9CA3AF);
    font-size: calc(0.85rem * var(--help-scale, 1));
}
.helm-help-popup-error i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--helm-warning, #fdae61);
}

/* ---- Image in popup ---- */
.helm-help-popup-image {
    padding: 0 1rem;
}
.helm-help-popup-image img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}
