/* public/css/integrations.css — Integrations view (view-integrations, index.html)
   Scoped under #view-integrations. Reuses style.css tokens (.wf-card, .btn, .wf-badge). */

#view-integrations .intg-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--wf-outline-variant, #e0e0e0);
    margin: 12px 0 20px;
}
#view-integrations .intg-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    color: var(--wf-on-surface-variant, #5f6368);
    cursor: pointer;
    margin-bottom: -2px;
}
#view-integrations .intg-tab.active {
    color: var(--wf-primary, #1a73e8);
    border-bottom-color: var(--wf-primary, #1a73e8);
}
#view-integrations .intg-tab:hover { color: var(--wf-primary, #1a73e8); }

#view-integrations .intg-card { padding: 20px; margin-bottom: 16px; }
#view-integrations .intg-muted { color: var(--wf-on-surface-variant, #70757a); font-size: 0.85em; }
#view-integrations .intg-empty {
    padding: 24px;
    text-align: center;
    color: var(--wf-on-surface-variant, #70757a);
}
#view-integrations .intg-empty.error { color: var(--wf-error, #c5221f); }

/* Workflow rows (Mappings tab list) */
#view-integrations .intg-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--wf-outline-variant, #e0e0e0);
    border-radius: 10px;
    margin-bottom: 10px;
    background: var(--wf-surface, #fff);
}
#view-integrations .intg-row__main { flex: 1; min-width: 0; }
#view-integrations .intg-row__name { font-weight: 600; }
#view-integrations .intg-row__badges { display: flex; gap: 6px; flex-wrap: wrap; }
#view-integrations .intg-row__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Editor */
#view-integrations .intg-editor__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}
#view-integrations .intg-editor__actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
}
#view-integrations .intg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}
#view-integrations .intg-field { display: flex; flex-direction: column; gap: 6px; }
#view-integrations .intg-field > span:first-child {
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wf-on-surface-variant, #70757a);
}
#view-integrations .intg-section { margin: 18px 0; }
#view-integrations .intg-section__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}
#view-integrations .intg-checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 16px;
    margin-top: 8px;
}
#view-integrations .intg-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92em;
    cursor: pointer;
    margin-right: 12px;
}
#view-integrations .intg-check--lg { font-size: 1em; font-weight: 600; }
#view-integrations .intg-input,
#intg-conn-modal .intg-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--wf-outline-variant, #dadce0);
    border-radius: 8px;
    font: inherit;
    font-size: 0.92em;
}
#view-integrations .intg-static-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

/* Tables (field map, deliveries, connections) */
#view-integrations .intg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
}
#view-integrations .intg-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--wf-outline-variant, #e0e0e0);
    color: var(--wf-on-surface-variant, #5f6368);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
#view-integrations .intg-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--wf-outline-variant, #eeeeee);
    vertical-align: middle;
}
#view-integrations .intg-url {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 0.85em;
}

/* Secret + delivery modals reuse .modal/.modal-content from style.css */
#view-integrations .intg-secret-box,
#intg-secret-modal .intg-secret-box {
    font-family: monospace;
    background: var(--wf-surface-container, #f1f3f4);
    border: 1px dashed var(--wf-outline, #bdc1c6);
    border-radius: 8px;
    padding: 14px;
    word-break: break-all;
    margin: 12px 0;
    user-select: all;
}
#intg-secret-modal .intg-secret-testrecv {
    margin: 0 0 14px;
    padding: 10px 12px;
    background: var(--wf-surface-container, #f1f3f4);
    border-left: 3px solid var(--wf-primary, #1a73e8);
    border-radius: 6px;
}
/* Help panel: two top-level collapsible sections (overview / walkthrough) */
.intg-help-panel .intg-help-acc {
    border: 1px solid var(--wf-outline-variant, #dadce0);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}
.intg-help-panel .intg-help-acc__sum {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 700;
    font-size: 0.95em;
    background: var(--wf-surface-container, #f1f3f4);
    list-style: none;
}
.intg-help-panel .intg-help-acc__sum::-webkit-details-marker { display: none; }
.intg-help-panel .intg-help-acc__sum::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.15s;
}
.intg-help-panel .intg-help-acc[open] > .intg-help-acc__sum::before { transform: rotate(90deg); }
/* Horizontal padding kept minimal so the inner text column is the same width
   as the pre-accordion panel — the sections wrap exactly as they used to. */
.intg-help-panel .intg-help-acc__body { padding: 10px 4px 2px; }

/* Walkthrough steps: numbered, each expandable for its detail */
.intg-help-panel .intg-wt-step {
    border-bottom: 1px solid var(--wf-outline-variant, #e8eaed);
    padding: 2px 0;
}
.intg-help-panel .intg-wt-step:last-child { border-bottom: none; }
.intg-help-panel .intg-wt-step summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px;
    font-weight: 600;
    font-size: 0.9em;
    list-style: none;
}
.intg-help-panel .intg-wt-step summary::-webkit-details-marker { display: none; }
/* Tiny expand cue — hint only, right next to the step title, flips when open */
.intg-help-panel .intg-wt-step summary::after {
    content: '▾';
    margin-left: 6px;
    font-size: 0.78em;
    color: var(--wf-on-surface-variant, #80868b);
    transition: transform 0.15s;
}
.intg-help-panel .intg-wt-step:not([open]) > summary::after { transform: rotate(-90deg); }
.intg-help-panel .intg-wt-step__num {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--wf-primary, #1a73e8);
    color: #fff;
    font-size: 0.75em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.intg-help-panel .intg-wt-step__body {
    margin: 0 0 10px 32px;
    font-size: 0.85em;
    line-height: 1.5;
    color: var(--wf-on-surface-variant, #5f6368);
}

#intg-sink-modal .intg-sink-event {
    border: 1px solid var(--wf-outline-variant, #dadce0);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
}
#intg-sink-modal .intg-sink-event summary { cursor: pointer; font-size: 0.9em; }
#intg-sink-modal .intg-sink-event pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8em;
    background: var(--wf-surface-container, #f1f3f4);
    border-radius: 6px;
    padding: 10px;
    margin: 8px 0 2px;
}
#intg-delivery-modal pre,
#intg-delivery-modal #intg-delivery-modal-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: 0.85em;
    max-height: 55vh;
    overflow: auto;
    background: var(--wf-surface-container, #f8f9fa);
    border-radius: 8px;
    padding: 12px;
}

/* ── "How Integrations Work" ─────────────────────────────────
   Entry button + slide-in help panel. Same pattern and timing as the
   Workflow Designer's Shape Guide (wfd-guide-btn / wfdGuidePulse) —
   blue instead of brand orange, button on the LEFT. */
#view-integrations .intg-help-row { margin: 12px 0 2px; }
/* 40%-width bar on the left (where the eye lands on this screen):
   title + icon left, a plain "Help" cue at its right end. */
#view-integrations .intg-help-btn {
    display: flex;
    width: 40%;
    min-width: 300px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border: 1px solid var(--wf-primary, #1a73e8);
    border-radius: 10px;
    background: var(--wf-primary-container, #e8f0fe);
    color: var(--wf-on-primary-container, #174ea6);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, box-shadow 0.15s;
}
#view-integrations .intg-help-btn .material-symbols-outlined {
    font-size: 18px;
    color: var(--wf-primary, #1a73e8);
}
#view-integrations .intg-help-btn__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
#view-integrations .intg-help-btn__cta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--wf-primary, #1a73e8);
    white-space: nowrap;
}
#view-integrations .intg-help-btn:hover {
    background: var(--wf-surface, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
/* Nudge on every page load — identical timing to the Shape Guide: the ring
   shows at both ends of each 2.4s cycle, so 3 cycles read as 6 gentle flashes. */
#view-integrations .intg-help-btn--nudge {
    animation: intgHelpPulse 2.4s ease-in-out 3;
}
@keyframes intgHelpPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.45); }
    50% { box-shadow: 0 0 0 7px rgba(26, 115, 232, 0); }
}
/* LOUD nudge variant (21 Nov: subtle one was missed even by Vijay). Same 2.4s ×3
   timing as the base; louder visuals: stronger wider ring + background tint +
   bold label while it runs. To REVERT to the subtle nudge, change the class the
   JS adds in wfIntgInit back to 'intg-help-btn--nudge'. */
#view-integrations .intg-help-btn--nudge-loud {
    animation: intgHelpPulseLoud 2.4s ease-in-out 3;
    font-weight: 700;
}
@keyframes intgHelpPulseLoud {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.85);
        background: var(--wf-primary-container, #e8f0fe);
    }
    50% {
        box-shadow: 0 0 0 14px rgba(26, 115, 232, 0);
        background: #c6dafc;
    }
}

/* Slide-in panel (right, like the Shape Guide) */
.intg-help-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 440px;
    max-width: 92vw;
    display: flex;
    flex-direction: column;
    background: var(--wf-surface, #fff);
    border-left: 1px solid var(--wf-outline-variant, #e0e0e0);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(105%);
    transition: transform 0.25s ease;
    z-index: 950;
}
.intg-help-panel.is-open { transform: none; }
.intg-help-panel__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--wf-outline-variant, #e0e0e0);
}
.intg-help-panel__header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    color: var(--wf-on-surface, #202124);
}
.intg-help-panel__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--wf-on-surface-variant, #5f6368);
    cursor: pointer;
}
.intg-help-panel__close:hover {
    background: var(--wf-surface-container, #f1f3f4);
    color: var(--wf-on-surface, #202124);
}
.intg-help-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 20px;
}
.intg-help-panel__body .intg-help-intro {
    font-size: 0.9em;
    line-height: 1.55;
    color: var(--wf-on-surface-variant, #5f6368);
    margin: 6px 0 14px;
}
.intg-help-panel__body .intg-help-sec {
    border: 1px solid var(--wf-outline-variant, #e0e0e0);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.intg-help-panel__body .intg-help-sec__head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.92em;
    margin-bottom: 8px;
    cursor: pointer;
    list-style: none;
}
.intg-help-panel__body .intg-help-sec__head::-webkit-details-marker { display: none; }
/* Collapse cue, sitting right next to the number+title, flips when open */
.intg-help-panel__body .intg-help-sec__head::after {
    content: '▾';
    margin-left: 6px;
    font-size: 0.78em;
    color: var(--wf-on-surface-variant, #80868b);
    transition: transform 0.15s;
}
.intg-help-panel__body details.intg-help-sec:not([open]) > .intg-help-sec__head { margin-bottom: 0; }
.intg-help-panel__body details.intg-help-sec:not([open]) > .intg-help-sec__head::after { transform: rotate(-90deg); }
.intg-help-panel__body .intg-help-sec__num {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--wf-primary, #1a73e8);
    color: #fff;
    font-size: 0.78em;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.intg-help-panel__body .intg-help-sec__tag {
    font-weight: 400;
    font-size: 0.85em;
    color: var(--wf-on-surface-variant, #70757a);
}
.intg-help-panel__body .intg-help-sec__items {
    margin: 0;
    padding-left: 20px;
    list-style: circle;
    font-size: 0.88em;
    line-height: 1.55;
}
.intg-help-panel__body .intg-help-sec__items li { margin-bottom: 8px; }
.intg-help-panel__body .intg-help-sec__items li:last-child { margin-bottom: 0; }

/* Section hints in the mapping editor */
#view-integrations .intg-section__hint { margin: -2px 0 8px; }

/* Receiver setup guide modal — Firebase-onboarding look:
   framing strip, numbered section cards, collapsible docs */
#intg-guide-modal .intg-guide-frame {
    display: inline-block;
    background: var(--wf-surface-container, #f1f3f4);
    border: 1px solid var(--wf-outline-variant, #e0e0e0);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.88em;
    color: var(--wf-on-surface-variant, #5f6368);
}
#intg-guide-modal .intg-guide-sec {
    border: 1px solid var(--wf-outline-variant, #e0e0e0);
    border-radius: 10px;
    background: var(--wf-surface, #fff);
    padding: 12px 16px;
    margin-bottom: 12px;
}
#intg-guide-modal .intg-guide-sec__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
#intg-guide-modal .intg-guide-sec__num {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--wf-primary, #1a73e8);
    color: #fff;
    font-size: 0.82em;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#intg-guide-modal .intg-guide-sec__title { font-weight: 600; }
#intg-guide-modal .intg-guide-sec__steps {
    margin: 0;
    padding-left: 34px;
    list-style: circle;
    font-size: 0.92em;
    line-height: 1.55;
}
#intg-guide-modal .intg-guide-sec__steps li { margin-bottom: 8px; }
#intg-guide-modal .intg-guide-sec__steps li:last-child { margin-bottom: 0; }
#intg-guide-modal .intg-guide-docs {
    border: 1px solid var(--wf-outline-variant, #e0e0e0);
    border-radius: 10px;
    padding: 10px 16px;
    margin-top: 4px;
}
#intg-guide-modal .intg-guide-docs summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92em;
}
#intg-guide-modal .intg-guide-docs ul {
    margin: 10px 0 4px;
    padding-left: 20px;
    font-size: 0.92em;
    line-height: 1.7;
}

@media (max-width: 640px) {
    #view-integrations .intg-row { flex-direction: column; align-items: flex-start; }
    #view-integrations .intg-url { max-width: 160px; }
}
