/* Custom styles for Escribo application */

.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.pulse-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

.spinner {
    animation: spin 1s linear infinite;
}

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

/* Status indicators */
.status-pending {
    @apply bg-yellow-100 text-yellow-800 border-yellow-200;
}

.status-running {
    @apply bg-blue-100 text-blue-800 border-blue-200;
}

.status-completed {
    @apply bg-green-100 text-green-800 border-green-200;
}

.status-failed {
    @apply bg-red-100 text-red-800 border-red-200;
}

/* Responsive design improvements */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .text-4xl {
        font-size: 2rem;
    }
    
    .text-6xl {
        font-size: 3rem;
    }
}

/* Form enhancements */
.form-input:focus {
    outline: none;
    ring: 2;
    ring-color: #3b82f6;
    border-color: transparent;
}

/* Loading states */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Schema Builder Styles */
.schema-field {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #e9ecef;
  border-radius: 5px;
  background-color: #f8f9fa;
}

.nested-fields {
  margin-top: 10px;
  padding: 10px;
  background-color: #ffffff;
  border-radius: 5px;
}

.nested-fields .nested-fields {
  background-color: #f8f9fa;
}

.nested-fields .nested-fields .nested-fields {
  background-color: #ffffff;
}

.schema-field .row {
  align-items: center;
}

.schema-field .form-control,
.schema-field .form-select {
  font-size: 0.875rem;
}

.schema-field .btn {
  font-size: 0.75rem;
}

/* Array specific styling */
.nested-fields[style*="border-left: 2px solid #007bff"] {
  background-color: #e3f2fd;
}

/* Object specific styling */
.nested-fields[style*="border-left: 2px solid #ccc"] {
  background-color: #f5f5f5;
}

/* Array item object styling */
.nested-fields[style*="border-left: 2px solid #28a745"] {
  background-color: #e8f5e8;
}

/* Disabled field styling */
.schema-field input[disabled],
.schema-field select[disabled] {
  background-color: #e9ecef;
  opacity: 0.6;
}

/* Schema preview styling */
#schema-preview,
#example-preview {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  padding: 15px;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* Nested level indicators */
.nested-fields {
  position: relative;
}

.nested-fields::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, #007bff, #28a745);
  border-radius: 2px;
}

/* Schema Form Styles */
.schema-form {
  max-height: 70vh;
  overflow-y: auto;
}

.nested-object-container {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.nested-object-header h6 {
  color: #495057;
  font-weight: 600;
  margin-bottom: 10px;
}

.nested-object-content {
  border-left: 3px solid #007bff;
  padding-left: 15px;
  background-color: #ffffff;
  border-radius: 0 8px 8px 0;
}

.array-field-container {
  background-color: #e8f5e8;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.array-field-header {
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.array-items {
  min-height: 60px;
  background-color: #ffffff;
}

.array-item {
  position: relative;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 10px;
}

.array-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-label {
  font-weight: 600;
  color: #495057;
}

.form-label .text-danger {
  font-weight: 700;
}

.form-text {
  font-size: 0.875rem;
  color: #6c757d;
  margin-top: 5px;
}

.invalid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #dc3545;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-actions {
  background-color: #f8f9fa;
  margin: 0 -15px -15px -15px;
  padding: 15px;
  border-radius: 0 0 8px 8px;
}

/* Tooltip styling for info icons */
.fas.fa-info-circle {
  cursor: help;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.fas.fa-info-circle:hover {
  opacity: 1;
}

/* Form field depth indicators */
.mb-3[style*="margin-left"] {
  position: relative;
}

.mb-3[style*="margin-left"]::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #dee2e6;
  border-radius: 1px;
}

/* Enhanced button styles */
.btn-outline-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.btn-outline-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

/* Responsive form adjustments */
@media (max-width: 768px) {
  .schema-form {
    max-height: 60vh;
  }
  
  .nested-object-container,
  .array-field-container {
    padding: 10px;
  }
  
  .mb-3[style*="margin-left"] {
    margin-left: 10px !important;
  }
  
  .nested-object-content {
    padding-left: 10px;
  }
}

.options-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.options-dialog {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
}

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

.options-dialog-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #333;
}

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

.options-dialog-close:hover {
  background-color: #f0f0f0;
}

.options-dialog-content {
  padding: 20px;
}

.options-dialog-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.options-dialog-button {
  padding: 12px 20px;
  border: 2px solid #007bff;
  background: white;
  color: #007bff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  text-align: left;
}

.options-dialog-button:hover {
  background: #007bff;
  color: white;
}

.options-dialog-button:active {
  transform: translateY(1px);
}

/* Add Input Modal Specific Styles */
#addInputToNodeModal .modal-dialog {
  max-width: 40vw;
}

#addInputToNodeModal .modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

#addInputToNodeModal .modal-header {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

#addInputToNodeModal .modal-footer {
  border-top: 2px solid #dee2e6;
}

/* Loading state styles */
#addInputLoadingState {
  min-height: 200px;
}

#addInputLoadingState .spinner-border {
  width: 2rem;
  height: 2rem;
}

/* Error state styles */
#addInputErrorState .alert {
  border-left: 4px solid #dc3545;
}

#addInputErrorState .fas.fa-exclamation-triangle {
  font-size: 1.25rem;
  color: #dc3545;
}

/* No schema state styles */
#addInputNoSchemaState .alert {
  border-left: 4px solid #17a2b8;
}

#addInputNoSchemaState .fas.fa-info-circle {
  font-size: 1.25rem;
  color: #17a2b8;
}

/* Submit button loading state */
#submitNodeInputBtn .spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.125em;
}

/* Modal content transitions */
#addInputToNodeModalContent {
  transition: opacity 0.3s ease-in-out;
}

#addInputToNodeModalContent.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Enhanced alert styling */
.alert-danger .alert-heading,
.alert-info .alert-heading {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Responsive modal adjustments */
@media (max-width: 992px) {
  #addInputToNodeModal .modal-dialog {
    max-width: 95vw;
    margin: 0.5rem;
  }
  
  #addInputToNodeModal .modal-body {
    max-height: 60vh;
  }
}

@media (max-width: 576px) {
  #addInputToNodeModal .modal-footer {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  #addInputToNodeModal .modal-footer .d-flex {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  #addInputToNodeModal .modal-footer .text-muted {
    text-align: center;
    margin-bottom: 0.5rem;
  }
  
  #addInputToNodeModal .modal-footer > div > div {
    display: flex;
    gap: 0.5rem;
  }
}