/* =============================================================
 *  recommendations.css — AI Insights Panel & Trigger Row
 * ============================================================= */

/* ── Desktop right-edge panel ──────────────────────────────── */
.ii-rec-panel {
    position: fixed;
    top: var(--header-sidebar-height, 3rem);
    right: 0;
    bottom: 0;
    width: var(--ii-rec-panel-width, 310px);
    background: var(--ii-surface-white, #fff);
    border-left: 1px solid var(--ii-border, #e5e7eb);
    transform: translateX(100%);
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
        visibility 0s linear 0.38s;
    visibility: hidden;
    z-index: 500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ii-rec-panel.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
        visibility 0s linear 0s;
}

/* Compress main area when panel is open */
.has-rec-panel-open #iiMain {}

/* ── Panel header ──────────────────────────────────────────── */
.ii-rec-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    min-height: 48px;
    border-bottom: 1px solid var(--ii-border, #e5e7eb);
    flex-shrink: 0;
}

.ii-rec-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ii-text-primary, #111827);
}

.ii-rec-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--ii-text-tertiary, #9ca3af);
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
    transition: background 150ms, color 150ms;
}

.ii-rec-panel-close:hover {
    background: var(--ii-bg-hover, #e5e7eb);
    color: var(--ii-text-primary, #111827);
}

/* ── Panel body ────────────────────────────────────────────── */
.ii-rec-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Panel footer (visible only when cards are selected) ───── */
.ii-rec-panel-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 12px;
    border-top: 1px solid var(--ii-border, #e5e7eb);
    flex-shrink: 0;
    gap: 8px;
}

/* ── "New insights" button — top of panel body, full width ─── */
.ii-rec-generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 14px;
    border: 1.5px solid #8b5cf6;
    border-radius: 8px;
    background: transparent;
    color: #8b5cf6;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.ii-rec-generate-btn:hover:not(:disabled) {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

.ii-rec-generate-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Session accordion ─────────────────────────────────────── */
.ii-rec-session {
    border: 1px solid var(--ii-border, #e5e7eb);
    border-radius: 10px;
    transition: box-shadow 150ms ease;
}

.ii-rec-session.is-open {
    border: 1px solid #8b5cf6;
}

.ii-rec-session:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.ii-rec-session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    cursor: pointer;
    user-select: none;
    background: var(--ii-bg-secondary, #f9fafb);
    border-radius: 10px;
    transition: background 150ms ease;
    gap: 8px;
}

.ii-rec-session.is-open .ii-rec-session-header {
    border-radius: 10px 10px 0 0;
}

.ii-rec-session-header:hover {
    background: var(--ii-bg-hover, #f3f4f6);
}

.ii-rec-session-header-left {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.ii-rec-session-date {
    font-size: 11.5px;
    color: var(--ii-text-tertiary, #9ca3af);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ii-rec-session-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ii-text-tertiary, #9ca3af);
    background: var(--ii-accent-dim, rgba(37, 99, 235, 0.09));
    padding: 2px 7px;
    border-radius: var(--ii-radius-rounded);
    white-space: nowrap;
    flex-shrink: 0;
}

.ii-rec-session-badge--pending {
    color: var(--ii-text-secondary, #6b7280);
    background: var(--ii-bg-hover, #e5e7eb);
    animation: iiRecBadgePulse 1.6s ease-in-out infinite;
}

@keyframes iiRecBadgePulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.ii-rec-session-chevron {
    flex-shrink: 0;
    color: var(--ii-text-tertiary, #9ca3af);
    transition: transform 220ms ease, color 150ms ease;
    display: flex;
    align-items: center;
}

.ii-rec-session.is-open .ii-rec-session-chevron {
    transform: rotate(180deg);
    color: var(--ii-text-secondary, #6b7280);
}

.ii-rec-session-body {
    display: none;
    padding: 10px 10px 6px;
    border-radius: 0 0 10px 10px;
    background: var(--ii-surface-white, #fff);
}

.ii-rec-session.is-open .ii-rec-session-body {
    display: block;
}

/* Pending session: body always visible (showing skeleton) */
.ii-rec-session--pending .ii-rec-session-body {
    display: block;
}

/* ── Section labels within session body ────────────────────── */
.ii-rec-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.ii-rec-section:last-child {
    margin-bottom: 0;
}

.ii-rec-section-label {
    display: none;
    /* hidden — may be re-enabled in future */
}

/* ── Unified insight cards ─────────────────────────────────── */
.ii-rec-card {
    position: relative;
    outline: none;
    user-select: none;
}

.ii-rec-card--step {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ii-border, #e5e7eb);
    border-radius: 10px;
    background: var(--ii-surface-white, #fff);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    margin-bottom: 6px;
}

.ii-rec-card--step:hover {
    /* border-color: #8b5cf6; */
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.22), 0 4px 16px rgba(139, 92, 246, 0.1);
    transform: translateY(-1px);
}

.ii-rec-card--step:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}

.ii-rec-card--step.is-selected {
    /* border-color: #8b5cf6; */
    background: rgba(139, 92, 246, 0.05);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.3);
}

[data-theme="dark"] .ii-rec-card--step {
    background: var(--ii-bg-secondary, #1f2937);
}

[data-theme="dark"] .ii-rec-card--step.is-selected {
    background: rgba(139, 92, 246, 0.1);
}

/* Checkbox indicator — appears on hover and selected */
.ii-rec-card-select {
    position: absolute;
    top: 13px;
    left: 10px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 1;
}

.ii-rec-card--step:hover .ii-rec-card-select,
.ii-rec-card--step.is-selected .ii-rec-card-select {
    opacity: 1;
}

.ii-rec-card-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid #8b5cf6;
    background: transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
    box-sizing: border-box;
}

.ii-rec-card--step.is-selected .ii-rec-card-checkbox {
    background: #8b5cf6 url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e") center/contain no-repeat;
    border-color: #8b5cf6;
}

/* Card body (text content) */
.ii-rec-card-body {
    padding: 11px 12px 9px 32px;
    flex: 1;
}

.ii-rec-card-title {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ii-text-primary, #111827);
    line-height: 1.4;
    margin-bottom: 3px;
}

.ii-rec-card-desc {
    font-size: 11.5px;
    color: var(--ii-text-secondary, #4b5563);
    line-height: 1.5;
    margin: 0;
}

/* "Generate selected" footer button */
.ii-rec-generate-selected-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: #8b5cf6;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.ii-rec-generate-selected-btn:hover:not(:disabled) {
    background: #7c3aed;
}

.ii-rec-generate-selected-btn:disabled {
    background: var(--ii-bg-hover, #e5e7eb);
    color: var(--ii-text-tertiary, #9ca3af);
    cursor: not-allowed;
    opacity: 1;
}

/* ── Selection bar (between body and footer) ──────────────── */
.ii-rec-selection-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    border-top: 1px solid rgba(139, 92, 246, 0.18);
    background: rgba(139, 92, 246, 0.05);
    flex-shrink: 0;
}

.ii-rec-selection-bar.is-visible {
    display: flex;
}

.ii-rec-sel-info {
    font-size: 12px;
    color: #8b5cf6;
    font-weight: 500;
}

.ii-rec-selected-count {
    font-weight: 700;
}

.ii-rec-deselect-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ii-text-tertiary, #9ca3af);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.15s ease;
    white-space: nowrap;
}

.ii-rec-deselect-btn:hover {
    color: var(--ii-text-secondary, #4b5563);
}

/* ── AI insights drawer ─────────────────────────── */
.ii-ai-insights-drawer .ii-drawer-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
}

.ii-ai-insights-drawer .ii-rec-generate-btn {
    margin-bottom: 0;
}

.ii-ai-insights-drawer .ii-rec-selection-bar {
    background: none;
}

/* ── Mobile drawer footer wrapper ─────────────────────────── */
.ii-rec-drawer-footer-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.ii-rec-drawer-footer-inner .ii-rec-selection-bar {
    border-top: none;
    border-bottom: 1px solid rgba(139, 92, 246, 0.18);
    padding: 0 0 8px;
}

.ii-rec-drawer-footer-actions {
    display: flex;
    gap: 8px;
}

.ii-rec-drawer-footer-actions .ii-rec-generate-btn,
.ii-rec-drawer-footer-actions .ii-rec-generate-selected-btn {
    flex: 1;
}

/* ── Skeleton ────────────────────────────────────────────── */
.ii-rec-skeleton {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ii-rec-skel-session-header {
    width: 100%;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(90deg,
            var(--ii-bg-secondary, #f3f4f6) 25%,
            var(--ii-bg-hover, #e5e7eb) 50%,
            var(--ii-bg-secondary, #f3f4f6) 75%);
    background-size: 200% 100%;
    animation: iiSkeletonShimmer 1.8s infinite linear;
}

.ii-rec-skel-card {
    width: 100%;
    height: 68px;
    border-radius: 8px;
    background: linear-gradient(90deg,
            var(--ii-bg-secondary, #f3f4f6) 25%,
            var(--ii-bg-hover, #e5e7eb) 50%,
            var(--ii-bg-secondary, #f3f4f6) 75%);
    background-size: 200% 100%;
    animation: iiSkeletonShimmer 1.8s infinite linear;
}

/* ── Error state ─────────────────────────────────────────── */
.ii-rec-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 16px;
    color: var(--ii-text-tertiary, #9ca3af);
    text-align: center;
}

.ii-rec-error p {
    font-size: 13px;
    margin: 0;
}

/* ── Floating AI Insights button (bottom-center of image) ── */
/* ── AI Insights icon button inside image-actions overlay ─── */
/* .ii-insights-action-btn.ii-rec-has-data {
    background: rgba(139, 92, 246, 0.82);
    border-color: rgba(167, 139, 250, 0.4);
    color: #fff;
}

.ii-insights-action-btn.ii-rec-has-data:hover {
    background: rgba(139, 92, 246, 0.95);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
} */

.ii-rec-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ii-accent, #2563eb);
    flex-shrink: 0;
}

.ii-rec-cost {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px 1px 4px;
    border-radius: 10px;
    background: var(--ii-accent-dim, rgba(37, 99, 235, 0.1));
    color: var(--ii-accent, #2563eb);
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
}

.ii-rec-cost svg {
    flex-shrink: 0;
}

/* ── Mobile: disable desktop panel, use Drawer ───────────── */
@media (max-width: 768px) {
    .ii-rec-panel {
        display: none !important;
    }

    .has-rec-panel-open #iiMain {
        margin-right: 0 !important;
    }

    .ii-rec-session-header {
        border-radius: 10px;
    }
}