/* TriggerNinja Platform Manager Styles */

/* Ensure admin page layout doesn't inherit unwanted styles */
.wrap.triggerninja-admin-page {
    position: relative;
}

.triggerninja-platform-manager {
    background: #fff;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    padding: 20px;
    border-radius: 4px;
    display: block;
    width: 100%;
}

.platform-manager-header {
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

.platform-manager-header h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.platform-manager-header .description {
    margin: 0;
    color: #646970;
    font-size: 14px;
    line-height: 1.5;
}

/* Enabled Platforms Section */
.enabled-platforms-section {
    margin-bottom: 40px;
}

.enabled-platforms-section h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

/* Platform Browser */
.platform-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.platform-browser-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.platform-search-filter {
    display: flex;
    gap: 10px;
    align-items: center;
}

.platform-search-input {
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    width: 200px;
}

.platform-category-filter {
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    min-width: 150px;
}

/* Platform Grid */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    box-sizing: border-box;
    max-width: 100%;
}

.enabled-grid {
    border: 2px dashed #2271b1;
    background: #f0f6fc;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.enabled-grid:empty::after {
    content: "No platforms enabled yet. Enable platforms below to get started.";
    display: block;
    text-align: center;
    color: #646970;
    font-style: italic;
    padding: 40px 20px;
}

/* Platform Cards */
.platform-card {
    position: relative;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s ease;
    cursor: default;
    box-sizing: border-box;
    min-width: 0; /* Allows flex items to shrink */
    word-wrap: break-word;
}

.platform-card:hover {
    border-color: #2271b1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.platform-card.enabled {
    border-color: #00a32a;
    background: #f6fff8;
}



/* Platform Card Content */
.platform-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f1f1;
    border-radius: 8px;
    overflow: hidden;
}

.platform-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.platform-info {
    margin-bottom: 15px;
}

.platform-name {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.3;
}

.platform-description {
    margin: 0;
    font-size: 14px;
    color: #646970;
    line-height: 1.4;
}

/* Platform Actions */
.platform-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.platform-actions .button {
    font-size: 13px;
    padding: 6px 12px;
    height: auto;
    line-height: 1.3;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.platform-actions .button-primary {
    background: #2271b1;
    border-color: #2271b1;
}

.platform-actions .button-primary:hover {
    background: #135e96;
    border-color: #135e96;
}

.platform-actions .button-secondary {
    background: #f6f7f7;
    border-color: #ddd;
    color: #2c3338;
}

.platform-actions .button-secondary:hover {
    background: #f0f0f1;
    border-color: #8c8f94;
}


/* Category Sections */
.platform-category {
    margin-bottom: 30px;
}

.category-title {
    margin: 0 0 15px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.platform-category[data-category="email_marketing"] .category-title::before {
    content: "📧 ";
}

.platform-category[data-category="crm"] .category-title::before {
    content: "📊 ";
}

.platform-category[data-category="automation"] .category-title::before {
    content: "🔄 ";
}

.platform-category[data-category="other"] .category-title::before {
    content: "🔧 ";
}

/* Platform Configuration Modal */
.platform-config-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #646970;
}

.modal-close:hover {
    background: #f0f0f1;
    color: #d63638;
}

.modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Platform Field Styling within Modal */
.platform-field {
    margin-bottom: 20px;
}

.field-wrapper label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #1d2327;
}

.field-wrapper input,
.field-wrapper select,
.field-wrapper textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
}

.field-wrapper .description {
    margin: 6px 0 0 0;
    font-size: 13px;
    color: #646970;
    line-height: 1.4;
}

/* Loading States */
.platform-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.platform-card.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ddd;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty States */
.no-settings {
    text-align: center;
    color: #646970;
    font-style: italic;
    padding: 40px 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .platform-grid {
        grid-template-columns: 1fr;
    }
    
    .platform-browser-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .platform-search-filter {
        width: 100%;
        justify-content: stretch;
    }
    
    .platform-search-input,
    .platform-category-filter {
        flex: 1;
        width: auto;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .platform-actions {
        justify-content: center;
    }
}

/* Hidden elements for filtering */
.platform-category.hidden,
.platform-card.hidden {
    display: none !important;
}