/* Custom Modal Styles */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.custom-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.custom-modal-dialog {
  position: relative;
  width: auto;
  margin: 0.5rem;
  background-color: var(--background-color, #fff);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.3rem;
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  transform: translateY(25px);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  max-width: 800px; /* Default size */
  cursor: move;
}

/* Dialog sizes based on content needs */
.custom-modal-dialog.modal-lg {
  max-width: 1200px; /* Larger size */
}

.custom-modal-dialog.modal-xl {
  max-width: 1800px; /* Extra large for child forms */
  min-width: 1200px; /* Minimum width for forms with children */
}

/* Fix positioning to not go offscreen on large screens */
@media (min-width: 1920px) {
  .custom-modal-dialog.modal-xl {
    max-width: 1800px; /* Fixed width on large screens */
  }
}

/* Fix positioning on small screens */
@media (max-width: 1366px) {
  .custom-modal-dialog.modal-xl {
    max-width: 95vw; /* Percentage on smaller screens */
    min-width: 1200px; /* Maintain minimum width */
  }
}

/* Handle very small screens - allow smaller than minimum on tiny screens */
@media (max-width: 1250px) {
  .custom-modal-dialog.modal-xl {
    min-width: 95vw; /* Allow smaller than minimum on tiny screens */
  }
}

.custom-modal-overlay.show .custom-modal-dialog {
  transform: translateY(0);
}

.custom-modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color, #dee2e6);
  border-top-left-radius: calc(0.3rem - 1px);
  border-top-right-radius: calc(0.3rem - 1px);
  background-color: var(--card-background, #f8f9fa);
}

.custom-modal-body {
  position: relative;
  padding: 1rem;
  flex: 1 1 auto;
  max-height: 75vh;
  overflow-y: auto;
}

.custom-modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  padding: 0.75rem;
  border-top: 1px solid var(--border-color, #dee2e6);
  border-bottom-right-radius: calc(0.3rem - 1px);
  border-bottom-left-radius: calc(0.3rem - 1px);
  background-color: var(--card-background, #f8f9fa);
}

.custom-modal-title {
  margin-bottom: 0;
  line-height: 1.5;
}

.custom-modal-header .btn-close {
  padding: 0.5rem;
  margin: -0.5rem -0.5rem -0.5rem auto;
}

/* Enhanced Child Form Styles */
.custom-modal-body .child-forms-container {
  padding-left: 10px;
  height: 100%;
}

.custom-modal-body .collapsible-section {
  margin-bottom: 1.25rem;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.custom-modal-body .child-grid-container {
  min-height: 300px;
}

.custom-modal-body .collapsible-content.expanded {
  max-height: 2500px; /* Larger to accommodate bigger grids */
}

/* Form field styles for the more compact layout */
.custom-modal-body form .form-group {
  margin-bottom: 0.75rem; /* Slightly reduced spacing between fields */
}

.custom-modal-body form .form-label {
  margin-bottom: 0.25rem; /* Compact label spacing */
  font-weight: 500;
}

.custom-modal-body form .form-control {
  padding: 0.375rem 0.5rem; /* Slightly reduced padding */
}

/* Toggle switch styling for compact layout */
.custom-modal-body form .form-check.form-switch {
  padding-left: 3em;
  margin-bottom: 0.75rem;
}

/* BigCombo/Select2 styles for the compact layout */
.custom-modal-body .bigcombo {
  width: 100% !important;
  max-width: 100%;
}

.custom-modal-body .select2-container {
  width: 100% !important;
  max-width: 100%;
}

.custom-modal-body .select2-search__field {
  width: 100% !important;
}

/* Fix positioning to not go offscreen */
@media (min-width: 576px) {
  .custom-modal-dialog {
    max-height: 95vh;
    margin: 1.75rem auto;
  }
}

/* SQL Error Dialog Styles */
.sql-error-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1050;
}

.sql-error-dialog .custom-modal-dialog {
    max-width: 900px;
    width: 90vw;
    margin: 5vh auto;
}

.sql-error-content {
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.sql-error-header {
    background-color: var(--error-color, #dc3545);
    color: white;
    padding: 15px;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sql-error-header i {
    font-size: 1.2em;
}

.sql-error-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
    background-color: var(--card-background);
}

.sql-message {
    background-color: var(--error-background, #f8d7da);
    color: var(--error-text, #721c24);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--error-border, #f5c6cb);
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.sql-query-container {
    background-color: var(--code-background, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 6px;
    overflow: hidden;
}

.sql-query-header {
    background-color: var(--table-header-bg, #e9ecef);
    color: var(--text-color);
    padding: 10px 15px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sql-query-copy-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: background-color 0.2s;
}

.sql-query-copy-btn:hover {
    background-color: var(--accent-color);
    color: white;
}

.sql-query {
    width: 100%;
    box-sizing: border-box;
    padding: 15px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-color);
    background-color: var(--code-background, #f8f9fa);
    height: 900px;
    max-height: 900px;
    overflow-y: auto;
    margin: 0;
    border: none;
    resize: none;
}

.sql-query::-webkit-scrollbar {
    width: 8px;
}

.sql-query::-webkit-scrollbar-track {
    background: var(--scrollbar-track, #f1f1f1);
    border-radius: 4px;
}

.sql-query::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #c1c1c1);
    border-radius: 4px;
}

.sql-query::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover, #a8a8a8);
}

.sql-error-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color, #dee2e6);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: var(--card-background);
}

.sql-error-close-btn {
    background-color: var(--secondary-color, #6c757d);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.sql-error-close-btn:hover {
    background-color: var(--secondary-color-hover, #545b62);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .sql-message {
        background-color: #2d1619;
        color: #f8d7da;
        border-color: #842029;
    }
    
    .sql-query {
        background-color: #1e1e1e;
        color: #d4d4d4;
    }
    
    .sql-query-container {
        background-color: #1e1e1e;
        border-color: #444;
    }
    
    .sql-query-header {
        background-color: #2d2d2d;
        border-color: #444;
    }
} 