/* Settings tab: Connections / Notifications / General / License sub-tabs. */

.iafwzc-settings-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--iafwzc-border-100, #eceef5);
    margin-bottom: 20px;
}

.iafwzc-settings-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 4px;
    margin-right: 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--iafwzc-muted-text, #8a8fa6);
    cursor: pointer;
}

.iafwzc-settings-tab:hover {
    color: var(--iafwzc-body-text, #4a4f66);
}

.iafwzc-settings-tab[aria-selected="true"] {
    color: var(--iafwzc-primary-text, #5b3fe0);
    border-bottom-color: var(--iafwzc-primary-grad-end, #6a4cf0);
}

.iafwzc-settings-section {
    display: none;
}

.iafwzc-settings-section-active {
    display: block;
}

.iafwzc-settings-group {
    display: none;
}

.iafwzc-settings-group-active {
    display: block;
}

/* ── Notifications / General: one card per setting ── */
.iafwzc-settings-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 820px;
    box-sizing: border-box;
    padding: 22px;
    /* One shared white panel with an outer border for General and Notifications. */
    background: var(--iafwzc-card-bg, #fff);
    border: 1px solid var(--iafwzc-border-100, #eceef5);
    border-radius: var(--iafwzc-radius-md, 14px);
    box-shadow: var(--iafwzc-shadow-card, 0 4px 16px rgba(20, 22, 50, .04));
}

.iafwzc-settings-group-active {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.iafwzc-setting-card {
    background: var(--iafwzc-card-bg, #fff);
    border: 1px solid var(--iafwzc-border-100, #eceef5);
    border-radius: 14px;
}

.iafwzc-setting-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px 24px;
}

.iafwzc-setting-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.iafwzc-setting-icon--error {
    background: var(--iafwzc-error-bg, #fdecec);
    color: var(--iafwzc-error, #e0393e);
}

.iafwzc-setting-icon--warn {
    background: #fef4e2;
    color: #f59e0b;
}

.iafwzc-setting-icon--neutral {
    background: #f1f2f6;
    color: #6b7085;
}

.iafwzc-setting-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.iafwzc-setting-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--iafwzc-ink, #1b1d2a);
    cursor: pointer;
}

.iafwzc-setting-desc {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--iafwzc-muted-text, #8a8fa6);
}

.iafwzc-setting-warning {
    align-self: flex-start;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #fff4ec;
    color: #c2410c;
    font-size: 12.5px;
    font-weight: 600;
}

.iafwzc-setting-warning[hidden],
.iafwzc-setting-panel[hidden] {
    display: none;
}

/* Expanded options of a setting that is switched on. */
.iafwzc-setting-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 20px 24px 24px 80px;
    border-top: 1px solid var(--iafwzc-border-300, #f1f2f7);
}

.iafwzc-setting-panel--two {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.iafwzc-setting-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.iafwzc-setting-field--narrow {
    max-width: 420px;
}

.iafwzc-setting-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--iafwzc-ink, #1b1d2a);
}

#wpcontent .iafwzc-setting-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--iafwzc-border-200, #e4e6ef);
    border-radius: 12px;
    background: #f8f9fc;
    box-shadow: none;
    font-size: 14px;
    color: var(--iafwzc-ink, #1b1d2a);
}

#wpcontent .iafwzc-setting-input:focus {
    border-color: var(--iafwzc-primary-grad-start, #8b6cf8);
    box-shadow: 0 0 0 3px #ece7fe;
    background: #fff;
    outline: none;
}

/* On / off switch: a real checkbox underneath, so the form and the keyboard work as before. */
.iafwzc-switch {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: 46px;
    height: 26px;
}

#wpcontent .iafwzc-switch-input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.iafwzc-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #d9dce6;
    transition: background-color .18s ease;
}

.iafwzc-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: left .18s ease;
}

.iafwzc-switch-input:checked + .iafwzc-switch-track {
    background: linear-gradient(135deg, var(--iafwzc-primary-grad-start, #8b6cf8), var(--iafwzc-primary-grad-end, #6a4cf0));
}

.iafwzc-switch-input:checked + .iafwzc-switch-track::after {
    left: 23px;
}

.iafwzc-switch-input:focus-visible + .iafwzc-switch-track {
    outline: 2px solid var(--iafwzc-primary-grad-end, #6a4cf0);
    outline-offset: 2px;
}

.iafwzc-setting-actions {
    display: flex;
    justify-content: flex-end;
}

#wpcontent .iafwzc-settings-save {
    height: 44px;
    padding: 0 22px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--iafwzc-primary-grad-start, #8b6cf8), var(--iafwzc-primary-grad-end, #6a4cf0));
    font-size: 14.5px;
    box-shadow: 0 10px 24px -10px rgba(106, 76, 240, .6);
}

#wpcontent .iafwzc-settings-save:disabled {
    opacity: .6;
    cursor: not-allowed;
}

@media (max-width: 782px) {
    .iafwzc-setting-head {
        padding: 18px 16px;
    }

    .iafwzc-setting-panel {
        padding: 16px;
    }
}

/* ── Connections hint / empty guidance ── */
.iafwzc-connections-hint {
    background: var(--iafwzc-lavender-300, #f5f2ff);
    border: 1px solid var(--iafwzc-lavender-border-100, #d9cffb);
    border-radius: var(--iafwzc-radius-sm, 8px);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--iafwzc-body-text, #4a4f66);
    font-size: 13.5px;
}

.iafwzc-connections-hint p {
    margin: 0;
}

/* ── Service badges ── */
.iafwzc-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--iafwzc-radius-pill, 999px);
    font-size: 12px;
    font-weight: 700;
    background: var(--iafwzc-border-300, #f1f2f7);
    color: var(--iafwzc-body-text, #4a4f66);
}

.iafwzc-badge.iafwzc-conn-badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
}

/* Connections table: status pill and the Test connection spinner. */
.iafwzc-conn-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--iafwzc-radius-pill, 999px);
    background: var(--iafwzc-success-bg, #e8f8f1);
    color: var(--iafwzc-success-dark, #0f9f6e);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.iafwzc-conn-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--iafwzc-success, #10b981);
}

.iafwzc-conn-status.is-error {
    background: var(--iafwzc-error-bg, #fdecec);
    color: var(--iafwzc-error-dark, #d23339);
}

.iafwzc-conn-status.is-error .iafwzc-conn-status-dot {
    background: var(--iafwzc-error, #e0393e);
}

.iafwzc-row-menu-spinner {
    width: 14px;
    height: 14px;
    margin-left: auto;
    border: 2px solid var(--iafwzc-lavender-border-200, #e3dcfc);
    border-top-color: var(--iafwzc-primary-text, #5b3fe0);
    border-radius: 50%;
    animation: iafwzc-spin .7s linear infinite;
}

.iafwzc-row-menu-spinner[hidden] {
    display: none;
}

.iafwzc-badge-crm {
    background: var(--iafwzc-crm-bg, #efeafe);
    color: var(--iafwzc-crm-text, #6a4cf0);
}

.iafwzc-badge-bigin {
    background: var(--iafwzc-bigin-bg, #e8f0fe);
    color: var(--iafwzc-bigin-text, #2f6fdf);
}

/* ── Notification fields: hint, invalid state, Save button loading ── */
.iafwzc-setting-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #7a7f99;
}

.iafwzc-setting-input.iafwzc-setting-input--invalid,
#wpcontent .iafwzc-setting-input.iafwzc-setting-input--invalid {
    border-color: #e5484d;
    box-shadow: 0 0 0 3px rgba(229, 72, 77, .15);
}

#wpcontent .iafwzc-settings-save.iafwzc-loading,
#wpcontent .iafwzc-settings-save.iafwzc-loading:disabled {
    opacity: .85;
    cursor: not-allowed;
}

.iafwzc-settings-save.iafwzc-loading::before {
    content: "";
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: iafwzc-save-spin .7s linear infinite;
}

@keyframes iafwzc-save-spin {
    to { transform: rotate(360deg); }
}

/* ── License tab (same panel / card / field look as General and Notifications) ── */
.iafwzc-license-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 40px;
    padding: 16px 24px 16px 80px;
    border-top: 1px solid var(--iafwzc-border-300, #f1f2f7);
}

.iafwzc-license-fact {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.iafwzc-license-value {
    display: inline-block;
    align-self: flex-start;
    padding: 4px 12px;
    border-radius: 999px;
    background: #ede9fe;
    color: var(--iafwzc-primary-grad-end, #6a4cf0);
    font-size: 13.5px;
    font-weight: 700;
}

.iafwzc-license-form .iafwzc-setting-desc a {
    color: var(--iafwzc-primary-grad-end, #6a4cf0);
    font-weight: 600;
    text-decoration: none;
}

.iafwzc-license-form .iafwzc-setting-desc a:hover {
    text-decoration: underline;
}

@media (max-width: 782px) {
    .iafwzc-license-facts {
        padding: 14px 16px;
    }
}

/* WP's blue focus ring showed on the link after a click (it opens a new tab). No ring on mouse
   click; keyboard focus keeps a soft purple one. */
.iafwzc-license-form .iafwzc-setting-desc a:focus,
.iafwzc-license-form .iafwzc-setting-desc a:active {
    outline: none;
    box-shadow: none;
    color: var(--iafwzc-primary-grad-end, #6a4cf0);
}

.iafwzc-license-form .iafwzc-setting-desc a:focus-visible {
    box-shadow: 0 0 0 3px rgba(106, 76, 240, 0.35);
    border-radius: 4px;
}

/* ── License tab: active-license summary card ── */
.iafwzc-license-hero {
    border: 1px solid var(--iafwzc-border-100, #eceef5);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}

.iafwzc-license-hero-top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    background: linear-gradient(135deg, #f5f2ff 0%, #ffffff 70%);
    border-bottom: 1px solid var(--iafwzc-border-300, #f1f2f7);
}

.iafwzc-license-hero-icon {
    background: linear-gradient(135deg, var(--iafwzc-primary-grad-start, #8b6cf8), var(--iafwzc-primary-grad-end, #6a4cf0));
    color: #fff;
    box-shadow: 0 8px 18px -8px rgba(106, 76, 240, .6);
}

.iafwzc-license-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 999px;
    background: #e7f7ee;
    color: #138a4b;
    font-size: 12.5px;
    font-weight: 700;
}

.iafwzc-license-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.iafwzc-license-status--off {
    background: #fdecec;
    color: #e0393e;
}

.iafwzc-license-keybox {
    padding: 18px 24px;
}

.iafwzc-license-keybox-label,
.iafwzc-license-tile-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--iafwzc-muted-text, #8a8fa6);
}

.iafwzc-license-keyrow {
    display: flex;
    align-items: center;
    gap: 10px;
}

.iafwzc-license-key-masked {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid var(--iafwzc-border-200, #e4e6ef);
    border-radius: 12px;
    background: #f8f9fc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    letter-spacing: .06em;
    color: var(--iafwzc-ink, #1b1d2a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.iafwzc-license-copy {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--iafwzc-border-200, #e4e6ef);
    border-radius: 12px;
    background: #fff;
    color: var(--iafwzc-primary-grad-end, #6a4cf0);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.iafwzc-license-copy:hover,
.iafwzc-license-copy:focus {
    background: #f3f0ff;
    border-color: var(--iafwzc-primary-grad-start, #8b6cf8);
    outline: none;
    box-shadow: none;
}

.iafwzc-license-copy svg {
    display: block;
}

.iafwzc-license-copy .iafwzc-check-icon {
    display: none;
}

.iafwzc-license-copy.iafwzc-copied {
    background: #e7f7ee;
    border-color: #138a4b;
    color: #138a4b;
}

.iafwzc-license-copy.iafwzc-copied .iafwzc-copy-icon {
    display: none;
}

.iafwzc-license-copy.iafwzc-copied .iafwzc-check-icon {
    display: block;
}

.iafwzc-license-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 24px 22px;
}

.iafwzc-license-tile {
    padding: 14px 16px;
    border: 1px solid var(--iafwzc-border-100, #eceef5);
    border-radius: 12px;
    background: #fbfbfe;
}

.iafwzc-license-tile-label {
    margin-bottom: 6px;
}

.iafwzc-license-tile-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--iafwzc-ink, #1b1d2a);
}

@media (max-width: 782px) {
    .iafwzc-license-hero-top {
        flex-wrap: wrap;
        padding: 18px 16px;
    }
    .iafwzc-license-keybox {
        padding: 16px;
    }
    .iafwzc-license-tiles {
        grid-template-columns: minmax(0, 1fr);
        padding: 0 16px 18px;
    }
}

.iafwzc-license-status--idle {
    background: #f1f2f6;
    color: #6b7085;
}

/* Add / edit connection popup (Settings): error banner inside the wizard-style modal. */
#iafwzc-auth-popupOverlay .iafwzc-auth-message {
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
}
#iafwzc-auth-popupOverlay .iafwzc-auth-error { background: #fdecec; color: #c0282d; border: 1px solid #f6c9cb; }
#iafwzc-auth-popupOverlay .iafwzc-auth-success { background: #e7f7ee; color: #138a4b; border: 1px solid #bfe8d0; }

/* Status column: pill with a "Test connection" button under it. */
.iafwzc-conn-status-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.iafwzc-conn-test-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 9px;
    border: 1px solid #e3dcfc;
    border-radius: 7px;
    background: #f5f2ff;
    color: #5b3fe0;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.iafwzc-conn-test-btn:hover,
.iafwzc-conn-test-btn:focus {
    background: #ebe5ff;
    border-color: #c9bdfb;
    color: #5b3fe0;
    outline: none;
    box-shadow: none;
}

.iafwzc-conn-test-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(106, 76, 240, .3);
}

.iafwzc-conn-test-btn svg {
    flex-shrink: 0;
    display: block;
}

.iafwzc-conn-test-btn:disabled,
.iafwzc-conn-test-btn.iafwzc-loading {
    cursor: not-allowed;
    opacity: .85;
}

.iafwzc-conn-test-btn.iafwzc-loading svg {
    display: none;
}

.iafwzc-conn-test-btn.iafwzc-loading::before {
    content: "";
    flex-shrink: 0;
    width: 11px;
    height: 11px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid #c9bdfb;
    border-top-color: #5b3fe0;
    animation: iafwzc-test-spin .7s linear infinite;
}

@keyframes iafwzc-test-spin {
    to { transform: rotate(360deg); }
}

/* Status column: only the Test connection button, same look as the Reconnect button. */
.iafwzc-conn-test-btn {
    height: 30px;
    padding: 0 10px;
    box-sizing: border-box;
    gap: 5px;
    border: 1px solid var(--iafwzc-border-200, #e4e6ef);
    border-radius: 8px;
    background: #fff;
    color: #5b3fe0;
    font-size: 12.5px;
}

.iafwzc-conn-test-btn:hover,
.iafwzc-conn-test-btn:focus {
    background: #f5f2ff;
    border-color: #c9bdfb;
}

.iafwzc-conn-test-btn.iafwzc-loading svg {
    display: block;
    animation: iafwzc-test-spin .8s linear infinite;
}

.iafwzc-conn-test-btn.iafwzc-loading::before {
    content: none;
}

/* Add / edit connection popup while it sends you to Zoho: blocked buttons + spinner. */
#iafwzc-auth-popupOverlay .iafwzc-conn-modal-foot button:disabled,
#iafwzc-auth-popupOverlay .iafwzc-conn-modal-close:disabled {
    cursor: not-allowed;
    opacity: .6;
}

#iafwzc-auth-popupOverlay .iafwzc-conn-modal-foot .iafwzc-loading,
#iafwzc-auth-popupOverlay .iafwzc-conn-modal-foot .iafwzc-loading:disabled {
    opacity: .9;
    cursor: not-allowed;
}

#iafwzc-auth-popupOverlay .iafwzc-conn-modal-foot .iafwzc-loading::before {
    content: "";
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: iafwzc-auth-spin .7s linear infinite;
}

@keyframes iafwzc-auth-spin {
    to { transform: rotate(360deg); }
}

/* Connections table: "Modified" cell (date, then time and how long ago). */
.iafwzc-modified-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.iafwzc-modified-date {
    font-weight: 600;
    color: var(--iafwzc-ink, #1b1d2a);
}

.iafwzc-modified-time {
    font-size: 11.5px;
    color: var(--iafwzc-muted-text, #8a8fa6);
}

/* Edit connection: the other Zoho product is locked. */
#iafwzc-auth-popupOverlay .iafwzc-conn-product:has(input:disabled) {
    opacity: .5;
    background: #f4f5f9;
    cursor: not-allowed;
}

#iafwzc-auth-popupOverlay .iafwzc-conn-product:has(input:disabled):hover {
    border-color: var(--iafwzc-border-200, #e4e6ef);
}

#iafwzc-auth-popupOverlay .iafwzc-conn-lock-note {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #7a7f99;
}

#iafwzc-auth-popupOverlay .iafwzc-conn-lock-note[hidden] {
    display: none;
}

/* "Reconnect needed" badge beside a connection's Test connection button. */
.iafwzc-reconnect-badge {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #fdecec;
    color: #c0282d;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: help;
}

/* "Add Connection" inside the empty Connections message: a button that looks like a link. */
.iafwzc-hint-link {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--iafwzc-primary-text, #5b3fe0);
    text-decoration: underline;
    cursor: pointer;
}

.iafwzc-hint-link:hover {
    color: var(--iafwzc-primary-text-hover, #4b31c9);
}

.iafwzc-hint-link:focus-visible {
    outline: 2px solid var(--iafwzc-primary-grad-start, #8b6cf8);
    outline-offset: 2px;
    border-radius: 2px;
}
