/* Babba Media resources popover — sessions header quick links */

#workflow-studio-view .wf-babba-resources {
    position: relative;
    display: inline-flex;
    align-items: center;
}

#workflow-studio-view .wf-babba-resources[hidden] {
    display: none !important;
}

/* Icon-only trigger — matches wf-back-to-sessions-btn */
#workflow-studio-view .wf-babba-resources__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    background: var(--color-surface-elevated);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

#workflow-studio-view .wf-babba-resources__trigger:hover,
#workflow-studio-view .wf-babba-resources__trigger[aria-expanded="true"] {
    color: var(--color-text-primary);
    border-color: color-mix(in srgb, var(--color-primary) 28%, var(--color-border-light));
    background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface-elevated));
}

#workflow-studio-view .wf-babba-resources__trigger:active {
    transform: scale(0.96);
}

#workflow-studio-view .wf-babba-resources__trigger:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

#workflow-studio-view .wf-babba-resources__trigger i,
#workflow-studio-view .wf-babba-resources__trigger svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#workflow-studio-view .wf-babba-resources__panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: var(--z-popover, 600);
    width: min(340px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--color-border-light);
    border-radius: 14px;
    background: var(--color-surface-elevated, var(--color-surface));
    box-shadow:
        0 18px 40px color-mix(in srgb, var(--color-gray-900, #111) 14%, transparent),
        0 2px 8px color-mix(in srgb, var(--color-gray-900, #111) 6%, transparent);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    visibility: hidden;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0.2s ease;
}

#workflow-studio-view .wf-babba-resources__panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

/* Keep in layout for transitions; only fully remove when closed + settled */
#workflow-studio-view .wf-babba-resources__panel[hidden]:not(.is-leaving) {
    display: none !important;
}

#workflow-studio-view .wf-babba-resources__panel.is-leaving {
    display: block !important;
}

#workflow-studio-view .wf-babba-resources__head {
    display: grid;
    gap: 2px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--color-border-light);
}

#workflow-studio-view .wf-babba-resources__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
}

#workflow-studio-view .wf-babba-resources__subtitle {
    margin: 0;
    font-size: var(--font-size-xs);
    line-height: 1.35;
    color: var(--color-text-tertiary);
}

#workflow-studio-view .wf-babba-resources__list {
    display: grid;
    gap: 4px;
    padding: 8px;
}

#workflow-studio-view .wf-babba-resources__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition:
        background 0.14s ease,
        border-color 0.14s ease;
}

#workflow-studio-view .wf-babba-resources__item:hover,
#workflow-studio-view .wf-babba-resources__item:focus-visible {
    background: color-mix(in srgb, var(--color-primary) 7%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-primary) 14%, var(--color-border-light));
    outline: none;
}

#workflow-studio-view .wf-babba-resources__item.is-empty:hover,
#workflow-studio-view .wf-babba-resources__item.is-empty:focus-visible {
    background: color-mix(in srgb, var(--color-bg-tertiary) 70%, var(--color-surface));
    border-color: var(--color-border-light);
}

#workflow-studio-view .wf-babba-resources__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--color-bg-tertiary);
    border: 1px solid color-mix(in srgb, var(--color-border-light) 80%, transparent);
    flex-shrink: 0;
}

#workflow-studio-view .wf-babba-resources__logo {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}

#workflow-studio-view .wf-babba-resources__copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

#workflow-studio-view .wf-babba-resources__name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    line-height: 1.25;
}

#workflow-studio-view .wf-babba-resources__hint {
    font-size: 11px;
    line-height: 1.3;
    color: var(--color-text-tertiary);
}

#workflow-studio-view .wf-babba-resources__item.is-empty .wf-babba-resources__hint {
    color: color-mix(in srgb, var(--color-primary) 55%, var(--color-text-tertiary));
}

#workflow-studio-view .wf-babba-resources__chevron {
    display: inline-flex;
    color: var(--color-text-tertiary);
}

#workflow-studio-view .wf-babba-resources__chevron i,
#workflow-studio-view .wf-babba-resources__chevron svg {
    width: 15px;
    height: 15px;
}

#workflow-studio-view .wf-babba-resources__item:hover .wf-babba-resources__chevron {
    color: var(--color-text-secondary);
}

#workflow-studio-view .wf-babba-resources__footer {
    padding: 4px 8px 8px;
    border-top: 1px solid var(--color-border-light);
}

#workflow-studio-view .wf-babba-resources__manage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--color-text-secondary);
    font: inherit;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

#workflow-studio-view .wf-babba-resources__manage:hover,
#workflow-studio-view .wf-babba-resources__manage:focus-visible {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    outline: none;
}

#workflow-studio-view .wf-babba-resources__manage i,
#workflow-studio-view .wf-babba-resources__manage svg {
    width: 14px;
    height: 14px;
}

#workflow-studio-view .wf-babba-resources__loading,
#workflow-studio-view .wf-babba-resources__error {
    margin: 0;
    padding: 16px 12px;
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
}

#workflow-studio-view .wf-babba-resources__error {
    color: var(--color-error, #dc2626);
}

[data-theme="dark"] #workflow-studio-view .wf-babba-resources__panel {
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] #workflow-studio-view .wf-babba-resources__mark {
    background: color-mix(in srgb, var(--color-surface) 70%, #000);
}

@media (max-width: 720px) {
    #workflow-studio-view .wf-babba-resources {
        width: auto;
        align-self: flex-end;
    }

    #workflow-studio-view .wf-babba-resources__trigger {
        width: 36px;
        height: 36px;
    }

    #workflow-studio-view .wf-babba-resources__panel {
        right: 0;
        left: auto;
        width: min(320px, calc(100vw - 24px));
    }
}
