/* Custom styles for Integration Engine UI */

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.navbar-brand {
    font-weight: 600;
}

/* Main Content Layout */
#mainContentRow {
    min-height: calc(100vh - 120px); /* Ensure minimum height for the main content */
    align-items: stretch;
}

/* Left Panel Background */
.col-md-4 .card {
    background-color: #fafafa;
    color: #212529;
}

/* Configuration List */
.list-group-item {
    border-left: none;
    border-right: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #ffffff;
    color: black;
    border-color: #ffffff;
}

.list-group-item:hover {
    background-color: #cecccc;
    color: white;
    transform: translateX(5px);
}

.list-group-item.active {
    background-color: #ffffff;
    border-color: #666666;
    color: black;
    transform: translateX(5px);
}

/* Fixed height configurations list */
#configurationsList {
    max-height: calc(100vh - 200px); /* Fixed height based on viewport */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #666666 #f8f9fa;
}

/* Custom scrollbar for webkit browsers */
#configurationsList::-webkit-scrollbar {
    width: 6px;
}

#configurationsList::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

#configurationsList::-webkit-scrollbar-thumb {
    background: #666666;
    border-radius: 3px;
}

#configurationsList::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

/* Ensure the configurations panel has a fixed height */
#configurationsPanel .card {
    height: calc(100vh - 120px); /* Fixed height for the entire card */
    display: flex;
    flex-direction: column;
}

#configurationsPanel .card-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

/* Responsive adjustments for configurations list */
@media (max-width: 768px) {
    #configurationsList {
        max-height: calc(50vh - 100px); /* Smaller height on mobile */
    }
    
    #configurationsPanel .card {
        height: calc(50vh - 80px);
    }
    
    #editorPanel .card {
        height: calc(50vh - 80px);
    }
    
    #welcomePanel {
        height: calc(50vh - 80px);
    }
}

/* Additional improvements for configurations list */
.config-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.config-item:last-child {
    border-bottom: none;
}

.config-item h6 {
    margin-bottom: 0.5rem;
    color: #495057;
    font-weight: 600;
}

.config-item small {
    color: #6c757d;
    display: block;
    margin-bottom: 0.25rem;
}

.config-item .badge {
    font-size: 0.75em;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
}

/* Smooth scrolling for configurations list */
#configurationsList {
    scroll-behavior: smooth;
}

/* Loading state for configurations list */
#configurationsList.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty state styling */
#configurationsList:empty::after {
    content: "No configurations found";
    display: block;
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

/* Editor Panels */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Editor panel specific styling */
#editorPanel .card {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

#editorPanel .card-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Configuration editor form */
#configurationEditor .card-body {
    padding: 1.5rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #666666 #f8f9fa;
}

/* Form sections spacing */
#configurationEditor .mb-3 {
    margin-bottom: 1.5rem !important;
}

#configurationEditor .row {
    margin-bottom: 1rem;
}

/* Business Rules section specific styling */
#configurationEditor .mb-3:has(#ruleType) {
    margin-bottom: 2rem !important;
}

#javascriptRuleContainer,
#droolsRuleContainer {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#ruleScript,
#droolsRule {
    min-height: 120px;
    max-height: 200px;
    resize: vertical;
}

/* Response Mappings section specific styling */
#configurationEditor .mb-3:has(#mappingsContainer) {
    margin-bottom: 2rem !important;
}

#mappingsContainer {
    margin-top: 1rem;
}

/* Specific spacing for Business Rules and Response Mappings sections */
#configurationEditor .mb-3:nth-child(4),
#configurationEditor .mb-3:nth-child(5) {
    margin-bottom: 2.5rem !important;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

/* Ensure proper spacing between rule type selector and editor */
#ruleType {
    margin-bottom: 1rem;
}

/* Ensure proper spacing for response destination radio buttons */
#configurationEditor .form-check-inline:has(input[name="responseDestination"]) {
    margin-bottom: 1rem;
}

/* Additional spacing improvements */
#configurationEditor .mb-3 {
    position: relative;
}

#configurationEditor .mb-3:after {
    content: '';
    display: block;
    height: 1rem;
    clear: both;
}

/* Ensure textareas don't cause layout issues */
#configurationEditor textarea.form-control {
    box-sizing: border-box;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#configurationEditor textarea.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: 0;
}

/* Prevent any floating elements from causing layout issues */
#configurationEditor .clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* Payload sections */
#templatePayloadContainer,
#apiPayloadContainer {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#payloadTemplate {
    min-height: 100px;
    max-height: 150px;
    resize: vertical;
}

/* Headers section */
#headersContainer {
    margin-top: 0.5rem;
}

/* Test panel spacing */
#testPanel {
    margin-top: 1.5rem !important;
}

#testContext {
    min-height: 100px;
    max-height: 150px;
    resize: vertical;
}

/* Section separators and spacing */
#configurationEditor .mb-3:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 1.5rem;
}

/* Form labels spacing */
#configurationEditor .form-label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
}

/* Form text spacing */
#configurationEditor .form-text {
    margin-bottom: 0.75rem;
    color: #6c757d;
}

/* Input groups spacing */
#configurationEditor .input-group {
    margin-bottom: 0.75rem;
}

/* Radio button groups */
#configurationEditor .form-check-inline {
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

/* Ensure proper spacing for nested containers */
#configurationEditor .mt-2 {
    margin-top: 1rem !important;
}

#configurationEditor .mt-3 {
    margin-top: 1.5rem !important;
}

/* Prevent textarea overflow */
#configurationEditor textarea {
    overflow-y: auto;
    word-wrap: break-word;
}



/* Custom scrollbar for editor */
#configurationEditor .card-body::-webkit-scrollbar {
    width: 6px;
}

#configurationEditor .card-body::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

#configurationEditor .card-body::-webkit-scrollbar-thumb {
    background: #666666;
    border-radius: 3px;
}

#configurationEditor .card-body::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

/* Welcome panel */
#welcomePanel {
    height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-header {
    background-color: #000000;
    border-bottom: 1px solid #333333;
    font-weight: 600;
    color: white;
}

/* Override for left panel card header specifically */
.col-md-4 .card-header {
    background-color: #f8f9fa;
    color: #212529;
    border-bottom: 1px solid #dee2e6;
}

/* Disabled form group styling */
.form-group.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.form-group.disabled label {
    color: #6c757d;
}

.form-group.disabled .form-text {
    color: #6c757d !important;
}

/* Fresh token message styling */
.fresh-token-message {
    border-left: 4px solid #17a2b8;
    background-color: #f8f9fa;
}

/* Form Controls */
.form-control, .form-select {
    border: 1px solid #ced4da;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Code Areas */
#payloadTemplate, #ruleScript, #droolsRule, #testContext {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    resize: vertical;
}

#payloadTemplate:focus, #ruleScript:focus, #droolsRule:focus, #testContext:focus {
    background-color: #fff;
}

/* Dynamic Input Groups */
.input-group {
    margin-bottom: 0.5rem;
}

.input-group .btn-outline-secondary {
    border-color: #ced4da;
}

.input-group .btn-remove {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.input-group .btn-remove:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

/* Test Results */
#testResult {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

#testResult .success {
    color: #198754;
}

#testResult .error {
    color: #dc3545;
}

#testResult .info {
    color: #0dcaf0;
}

/* Loading States */
.btn:disabled {
    opacity: 0.6;
}

#loadingSpinner {
    z-index: 9999;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container-fluid {
        padding: 0.5rem;
    }
    
    .col-md-4, .col-md-8 {
        margin-bottom: 1rem;
    }
    
    .card-header .btn-group {
        flex-direction: column;
    }
    
    .card-header .btn {
        margin-bottom: 0.25rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Status Badges */
.status-badge.javascript {
    background-color: #f39c12;
}

.status-badge.drools {
    background-color: #e74c3c;
}

.status-badge.get {
    background-color: #17a2b8;
}

.status-badge.post {
    background-color: #28a745;
}

.status-badge.put {
    background-color: #ffc107;
    color: #212529;
}

.status-badge.delete {
    background-color: #dc3545;
}

/* Validation States */
.is-valid {
    border-color: #198754;
}

.is-invalid {
    border-color: #dc3545;
}

.valid-feedback {
    color: #198754;
}

.invalid-feedback {
    color: #dc3545;
}

/* Syntax Highlighting for JSON */
.json-key {
    color: #0066cc;
    font-weight: bold;
}

.json-string {
    color: #008000;
}

.json-number {
    color: #ff6600;
}

.json-boolean {
    color: #cc00cc;
}

.json-null {
    color: #666666;
}

/* Logs Panel */
.logs-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.logs-panel.show {
    right: 0;
}

.logs-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logs-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.log-entry {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f3f4;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

.log-entry:hover {
    background-color: #f8f9fa;
}

.log-timestamp {
    color: #6c757d;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.log-level {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.log-level.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.log-level.success {
    background-color: #d4edda;
    color: #155724;
}

.log-level.warning {
    background-color: #fff3cd;
    color: #856404;
}

.log-level.error {
    background-color: #f8d7da;
    color: #721c24;
}

.log-message {
    color: #333;
    word-break: break-word;
}

/* Folder Management Styles */
.folder-management-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.folder-section {
    border-left: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.folder-section:hover {
    border-left-color: #007bff;
}

.folder-header {
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-header:hover {
    background-color: #e9ecef;
}

.folder-name {
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
}

.folder-toggle-icon {
    transition: transform 0.2s ease;
}

.folder-content {
    background-color: #ffffff;
    border-left: 2px solid #f8f9fa;
    margin-left: 10px;
}

.folder-actions .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* Enhanced Configuration Item Styles for Tree View */
.config-item {
    border: none;
    border-bottom: 1px solid #f1f3f4;
    padding: 8px 12px;
    margin: 0;
    transition: all 0.2s ease;
}

.config-item:hover {
    background-color: #f8f9fa;
    transform: translateX(2px);
    border-left: 3px solid #007bff;
}

.config-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid #007bff;
    transform: translateX(2px);
}

.config-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.config-item:hover .config-actions {
    opacity: 1;
}

.config-actions .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
    border: none;
    background: transparent;
}

.config-actions .btn:hover {
    background-color: #dee2e6;
}

/* Folder Hierarchy Indentation */
.folder-content .folder-content {
    margin-left: 15px;
}

.folder-content .config-item {
    margin-left: 5px;
}

/* Status badges in folder view */
.config-item .badge {
    font-size: 0.6rem;
    padding: 2px 6px;
}

/* Folder color indicators */
.folder-icon {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

/* Responsive folder view */
@media (max-width: 768px) {
    .folder-content {
        margin-left: 5px;
    }
    
    .folder-header {
        padding: 6px 8px;
    }
    
    .config-item {
        padding: 6px 8px;
    }
    
    .folder-actions,
    .config-actions {
        opacity: 1; /* Always show on mobile */
    }
}

/* Loading states for folder operations */
.folder-section.loading {
    opacity: 0.6;
    pointer-events: none;
}

.folder-section.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty folder state */
.folder-content:empty::after {
    content: "Empty folder";
    display: block;
    padding: 16px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    font-size: 0.875rem;
}

/* Folder dropdown styling */
#folderSelect {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 4 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

#folderSelect option {
    padding: 8px 12px;
    font-size: 0.875rem;
}

/* Move to folder button styling */
.config-actions .btn-group .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
    margin-right: 2px;
}

.config-actions .btn-group .btn i {
    font-size: 0.7rem;
}

/* Folder selection form styling */
.folder-form-group {
    position: relative;
}

.folder-form-group::before {
    content: "📁";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
    font-size: 0.875rem;
}

.folder-form-group select {
    padding-left: 32px;
}

/* Collapsible Panel Styles */
#configurationsPanel {
    transition: all 0.3s ease;
}

#configurationsPanel.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

#editorPanel {
    transition: all 0.3s ease;
}

#editorPanel.expanded {
    width: 100%;
}

/* Floating Toggle Button */
.floating-toggle-btn {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 1000;
    transition: all 0.3s ease;
}

.floating-toggle-btn .btn {
    border-radius: 0 0.375rem 0.375rem 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.floating-toggle-btn .btn:hover {
    transform: translateX(2px);
}

/* Custom Tooltips */
.tooltip-custom {
    position: relative;
    cursor: help;
}

.tooltip-custom::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip-custom:hover::after {
    opacity: 1;
    visibility: visible;
} 

/* Log Details */
.log-details {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
}

.log-details details {
    font-size: 0.875rem;
}

.log-details summary {
    cursor: pointer;
    font-weight: 600;
    color: #495057;
    padding: 0.25rem 0;
}

.log-details summary:hover {
    color: #0d6efd;
}

.log-details .log-payload,
.log-details .log-response {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.5rem;
    margin-top: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-details .log-payload {
    border-left: 3px solid #17a2b8;
}

.log-details .log-response {
    border-left: 3px solid #28a745;
}

.log-details strong {
    color: #495057;
    font-size: 0.875rem;
} 