/**
 * Integrations Page Styling
 * Enhanced UI for integration tiles with connection details
 */

/* Integration Details Section */
.integration-details {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.integration-info {
    text-align: left;
    font-size: 13px;
    color: #495057;
}

.integration-info p {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.integration-info strong {
    color: #0e1369;
    font-weight: 600;
    margin-right: 8px;
}

/* Enhanced Status Badges */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.status-badge.connected {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.status-badge.not-connected {
    background: #f1f3f5;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.status-badge.available {
    background: linear-gradient(135deg, #6264A7 0%, #4B4D8C 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(98, 100, 167, 0.3);
}

.status-badge.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Enhanced Connect Button */
.connect-btn {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(14, 19, 105, 0.2);
}

.connect-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(14, 19, 105, 0.3);
}

.connect-btn:active:not(:disabled) {
    transform: translateY(0);
}

.connect-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.connect-btn.disconnect-btn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.connect-btn.disconnect-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Integration Item Enhancements */
.integration-item {
    position: relative;
    transition: all 0.3s ease;
}

.integration-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.integration-item[data-connected="true"] {
    border: 2px solid #10b981;
}

.integration-item[data-connected="true"]::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: inherit;
    z-index: -1;
    opacity: 0.1;
}

/* Loading States */
.connect-btn .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Tooltip for Read-Only Fields */
.integration-info [title] {
    cursor: help;
    border-bottom: 1px dotted #6c757d;
}

/* Responsive Design */
@media (max-width: 768px) {
    .integration-details {
        font-size: 12px;
    }
    
    .integration-info p {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .connect-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Integration Grid Enhancements */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 20px 0;
}

@media (max-width: 1200px) {
    .integrations-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .integrations-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Connection Success Animation */
@keyframes connectionSuccess {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.integration-item.just-connected {
    animation: connectionSuccess 0.6s ease-out;
}

/* Error State */
.integration-item.error-state {
    border-color: #ef4444;
    background: #fef2f2;
}

.integration-item.error-state .status-badge {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

/* Organization Required State */
.integration-item.requires-org {
    opacity: 0.7;
}

.integration-item.requires-org .connect-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.integration-item.requires-org .connect-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Integration Icon Enhancements */
.integration-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.integration-item:hover .integration-icon {
    transform: scale(1.1);
    background: #e9ecef;
}

.integration-icon img {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
}

/* Connected Badge Indicator */
.integration-item[data-connected="true"] .integration-icon::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* ============================================================================
   GTM (Google Tag Manager) Modal Styles
   ============================================================================ */

/* Modal Overlay */
.gtm-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    animation: fadeIn 0.2s ease-out;
    margin: 0 !important;
    padding: 0 !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal Container */
.gtm-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

.gtm-modal-large {
    max-width: 600px;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Modal Header */
.gtm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
}

.gtm-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gtm-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.gtm-modal-close:hover {
    opacity: 1;
}

/* Modal Body */
.gtm-modal-body {
    padding: 24px;
    max-height: calc(80vh - 140px);
    overflow-y: auto;
}

/* Loading State */
.gtm-loading {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.gtm-loading i {
    font-size: 40px;
    color: #0e1369;
    margin-bottom: 16px;
}

.gtm-loading p {
    margin: 0;
    font-size: 14px;
}

/* Step Indicator */
.gtm-step-indicator {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e9ecef;
}

.gtm-step {
    font-size: 13px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gtm-step::before {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gtm-step.active {
    color: #0e1369;
    font-weight: 600;
}

.gtm-step.active::before {
    background: #0e1369;
}

.gtm-step.completed {
    color: #10b981;
}

.gtm-step.completed::before {
    background: #10b981;
    content: '✓';
    color: white;
    font-size: 12px;
}

/* Account List */
.gtm-accounts-list h3,
.gtm-containers-list h3 {
    font-size: 14px;
    color: #374151;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gtm-account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.gtm-account-item:hover {
    background: #e9ecef;
}

.gtm-account-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gtm-account-info i {
    color: #6c757d;
    font-size: 18px;
}

.gtm-account-name {
    font-weight: 500;
    color: #1f2937;
}

/* Container Group */
.gtm-container-group {
    margin-bottom: 20px;
}

.gtm-container-group h4 {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gtm-container-group.recommended h4 {
    color: #10b981;
}

/* Container Item */
.gtm-container-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.gtm-container-item:hover {
    background: #e9ecef;
}

.gtm-container-item.recommended {
    background: #ecfdf5;
    border-color: #10b981;
}

.gtm-container-info {
    flex: 1;
    min-width: 0;
}

.gtm-container-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.gtm-container-name {
    font-weight: 600;
    color: #1f2937;
}

.gtm-container-id {
    font-family: monospace;
    font-size: 12px;
    color: #6b7280;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 4px;
}

.gtm-container-domains {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.gtm-container-context {
    display: flex;
    gap: 6px;
}

.gtm-context-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e5e7eb;
    color: #4b5563;
    text-transform: uppercase;
    font-weight: 600;
}

.gtm-context-badge.web {
    background: #dbeafe;
    color: #1d4ed8;
}

.gtm-context-badge.ios,
.gtm-context-badge.android {
    background: #fef3c7;
    color: #b45309;
}

/* Tip Box */
.gtm-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: #fffbeb;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 13px;
    color: #92400e;
}

.gtm-tip i {
    color: #f59e0b;
    margin-top: 2px;
}

.gtm-tip code {
    background: #fef3c7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* Buttons */
.gtm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.gtm-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.gtm-btn-primary {
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
}

.gtm-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 19, 105, 0.3);
}

.gtm-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.gtm-btn-secondary:hover {
    background: #e5e7eb;
}

/* Modal Actions */
.gtm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

/* Status States */
.gtm-success {
    text-align: center;
    padding: 30px 20px;
}

.gtm-success i {
    font-size: 48px;
    color: #10b981;
    margin-bottom: 16px;
}

.gtm-success h3 {
    color: #065f46;
    margin: 0 0 8px 0;
}

.gtm-success p {
    color: #6b7280;
    margin: 0;
}

.gtm-error {
    text-align: center;
    padding: 30px 20px;
}

.gtm-error i {
    font-size: 48px;
    color: #ef4444;
    margin-bottom: 16px;
}

.gtm-error h3 {
    color: #991b1b;
    margin: 0 0 8px 0;
}

.gtm-error p {
    color: #6b7280;
    margin: 0 0 8px 0;
}

.gtm-no-accounts,
.gtm-no-containers {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
}

.gtm-no-accounts i,
.gtm-no-containers i {
    font-size: 48px;
    color: #fbbf24;
    margin-bottom: 16px;
}

.gtm-no-accounts h3,
.gtm-no-containers h3 {
    color: #1f2937;
    margin: 0 0 12px 0;
}

/* Requirement Notice */
.gtm-requirement-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #eff6ff;
    border-radius: 8px;
    margin-bottom: 20px;
}

.gtm-requirement-notice i {
    color: #3b82f6;
    font-size: 20px;
    margin-top: 2px;
}

.gtm-requirement-notice p {
    margin: 0;
    color: #1e40af;
    line-height: 1.5;
}

/* Setup Required Badge */
.status-badge.setup-required {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* GTM ID Display */
.gtm-id {
    font-family: monospace;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ============================================================================
   WordPress Connector Modal Styles
   ============================================================================ */

/* Modal Container */
.wp-connect-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

.wp-connect-modal.active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.wp-connect-modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.wp-connect-modal .modal-container {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    margin: auto;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

/* Modal Header */
.wp-connect-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #21759b 0%, #1e40af 100%);
    color: white;
}

.wp-connect-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
}

.wp-connect-modal .modal-title i {
    font-size: 24px;
}

.wp-connect-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 4px;
}

.wp-connect-modal .modal-close:hover {
    opacity: 1;
}

/* Modal Body */
.wp-connect-modal .modal-body {
    padding: 24px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

/* Info Section */
.wp-connect-info {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    border-left: 4px solid #21759b;
}

.wp-connect-info p {
    margin: 0 0 12px 0;
    color: #0369a1;
    font-weight: 500;
}

.wp-connect-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wp-connect-info li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    color: #0c4a6e;
    font-size: 14px;
}

.wp-connect-info li i {
    color: #10b981;
    font-size: 12px;
}

/* Form Styles */
#wordpress-connect-form .form-group {
    margin-bottom: 20px;
}

#wordpress-connect-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    font-size: 14px;
}

#wordpress-connect-form label i {
    color: #6b7280;
}

#wordpress-connect-form input[type="text"],
#wordpress-connect-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    box-sizing: border-box;
}

#wordpress-connect-form input:focus {
    outline: none;
    border-color: #21759b;
    box-shadow: 0 0 0 3px rgba(33, 117, 155, 0.1);
}

#wordpress-connect-form .input-hint {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
}

/* Password Toggle */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: 48px !important;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.toggle-password:hover {
    color: #1f2937;
}

/* Progress Indicator */
.connect-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: #f0f9ff;
    border-radius: 8px;
    margin-bottom: 16px;
}

.connect-progress .progress-spinner {
    color: #21759b;
}

.connect-progress .progress-spinner i {
    font-size: 20px;
}

#wp-progress-text {
    color: #0369a1;
    font-weight: 500;
}

/* Error/Success Messages */
.connect-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid #ef4444;
    font-size: 14px;
}

.connect-success {
    background: #ecfdf5;
    color: #065f46;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid #10b981;
    font-size: 14px;
}

/* Modal Actions */
.wp-connect-modal .modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.wp-connect-modal .cancel-btn {
    padding: 12px 24px;
    background: #f3f4f6;
    color: #374151;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wp-connect-modal .cancel-btn:hover {
    background: #e5e7eb;
}

.wp-connect-modal .submit-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #21759b 0%, #1e40af 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wp-connect-modal .submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 117, 155, 0.3);
}

.wp-connect-modal .submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Security Note */
.wp-security-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: #f0fdf4;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 12px;
    color: #166534;
}

.wp-security-note i {
    color: #10b981;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Connected Sites List */
.wordpress-site-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.wordpress-site-item:hover {
    background: #e9ecef;
}

.site-info {
    flex: 1;
    min-width: 0;
}

.site-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-url {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #9ca3af;
}

.site-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.site-actions .btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.site-actions .btn-icon:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.site-actions .disconnect-site:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.no-sites {
    text-align: center;
    color: #9ca3af;
    padding: 16px;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 600px) {
    .wp-connect-modal .modal-container {
        width: 95%;
        max-height: 95vh;
        border-radius: 12px;
    }
    
    .wp-connect-modal .modal-header {
        padding: 16px 20px;
    }
    
    .wp-connect-modal .modal-body {
        padding: 20px;
    }
    
    .wp-connect-modal .modal-actions {
        flex-direction: column;
    }
    
    .wp-connect-modal .cancel-btn,
    .wp-connect-modal .submit-btn {
        width: 100%;
        justify-content: center;
    }
}
