/* ============================================================================
   ENTITY LINKS — Related Content Section
   ============================================================================ */

/* Related items are presented as a slide-in drawer anchored to the right edge
   of the modal card, opened by a floating pill toggle. The modal root
   (.task-modal / .note-modal) is the positioning context — both are
   position:fixed and overflow:hidden, so the closed drawer is clipped offscreen
   and the toggle never produces a scrollbar. */

/* --- Floating toggle pill --------------------------------------------------- */
.entity-links-toggle {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px 0 13px;
    border: 1px solid var(--border-light, rgba(0,0,0,0.08));
    border-right: none;
    border-radius: 18px 0 0 18px;
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #555);
    box-shadow: -2px 0 12px rgba(26, 26, 46, 0.08);
    cursor: pointer;
    font-family: var(--font-family, inherit);
    transition: background var(--duration-fast) var(--ease-in-out),
                color var(--duration-fast) var(--ease-in-out),
                transform var(--duration-normal) var(--ease-in-out),
                box-shadow var(--duration-fast) var(--ease-in-out);
}

.entity-links-toggle:hover {
    color: var(--text-primary, #1A1A2E);
    box-shadow: -3px 0 16px rgba(26, 26, 46, 0.12);
}

.entity-links-toggle:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}

.entity-links-toggle-icon {
    flex-shrink: 0;
    transition: color var(--duration-fast) var(--ease-in-out);
}

.entity-links-toggle-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    line-height: 1;
    border-radius: var(--radius-md);
    background: var(--bg-hover, rgba(0,0,0,0.06));
    color: var(--text-secondary, #555);
}

/* AI-pending state — draws attention with the brand blue. */
.entity-links-toggle--pending {
    color: #4A90D9;
}
.entity-links-toggle--pending .entity-links-toggle-icon { color: #4A90D9; }
.entity-links-toggle--pending .entity-links-toggle-count {
    background: rgba(74, 144, 217, 0.14);
    color: #357ABD;
}

/* Hide the toggle while the drawer is open (the drawer has its own close). */
.has-entity-links--open .entity-links-toggle {
    transform: translateY(-50%) translateX(8px);
    opacity: 0;
    pointer-events: none;
}

/* --- Drawer ----------------------------------------------------------------- */
.entity-links-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 80%;
    z-index: 7;
    display: flex;
    flex-direction: column;
    background: var(--bg-card, #fff);
    border-left: 1px solid var(--border-light, rgba(0,0,0,0.08));
    box-shadow: -8px 0 28px rgba(26, 26, 46, 0.14);
    transform: translateX(100%);
    pointer-events: none;
    transition: transform var(--duration-slow) var(--ease-in-out);
}

.entity-links-drawer--open {
    transform: translateX(0);
    pointer-events: auto;
}

.entity-links-drawer-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 12px 16px 20px;
    border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.06));
}

.entity-links-drawer-title {
    font-size: var(--font-size-12);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #888);
}

.entity-links-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary, #888);
    transition: background var(--duration-fast) var(--ease-in-out), color var(--duration-fast) var(--ease-in-out);
}
.entity-links-drawer-close:hover {
    background: var(--bg-hover, rgba(0,0,0,0.06));
    color: var(--text-primary, #1A1A2E);
}
.entity-links-drawer-close:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}

/* --- List ------------------------------------------------------------------- */
.entity-links-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
}

.entity-links-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-in-out),
                opacity var(--duration-normal) var(--ease-in-out),
                transform var(--duration-normal) var(--ease-in-out),
                max-height var(--duration-normal) var(--ease-in-out);
    max-height: 72px;
}

.entity-links-item:hover {
    background: var(--bg-hover, rgba(0,0,0,0.04));
}
.entity-links-item:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset-inset);
    background: var(--bg-hover, rgba(0,0,0,0.04));
}

/* Dismiss animation — collapse + fade. */
.entity-links-item--leaving {
    opacity: 0;
    transform: translateX(12px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
}

.entity-links-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-hover, rgba(0,0,0,0.05));
    color: var(--text-secondary, #888);
}

.entity-links-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.entity-links-title {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary, #1A1A2E);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entity-links-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.entity-links-type {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary, #9a9aa8);
}

.entity-links-confidence {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary, #9a9aa8);
    flex-shrink: 0;
}

.entity-links-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4A90D9;
    background: rgba(74, 144, 217, 0.1);
    border-radius: var(--radius-sm);
    padding: 2px 5px 2px 4px;
    flex-shrink: 0;
}

.entity-links-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Confirmed/manual rows: chevron hint, subtle until hover. */
.entity-links-open-hint {
    color: var(--text-tertiary, #c4c4cc);
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-in-out), transform var(--duration-fast) var(--ease-in-out);
}
.entity-links-item:hover .entity-links-open-hint,
.entity-links-item:focus-visible .entity-links-open-hint {
    opacity: 1;
}

.entity-links-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary, #888);
    padding: 0;
    transition: background var(--duration-fast) var(--ease-in-out), color var(--duration-fast) var(--ease-in-out);
}
.entity-links-btn:hover {
    background: var(--bg-hover, rgba(0,0,0,0.08));
}
.entity-links-btn:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}
.entity-links-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.entity-links-confirm:hover { color: var(--color-green-text); background: rgba(16, 185, 129, 0.12); }
.entity-links-dismiss:hover { color: var(--color-red-text); background: rgba(239, 68, 68, 0.12); }

/* --- Dark mode -------------------------------------------------------------- */
[data-theme="dark"] .entity-links-toggle {
    background: var(--bg-card, #1c1c2a);
    border-color: rgba(255,255,255,0.08);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.4);
    color: var(--text-secondary, #b8b8c4);
}
[data-theme="dark"] .entity-links-toggle:hover { color: var(--text-light, #F5F5F7); }
[data-theme="dark"] .entity-links-toggle-count {
    background: rgba(255,255,255,0.1);
    color: var(--text-secondary, #b8b8c4);
}
[data-theme="dark"] .entity-links-drawer {
    background: var(--bg-card, #1c1c2a);
    border-left-color: rgba(255,255,255,0.08);
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .entity-links-drawer-header { border-bottom-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .entity-links-icon {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary, #b8b8c4);
}
[data-theme="dark"] .entity-links-title { color: var(--text-light, #F5F5F7); }
[data-theme="dark"] .entity-links-item:hover { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .entity-links-item:focus-visible { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .entity-links-drawer-close:hover { background: rgba(255,255,255,0.08); color: var(--text-light, #F5F5F7); }
[data-theme="dark"] .entity-links-btn:hover { background: rgba(255,255,255,0.1); }
[data-theme="dark"] .entity-links-confirm:hover { background: rgba(16, 185, 129, 0.2); }
[data-theme="dark"] .entity-links-dismiss:hover { background: rgba(239, 68, 68, 0.2); }

/* --- Reduced motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .entity-links-toggle,
    .entity-links-drawer,
    .entity-links-item,
    .entity-links-open-hint,
    .entity-links-btn {
        transition: none;
    }
}

/* ============================================================================
   END ENTITY LINKS
   ============================================================================ */
