/* Custom CSS for the Dataset Query page - Enhanced Consistency and Layout */

/* --- COLOR PALETTE --- */
:root {
    --color-accent: #007bff;       /* NL Query & Generate Button */
    --color-info: #17a2b8;         /* SQL Output (Process/Info) */
    --color-success: #28a745;      /* Execute Button (Action) */
    --color-dark: #343a40;         
    --color-muted: #6c757d;        
    --color-background-light: #f8f9fa; 
    --color-background-code: #e9ecef; 
    --color-border: #dee2e6;       
    
    /* Defined heights for visual balance */
    --input-output-height: 200px; /* Target height for textarea and pre content */
}

/* --- GENERAL TEXT & ICONS --- */
.custom-text-header { color: var(--color-dark) !important; }
.custom-text-accent { color: var(--color-accent) !important; }
.custom-text-info { color: var(--color-info) !important; }
.custom-text-muted { color: var(--color-muted) !important; }
.custom-text-success { color: var(--color-success) !important; }


/* --- STEP INDICATORS --- */
.custom-step-badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    margin-right: 0.5rem;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    color: white;
    background-color: var(--color-dark); /* Dark badge for clear numbering */
}

/* --- BUTTONS --- */
.custom-btn-primary { 
    background-color: var(--color-accent); 
    border-color: var(--color-accent); 
    color: white; 
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}
.custom-btn-primary:hover { 
    background-color: #0056b3; 
    color: white;
    border-color: #0056b3; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.custom-btn-execute { 
    background-color: var(--color-info); /* ⭐ UPDATED TO INFO COLOR */
    border-color: var(--color-info); 
    color: white; 
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}
.custom-btn-execute:hover { 
    background-color: #117a8b; /* Darker info hover */
    color: white; 
    border-color: #117a8b; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.custom-btn-secondary {
    background-color: transparent;
    border-color: var(--color-muted);
    color: var(--color-muted);
}
.custom-btn-secondary:hover {
    background-color: #e2e6ea;
}


/* --- CONTAINERS & INPUTS --- */

/* Ensures side-by-side containers have equal height and vertical content alignment */
.custom-query-area {
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
    background-color: white; /* Use white background for content to make it pop */
    height: 100%; 
    display: flex; 
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Specific styling for Step 1 container to provide visual difference */
.custom-step-1 {
    border-left: 5px solid var(--color-accent);
}

/* Specific styling for Step 2 container */
.custom-step-2 {
    border-left: 5px solid var(--color-info);
}

/* Fix for equal height between textarea and pre element */
.custom-query-area textarea {
    flex-grow: 1; 
    min-height: var(--input-output-height);
    max-height: var(--input-output-height);
    margin-bottom: 1rem;
    font-family: Arial, sans-serif;
    color: var(--color-dark);
    border: 1px solid var(--color-border);
    resize: none; 
}

/* Style for displaying generated SQL */
.code-output {
    flex-grow: 1; 
    min-height: var(--input-output-height);
    max-height: var(--input-output-height);
    margin-bottom: 1rem;
    background-color: var(--color-background-code);
    border: 1px solid var(--color-border);
    padding: 0.75rem;
    overflow-y: auto;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    border-radius: 0.25rem;
    color: var(--color-dark);
}

.form-label.fw-bold {
    margin-bottom: 0.5rem;
}

/* Schema Card Styling */
.custom-card {
    border-color: var(--color-border);
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.custom-card-header {
    background-color: var(--color-background-light);
    border-bottom: 1px solid black;
    color: var(--color-dark);
}

/* Containers for results and visualization */
.custom-result-display {
    min-height: 300px;
    border: 1px solid var(--color-border);
    border-radius: 0.25rem;
    margin-top: 15px;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    height: 100%;
}

/* --- SCHEMA TABLE STYLING --- */
.table-container { 
    max-height: 250px; 
    overflow-y: auto; 
}
.table-separator {
    background-color: #e6f7ff;
    font-style: italic;
    text-align: center;
    color: var(--color-muted);
}
/* Targeting the specific SQL textarea */
#generated_sql {
    /* Overrides the default textarea font from the NL input */
    font-family: monospace !important; 
    
    /* Re-apply the code specific styling */
    background-color: var(--color-background-code);
    border: 1px solid var(--color-border);
    padding: 0.75rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--color-dark);
}
#result-display {
    /* Critical: Set a fixed height or max height for the chart area */
    max-height: 450px; /* Adjust this value to your preferred height */
    height: 450px;     /* Ensure a consistent base height */

    /* Ensure proper positioning for Chart.js responsiveness */
    position: relative; 
    overflow-y: auto; 
    overflow-x: auto;
}
#visualization-container {
    /* Critical: Set a fixed height or max height for the chart area */
    max-height: 450px; /* Adjust this value to your preferred height */
    height: 450px;     /* Ensure a consistent base height */

    /* Ensure proper positioning for Chart.js responsiveness */
    position: relative; 
    overflow-y: auto; 
}

/* --- READY TO SAVE STATE --- */
.custom-btn-ready-to-save {
    /* Use a strong color to grab attention, e.g., Green/Success */
    background-color: var(--color-success) !important; 
    border-color: var(--color-success) !important;
    color: white !important;
    font-weight: bold;
    /* Add animation for subtle flash/glow */
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.7);
    transition: all 0.3s ease-in-out;
}
.custom-btn-ready-to-save:hover {
    background-color: #1e7e34 !important; /* Darker green on hover */
    border-color: #1e7e34 !important;
    box-shadow: 0 0 15px rgba(40, 167, 69, 1);
}
/* --- SCHEMA CODE BLOCK STYLE --- */
.custom-code-block {
    background-color: white;
    /*border: 1px solid var(--color-border);*/
    border-radius: 0.25rem;
    color: var(--color-dark);
    font-family: monospace;
    font-size: 0.9em; /* Smaller font for detail */
}