/* -----------------------------------------------------------------------------
   Sync config header row
   ----------------------------------------------------------------------------- */

.sync-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-1);
}

.sync-config-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0;
}

    .sync-config-title i {
        color: var(--primary);
    }

/* compat aliases */
.sync-sections-container,
.sync-config-wrapper {
    display: flex;
    flex-direction: column;
}

.sync-sections-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-1);
}

.sync-sections-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0;
}

    .sync-sections-title i {
        color: var(--primary);
    }

/* -----------------------------------------------------------------------------
   Section cards list — gap between cards
   ----------------------------------------------------------------------------- */

#dynamicFieldsFilters {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* -----------------------------------------------------------------------------
   Card shell
   ----------------------------------------------------------------------------- */

.if-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: box-shadow 0.22s ease, border-color 0.22s ease;
    margin-bottom: var(--space-3);
}

    .if-card:last-child {
        margin-bottom: 0;
    }

    .if-card:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,.09);
    }

    .if-card.open {
        /* rgba fallback for browsers without color-mix */
        border-color: rgba(0, 98, 255, 0.3);
        border-color: color-mix(in srgb, var(--primary) 30%, var(--border-color));
        box-shadow: 0 2px 10px rgba(0,0,0,.07);
    }

    .if-card.always-open {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-light);
    }

/* -----------------------------------------------------------------------------
   Card header — clickable row
   ----------------------------------------------------------------------------- */

.if-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    background: transparent;
    transition: background 0.16s ease;
}

    .if-card-header:hover {
        background: var(--bg-secondary);
    }

/* number badge */
.section-num {
    min-width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.22s ease, color 0.22s ease;
}

.if-card.open .section-num {
    background: var(--primary);
    color: white;
}

/* auth icon */
.if-card-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-base);
    flex-shrink: 0;
}

.if-card-meta {
    flex: 1;
    min-width: 0;
}

    .if-card-meta h3 {
        font-size: var(--font-size-base);
        font-weight: var(--font-weight-semibold);
        color: var(--text-dark);
        margin: 0 0 2px 0;
        line-height: var(--line-height-tight);
    }

    .if-card-meta p {
        font-size: var(--font-size-xs);
        color: var(--text-light);
        margin: 0;
        line-height: var(--line-height-normal);
    }

.if-card-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.if-chevron {
    color: var(--text-light);
    font-size: .7rem;
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s ease;
    flex-shrink: 0;
}

.if-card.open .if-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

/* compat */
.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0;
}

.header-content {
    flex: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.header-content h6 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0 0 2px 0;
}

.header-content p {
    font-size: var(--font-size-xs);
    color: var(--text-light);
    margin: 0;
}

.toggle-icon {
    color: var(--text-light);
    font-size: .7rem;
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1), color 0.18s ease;
}

/* -----------------------------------------------------------------------------
   Card body — accordion
   Uses max-height as the primary cross-browser approach with a grid-template-rows
   enhancement on top for browsers that support it (Chrome 101+, Safari 16+).
   ----------------------------------------------------------------------------- */

.if-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.if-card.open .if-card-body,
.if-card.always-open .if-card-body {
    max-height: 2000px;
    transition: max-height 0.38s cubic-bezier(0.0, 0, 0.2, 1);
}

/* grid accordion enhancement for supporting browsers */
@supports (grid-template-rows: 0fr) {
    .if-card-body {
        display: grid;
        grid-template-rows: 0fr;
        max-height: none;
        overflow: visible;
        transition: grid-template-rows 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .if-card.open .if-card-body,
    .if-card.always-open .if-card-body {
        grid-template-rows: 1fr;
        max-height: none;
    }
}

.if-card-inner {
    overflow: hidden;
    min-height: 0;
    padding: 0 var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    border-top: 1px solid transparent;
    transition: padding 0.28s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.15s ease;
}

.if-card.open .if-card-inner,
.if-card.always-open .if-card-inner {
    padding: var(--space-5);
    border-color: var(--border-color);
}

/* -----------------------------------------------------------------------------
   Advanced filters — max-height accordion (intentional; nested grid breaks)
   ----------------------------------------------------------------------------- */

.if-advanced {
    margin-top: calc(-1 * var(--space-1));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-primary);
    transition: border-color 0.18s ease;
}

    /* :has() progressive enhancement — ignored on non-supporting browsers gracefully */
    .if-advanced:has(.if-advanced-toggle.open) {
        /* rgba fallback for browsers without color-mix */
        border-color: rgba(0, 98, 255, 0.4);
        border-color: color-mix(in srgb, var(--primary) 40%, var(--border-color));
    }

    /* JS adds .if-advanced--open for browsers without :has() support */
    .if-advanced.if-advanced--open {
        border-color: rgba(0, 98, 255, 0.4);
        border-color: color-mix(in srgb, var(--primary) 40%, var(--border-color));
    }

.if-advanced-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px var(--space-4);
    background: var(--bg-secondary);
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-medium);
    font-family: var(--font-family);
    -webkit-user-select: none;
    user-select: none;
    text-align: left;
    gap: var(--space-2);
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

    .if-advanced-toggle > span {
        display: flex;
        align-items: center;
        gap: var(--space-2);
    }

        .if-advanced-toggle > span > i {
            font-size: .72rem;
            color: var(--primary);
            flex-shrink: 0;
        }

    .if-advanced-toggle:hover {
        /* rgba fallback for browsers without color-mix */
        background: rgba(0, 98, 255, 0.06);
        background: color-mix(in srgb, var(--primary) 6%, var(--bg-secondary));
        color: var(--primary);
    }

    .if-advanced-toggle.open {
        color: var(--primary);
        font-weight: var(--font-weight-semibold);
        border-bottom-color: var(--border-color);
    }

.adv-chevron {
    font-size: .62rem;
    color: var(--text-light);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
    flex-shrink: 0;
}

.if-advanced-toggle.open .adv-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

.if-advanced-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .if-advanced-panel.open {
        max-height: 1200px;
        transition: max-height 0.38s cubic-bezier(0.0, 0, 0.2, 1);
    }

.if-advanced-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-primary);
    border-left: 3px solid var(--primary);
}

/* -----------------------------------------------------------------------------
   Compat / legacy aliases
   ----------------------------------------------------------------------------- */

.sync-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.sync-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.sync-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sync-section.open .sync-section-content {
    max-height: 2000px;
    transition: max-height 0.38s cubic-bezier(0.0, 0, 0.2, 1);
}

@supports (grid-template-rows: 0fr) {
    .sync-section-content {
        display: grid;
        grid-template-rows: 0fr;
        max-height: none;
        overflow: visible;
        transition: grid-template-rows 0.28s cubic-bezier(0.4,0,0.2,1);
    }

    .sync-section.open .sync-section-content {
        grid-template-rows: 1fr;
        max-height: none;
    }
}

.section-content {
    overflow: hidden;
    min-height: 0;
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.section-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.section-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: var(--font-size-lg);
}

.section-title-group {
    flex: 1;
}

.section-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0 0 var(--space-1) 0;
}

.section-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-light);
    margin: 0;
}

.section-number {
    min-width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.authentication-section {
    background: var(--bg-primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: 0 0 0 2px var(--primary-light);
}
