/* ============================================
   LDR Help System Styles
   Tooltips, Help Panels, and Documentation UI
   ============================================ */

/* ---------------------------------------------
   TOOLTIP SYSTEM
   --------------------------------------------- */

/* Base tooltip - text that shows tooltip on hover */
.ldr-help-tooltip {
    position: relative;
    cursor: help;
    /* No visual styling change - text looks normal */
}

/* Tooltip content - hidden by default, shown on hover */
.ldr-help-tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    width: max-content;
    max-width: 300px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 4px 20px rgba(var(--shadow-color-rgb), 0.25);
}

/* Tooltip arrow */
.ldr-help-tooltip[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-color);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Show tooltip on hover/focus */
.ldr-help-tooltip:hover::after,
.ldr-help-tooltip:hover::before,
.ldr-help-tooltip:focus::after,
.ldr-help-tooltip:focus::before {
    opacity: 1;
    visibility: visible;
}

/* Focus outline for accessibility */
.ldr-help-tooltip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 50%;
}

/* ---------------------------------------------
   TOOLTIP POSITION VARIANTS
   --------------------------------------------- */

/* Right position */
.ldr-help-tooltip--right[data-tooltip]::after {
    bottom: auto;
    top: 50%;
    left: calc(100% + 10px);
    transform: translateY(-50%);
}

.ldr-help-tooltip--right[data-tooltip]::before {
    bottom: auto;
    top: 50%;
    left: calc(100% + 4px);
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--border-color);
    border-top-color: transparent;
}

/* Left position */
.ldr-help-tooltip--left[data-tooltip]::after {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 10px);
    transform: translateY(-50%);
}

.ldr-help-tooltip--left[data-tooltip]::before {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 4px);
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: var(--border-color);
    border-top-color: transparent;
}

/* Bottom position */
.ldr-help-tooltip--bottom[data-tooltip]::after {
    bottom: auto;
    top: calc(100% + 8px);
}

.ldr-help-tooltip--bottom[data-tooltip]::before {
    bottom: auto;
    top: calc(100% + 2px);
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
    border-top-color: transparent;
}

/* ---------------------------------------------
   INLINE TOOLTIP (for use inside text)
   --------------------------------------------- */

.ldr-inline-tooltip {
    border-bottom: 1px dashed var(--text-muted);
    cursor: help;
    position: relative;
}

.ldr-inline-tooltip:hover {
    border-bottom-color: var(--accent-tertiary);
    color: var(--accent-tertiary);
}

/* ---------------------------------------------
   HELP PANEL (Collapsible "How it works" sections)
   --------------------------------------------- */

.ldr-help-panel {
    background: linear-gradient(135deg, rgba(var(--accent-primary-rgb), 0.06) 0%, rgba(var(--accent-tertiary-rgb), 0.04) 100%);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-primary);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ldr-help-panel:hover {
    border-color: rgba(var(--accent-primary-rgb), 0.3);
}

/* Panel Header - clickable to toggle */
.ldr-help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.ldr-help-panel-header:hover {
    background-color: rgba(var(--accent-primary-rgb), 0.08);
}

.ldr-help-panel-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.ldr-help-panel-title i {
    color: var(--accent-primary);
    font-size: 1rem;
}

.ldr-help-panel-toggle {
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

/* Collapsed state */
.ldr-help-panel.collapsed .ldr-help-panel-toggle {
    transform: rotate(-90deg);
}

/* Panel Content */
.ldr-help-panel-content {
    padding: 1rem 1.25rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.65;
    border-top: 1px solid var(--border-color);
    max-height: 800px;
    opacity: 1;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
}

.ldr-help-panel.collapsed .ldr-help-panel-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border-top: none;
    overflow: hidden;
}

/* Content styling */
.ldr-help-panel-content p {
    margin: 0 0 0.75rem 0;
}

.ldr-help-panel-content p:last-child {
    margin-bottom: 0;
}

.ldr-help-panel-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.ldr-help-panel-content li {
    margin-bottom: 0.4rem;
}

.ldr-help-panel-content strong {
    color: var(--text-primary);
}

.ldr-help-panel-content code {
    background-color: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent-secondary);
}

/* ---------------------------------------------
   HELP PANEL STEP LAYOUT
   --------------------------------------------- */

.ldr-help-steps {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.ldr-help-step {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.ldr-help-step-num {
    width: 26px;
    height: 26px;
    min-width: 26px;
    background: var(--accent-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.ldr-help-step-content {
    flex: 1;
}

.ldr-help-step-content strong {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.ldr-help-step-content p {
    margin: 0;
    color: var(--text-secondary);
}

/* ---------------------------------------------
   HELP TIP CALLOUT
   --------------------------------------------- */

.ldr-help-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.85rem 1rem;
    background: rgba(var(--accent-tertiary-rgb), 0.1);
    border-radius: 8px;
    margin-top: 0.75rem;
    font-size: 0.88rem;
}

.ldr-help-tip i {
    color: var(--accent-tertiary);
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.ldr-help-tip strong {
    color: var(--accent-tertiary);
}

/* Warning variant */
.ldr-help-tip--warning {
    background: rgba(var(--warning-color-rgb), 0.1);
}

.ldr-help-tip--warning i,
.ldr-help-tip--warning strong {
    color: var(--warning-color);
}

/* ---------------------------------------------
   HELP CARDS (for storage modes, etc.)
   --------------------------------------------- */

.ldr-help-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.ldr-help-card {
    padding: 0.85rem;
    border-radius: 8px;
    border-left: 3px solid;
}

.ldr-help-card-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.88rem;
}

.ldr-help-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

/* Card variants */
.ldr-help-card--success {
    background: rgba(var(--success-color-rgb), 0.1);
    border-left-color: var(--success-color);
}

.ldr-help-card--success .ldr-help-card-title {
    color: var(--success-color);
}

.ldr-help-card--warning {
    background: rgba(var(--warning-color-rgb), 0.1);
    border-left-color: var(--warning-color);
}

.ldr-help-card--warning .ldr-help-card-title {
    color: var(--warning-color);
}

.ldr-help-card--neutral {
    background: rgba(var(--text-muted-rgb), 0.1);
    border-left-color: var(--text-muted);
}

.ldr-help-card--neutral .ldr-help-card-title {
    color: var(--text-secondary);
}

.ldr-help-card--info {
    background: rgba(var(--accent-tertiary-rgb), 0.1);
    border-left-color: var(--accent-tertiary);
}

.ldr-help-card--info .ldr-help-card-title {
    color: var(--accent-tertiary);
}

/* ---------------------------------------------
   PANEL DISMISS OPTION
   --------------------------------------------- */

.ldr-help-panel-dismiss {
    margin-top: 0.9rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
    font-size: 0.82rem;
    color: var(--text-muted);
}

.ldr-help-panel-dismiss label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.ldr-help-panel-dismiss label:hover {
    color: var(--text-secondary);
}

.ldr-help-panel-dismiss input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* ---------------------------------------------
   LABEL WITH TOOLTIP
   --------------------------------------------- */

.ldr-label-with-tooltip {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
}

/* ---------------------------------------------
   GLOSSARY TERM
   --------------------------------------------- */

.ldr-glossary-term {
    color: var(--accent-secondary);
    border-bottom: 1px dotted var(--accent-secondary);
    cursor: help;
    position: relative;
}

.ldr-glossary-term:hover {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* ---------------------------------------------
   RESPONSIVE ADJUSTMENTS
   --------------------------------------------- */

@media (max-width: 767px) {
    /* Make tooltips work better on mobile */
    .ldr-help-tooltip[data-tooltip]::after {
        position: fixed;
        bottom: 70px;
        left: 1rem;
        right: 1rem;
        top: auto;
        transform: none;
        max-width: none;
        width: auto;
        text-align: center;
    }

    .ldr-help-tooltip[data-tooltip]::before {
        display: none;
    }

    /* Help panel adjustments */
    .ldr-help-panel-content {
        padding: 0.85rem 1rem 1rem;
    }

    .ldr-help-cards {
        grid-template-columns: 1fr;
    }

    /* Touch-friendly targets */
    .ldr-help-tooltip {
        min-width: 32px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .ldr-help-panel-header {
        padding: 1rem;
    }

    /* Help panel dismiss checkbox - proper touch target on mobile */
    .ldr-help-panel-dismiss {
        padding: 0.75rem 0;
        margin-bottom: 1rem;
    }

    .ldr-help-panel-dismiss label {
        min-height: 44px;
        padding: 0.5rem;
        border-radius: 6px;
        transition: background-color 0.15s ease;
    }

    .ldr-help-panel-dismiss label:hover,
    .ldr-help-panel-dismiss label:active {
        background-color: var(--bg-tertiary);
    }

    .ldr-help-panel-dismiss input[type="checkbox"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        margin-right: 0.5rem;
        accent-color: var(--accent-primary);
    }
}

/* ---------------------------------------------
   KEYBOARD HINTS DISPLAY
   --------------------------------------------- */

.ldr-keyboard-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.ldr-keyboard-hint kbd {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(var(--shadow-color-rgb), 0.2);
}

/* ---------------------------------------------
   PRIVACY NOTE
   --------------------------------------------- */

.ldr-privacy-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: rgba(var(--success-color-rgb), 0.08);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.ldr-privacy-note i {
    color: var(--success-color);
}
