// Integrations Page Styles

.integrations-container {
    margin: 0 auto;
    padding: 30px 20px;
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    position: relative;

    &.pro-locked {
        opacity: 0.9;
    }
}

.integrations-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;

    .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f4f6;
        border-top-color: #4a6cf7;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    p {
        margin-top: 16px;
        color: #64748b;
        font-size: 14px;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.integrations-header {
    margin-bottom: 30px;

    h1 {
        font-size: 28px;
        font-weight: 700;
        color: #1e293b;
        margin-bottom: 8px;
    }

    p {
        font-size: 16px;
        color: #64748b;
    }
}

// Pro Lock Overlay for Full Page
.pro-overlay-full {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 10px;
    background: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;

    &:hover {
        background: rgba(255, 255, 255, 0.4);

        .pro-badge-large {
            transform: scale(1.05);
            box-shadow: 0 8px 32px rgba(74, 108, 247, 0.4);
        }
    }

    .pro-badge-large {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 10px 20px;
        background: linear-gradient(135deg, #4a6cf7, #3c57d0);
        color: white;
        border-radius: 50px;
        font-size: 14px;
        font-weight: 700;
        box-shadow: 0 4px 16px rgba(74, 108, 247, 0.3);
        transition: all 0.3s ease;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        z-index: 5;

        .lock-icon {
            width: 25px;
            height: 25px;
            animation: lock-pulse 2s ease-in-out infinite;
        }

    }
}

@keyframes lock-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

// Integrations Grid
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

// Integration Card
.integration-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    display: flex;
    gap: 20px;

    &:hover:not(.disabled) {
        border-color: #4a6cf7;
        box-shadow: 0 4px 12px rgba(74, 108, 247, 0.15);
        transform: translateY(-2px);
    }

    &.enabled {
        border-color: #10b981;
        background: linear-gradient(to bottom, white, #f0fdf4);
    }

    &.disabled {
        opacity: 0.8;
        cursor: not-allowed;
    }

    .integration-icon {
        flex-shrink: 0;
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, #4a6cf7, #3c57d0);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;

        svg {
            font-size: 32px;
        }
    }

    .integration-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .integration-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;

        .integration-title-group {
            display: flex;
            align-items: center;
            gap: 8px;

            h3 {
                font-size: 18px;
                font-weight: 600;
                color: #1e293b;
                margin: 0;
            }

            .help-icon-button {
                background: transparent;
                border: none;
                color: #64748b;
                cursor: pointer;
                padding: 4px;
                display: flex;
                align-items: center;
                justify-content: center;
                border-radius: 50%;
                transition: all 0.2s ease;

                svg {
                    font-size: 20px;
                }

                &:hover {
                    background: #f1f5f9;
                    color: #4a6cf7;
                }

                &:active {
                    transform: scale(0.95);
                }
            }
        }
    }

    .integration-status {
        .status-badge {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
            white-space: nowrap;

            svg {
                font-size: 14px;
            }

            &.configured {
                background: #d1fae5;
                color: #065f46;
            }

            &.not-configured {
                background: #fee2e2;
                color: #991b1b;
            }
        }
    }

    .integration-description {
        font-size: 14px;
        color: #64748b;
        line-height: 1.5;
        margin: 0;
    }

    .integration-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: auto;

        .settings-button {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            background: transparent;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            color: #4b5563;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;

            svg {
                font-size: 18px;
            }

            &:hover:not(:disabled) {
                background: #f9fafb;
                border-color: #4a6cf7;
                color: #4a6cf7;
            }

            &:disabled {
                opacity: 0.5;
                cursor: not-allowed;
            }
        }

        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 48px;
            height: 26px;
            flex-shrink: 0;

            input[type="checkbox"] {
                opacity: 0;
                width: 0;
                height: 0;

                &:checked+.toggle-slider {
                    background: linear-gradient(135deg, #10b981, #059669);
                }

                &:checked+.toggle-slider:before {
                    transform: translateX(22px);
                }

                &:focus+.toggle-slider {
                    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
                }

                &:disabled+.toggle-slider {
                    opacity: 0.5;
                    cursor: not-allowed;
                }
            }

            .toggle-slider {
                position: absolute;
                cursor: pointer;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-color: #cbd5e1;
                transition: all 0.3s ease;
                border-radius: 26px;

                &:before {
                    position: absolute;
                    content: "";
                    height: 20px;
                    width: 20px;
                    left: 3px;
                    bottom: 3px;
                    background-color: white;
                    transition: all 0.3s ease;
                    border-radius: 50%;
                    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
                }

                &:hover {
                    background-color: #94a3b8;
                }
            }
        }
    }
}

// No Integrations Message
.no-integrations {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;

    p {
        font-size: 16px;
    }
}

// Integration Modal
.integration-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.integration-modal {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;

    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 24px;
        border-bottom: 1px solid #e5e7eb;

        h2 {
            font-size: 20px;
            font-weight: 600;
            color: #1e293b;
            margin: 0;
        }

        .close-button {
            background: transparent;
            border: none;
            color: #64748b;
            cursor: pointer;
            padding: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            transition: all 0.2s ease;

            svg {
                font-size: 24px;
            }

            &:hover {
                background: #f1f5f9;
                color: #1e293b;
            }
        }
    }

    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 24px;

        .modal-description {
            font-size: 14px;
            color: #64748b;
            margin-bottom: 24px;
        }

        .config-fields {
            display: flex;
            flex-direction: column;
            gap: 20px;

            .field-group {
                display: flex;
                flex-direction: column;
                gap: 8px;

                label {
                    font-size: 14px;
                    font-weight: 600;
                    color: #374151;

                    .required {
                        color: #ef4444;
                        margin-left: 4px;
                    }
                }

                input[type="text"],
                input[type="password"],
                input[type="email"],
                input[type="url"],
                textarea,
                select {
                    padding: 10px 14px;
                    border: 1px solid #d1d5db;
                    border-radius: 8px;
                    font-size: 14px;
                    color: #1e293b;
                    transition: all 0.2s ease;
                    font-family: inherit;

                    &:focus {
                        outline: none;
                        border-color: #4a6cf7;
                        box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
                    }
                }

                textarea {
                    resize: vertical;
                    min-height: 80px;
                }

                .checkbox-label {
                    display: flex;
                    align-items: center;
                    gap: 8px;
                    cursor: pointer;

                    input[type="checkbox"] {
                        width: 18px;
                        height: 18px;
                        cursor: pointer;
                        accent-color: #4a6cf7;
                    }

                    span {
                        font-size: 14px;
                        font-weight: 500;
                        color: #374151;
                    }
                }

                .field-description {
                    font-size: 12px;
                    color: #6b7280;
                    line-height: 1.4;
                }
            }
        }

        .test-result {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 12px 16px;
            border-radius: 8px;
            font-size: 14px;
            margin-top: 16px;

            svg {
                font-size: 20px;
            }

            &.success {
                background: #d1fae5;
                color: #065f46;
            }

            &.error {
                background: #fee2e2;
                color: #991b1b;
            }
        }
    }

    .modal-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px 24px;
        border-top: 1px solid #e5e7eb;

        .test-button {
            padding: 10px 20px;
            background: transparent;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            color: #4b5563;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;

            &:hover:not(:disabled) {
                background: #f9fafb;
                border-color: #4a6cf7;
                color: #4a6cf7;
            }

            &:disabled {
                opacity: 0.5;
                cursor: not-allowed;
            }
        }

        .action-buttons {
            display: flex;
            gap: 12px;

            button {
                padding: 10px 20px;
                border-radius: 8px;
                font-size: 14px;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.2s ease;
                display: flex;
                align-items: center;
                gap: 6px;

                svg {
                    font-size: 18px;
                }
            }

            .cancel-button {
                background: transparent;
                border: 1px solid #d1d5db;
                color: #4b5563;

                &:hover:not(:disabled) {
                    background: #f9fafb;
                }

                &:disabled {
                    opacity: 0.5;
                    cursor: not-allowed;
                }
            }

            .save-button {
                background: linear-gradient(135deg, #4a6cf7, #3c57d0);
                border: none;
                color: white;
                box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);

                &:hover:not(:disabled) {
                    background: linear-gradient(135deg, #3c57d0, #2d42a0);
                    transform: translateY(-1px);
                    box-shadow: 0 6px 16px rgba(74, 108, 247, 0.4);
                }

                &:disabled {
                    opacity: 0.6;
                    cursor: not-allowed;
                }
            }
        }
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

// Responsive Design
@media (max-width: 768px) {
    .integrations-container {
        padding: 20px 15px;
    }

    .integrations-header {
        h1 {
            font-size: 24px;
        }

        p {
            font-size: 14px;
        }
    }

    .integrations-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .integration-card {
        flex-direction: column;
        align-items: flex-start;

        .integration-icon {
            width: 48px;
            height: 48px;

            svg {
                font-size: 28px;
            }
        }

        .integration-actions {
            width: 100%;
        }
    }

    .integration-modal {
        max-height: 95vh;

        .modal-header,
        .modal-body,
        .modal-footer {
            padding: 16px;
        }

        .modal-footer {
            flex-direction: column;
            gap: 12px;

            .test-button,
            .action-buttons {
                width: 100%;
            }

            .action-buttons {
                button {
                    flex: 1;
                }
            }
        }
    }

    .pro-overlay-full {
        .pro-badge-large {
            padding: 24px 32px;

            .lock-icon {
                width: 40px;
                height: 40px;
            }

            span {
                font-size: 18px;
            }

            p {
                font-size: 13px;
            }
        }
    }
}


// Integration Help Modal
.integration-help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.integration-help-modal {
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;

    .help-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 24px;
        border-bottom: 1px solid #e5e7eb;

        .help-modal-title {
            display: flex;
            align-items: center;
            gap: 12px;

            svg {
                font-size: 28px;
                color: #4a6cf7;
            }

            h2 {
                font-size: 22px;
                font-weight: 600;
                color: #1e293b;
                margin: 0;
            }
        }

        .close-button {
            background: transparent;
            border: none;
            color: #64748b;
            cursor: pointer;
            padding: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            transition: all 0.2s ease;

            svg {
                font-size: 24px;
            }

            &:hover {
                background: #f1f5f9;
                color: #1e293b;
            }
        }
    }

    .help-modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 24px;

        .help-instructions {
            margin-bottom: 32px;

            h3 {
                font-size: 18px;
                font-weight: 600;
                color: #1e293b;
                margin-bottom: 16px;
            }

            .help-steps {
                list-style: none;
                counter-reset: step-counter;
                padding: 0;
                margin: 0;

                li {
                    counter-increment: step-counter;
                    position: relative;
                    padding: 12px 12px 12px 48px;
                    margin-bottom: 12px;
                    background: #f8fafc;
                    border-radius: 8px;
                    border-left: 3px solid #4a6cf7;
                    font-size: 14px;
                    line-height: 1.6;
                    color: #475569;
                    transition: all 0.2s ease;

                    &:before {
                        content: counter(step-counter);
                        position: absolute;
                        left: 12px;
                        top: 50%;
                        transform: translateY(-50%);
                        width: 24px;
                        height: 24px;
                        background: linear-gradient(135deg, #4a6cf7, #3c57d0);
                        color: white;
                        border-radius: 50%;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        font-size: 12px;
                        font-weight: 600;
                    }

                    &:hover {
                        background: #f1f5f9;
                        transform: translateX(4px);
                    }
                }
            }
        }

        .help-video {
            h3 {
                font-size: 18px;
                font-weight: 600;
                color: #1e293b;
                margin-bottom: 16px;
            }

            .video-container {
                position: relative;
                padding-bottom: 56.25%; // 16:9 aspect ratio
                height: 0;
                overflow: hidden;
                border-radius: 12px;
                background: #000;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

                iframe {
                    position: absolute;
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 100%;
                    border-radius: 12px;
                }
            }
        }
    }

    .help-modal-footer {
        padding: 20px 24px;
        border-top: 1px solid #e5e7eb;
        display: flex;
        justify-content: center;

        .close-help-button {
            padding: 12px 32px;
            background: linear-gradient(135deg, #4a6cf7, #3c57d0);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);

            &:hover {
                background: linear-gradient(135deg, #3c57d0, #2d42a0);
                transform: translateY(-2px);
                box-shadow: 0 6px 16px rgba(74, 108, 247, 0.4);
            }

            &:active {
                transform: translateY(0);
            }
        }
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

// Responsive for Help Modal
@media (max-width: 768px) {
    .integration-help-modal {
        max-height: 95vh;

        .help-modal-header,
        .help-modal-body,
        .help-modal-footer {
            padding: 16px;
        }

        .help-modal-header {
            .help-modal-title {
                h2 {
                    font-size: 18px;
                }

                svg {
                    font-size: 24px;
                }
            }
        }

        .help-modal-body {
            .help-instructions {
                h3 {
                    font-size: 16px;
                }

                .help-steps {
                    li {
                        font-size: 13px;
                        padding: 10px 10px 10px 42px;

                        &:before {
                            width: 22px;
                            height: 22px;
                            font-size: 11px;
                            left: 10px;
                        }
                    }
                }
            }

            .help-video {
                h3 {
                    font-size: 16px;
                }
            }
        }

        .help-modal-footer {
            .close-help-button {
                width: 100%;
            }
        }
    }
}

// Pro Lock Hover Effect for Individual Cards
.integration-card.pro-locked-card {
    position: relative;

    .pro-hover-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.3s ease;
        cursor: pointer;
        z-index: 10;

        .pro-hover-badge {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            transform: scale(0.9);
            transition: transform 0.3s ease;

            svg {
                font-size: 14px;
            }
        }
    }

    &:hover {
        .pro-hover-overlay {
            opacity: 1;

            .pro-hover-badge {
                transform: scale(1);
            }
        }

        // Slightly dim the card content on hover
        .integration-content,
        .integration-icon {
            opacity: 0.7;
            transition: opacity 0.3s ease;
        }
    }

    // Disable interactions for non-pro users
    .integration-actions {
        .toggle-switch input:disabled+.toggle-slider {
            opacity: 0.5;
            cursor: not-allowed;
        }

        button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
    }
}