/* Line-numbered Text Editor */
.line-numbers-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: row;
}

.line-numbers {
    width: 3rem;
    background-color: #f0f0f0;
    border: 1px solid #d1d5db;
    border-right: none;
    border-radius: 0.375rem 0 0 0.375rem;
    padding: 0.5rem 0.3rem;
    text-align: right;
    font-family: 'Monospace', monospace;
    font-size: 0.85rem;
    color: #6b7280;
    user-select: none;
    overflow-y: hidden;
    line-height: 1.5;
    white-space: pre;
}

.line-numbers-textarea {
    flex-grow: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-left: none;
    border-radius: 0 0.375rem 0.375rem 0;
    padding: 0.5rem;
    font-family: 'Monospace', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-y: auto;
    white-space: pre-wrap;
    color: #000; /* Default text color */
}

/* Make sure both the textarea and line numbers scroll together */
.line-numbers-textarea:focus {
    outline: none;
    border-color: #93c5fd;
}

/* Ensure full height layout */
html, body { height: 100%; margin: 0; overflow: hidden; font-family: sans-serif; }
body { display: flex; flex-direction: column; }

/* Custom styles for UI elements */
textarea { font-family: 'Monospace', monospace; resize: none; border: 1px solid #d1d5db; border-radius: 0.375rem; padding: 0.5rem; }
button { transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out; }
.error-message { background-color: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 0.375rem; padding: 0.5rem 1rem; margin-top: 0.5rem; white-space: pre-wrap; font-size: 0.8rem;}
.info-message { background-color: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; border-radius: 0.375rem; padding: 0.5rem 1rem; margin-top: 0.5rem; white-space: pre-wrap; font-size: 0.8rem;}
.status-indicator { font-size: 0.8rem; color: #6b7280; margin-left: 10px; }

/* Tab Styles */
.tab-button { border: 1px solid #d1d5db; border-bottom: none; background-color: #e5e7eb; padding: 0.5rem 1rem; border-radius: 0.375rem 0.375rem 0 0; margin-bottom: -1px; cursor: pointer; color: #374151; }
.tab-button[data-active="true"] { background-color: white; border-color: #d1d5db; border-bottom-color: white; font-weight: 600; color: #111827; opacity: 1; }
.tab-button:disabled { opacity: 0.5; cursor: not-allowed; background-color: #f3f4f6; color: #9ca3af; }

.tab-panel {
    border: 1px solid #d1d5db;
    border-radius: 0 0.375rem 0.375rem 0.375rem;
    background-color: white;
    flex-grow: 1;
    overflow: auto;
    display: none; /* Hidden by default */
}
.tab-panel[data-active="true"] { display: block; /* Shown when active */ }

/* Mermaid Diagram Container */
.mermaid svg { max-width: 100%; height: auto; display: block; margin: auto; }
#mermaidDiagram { min-height: 50px; /* Ensure space even when loading */ }

/* Chart Container */
#resultsChartContainer { position: relative; width: 100%; height: 100%; min-height: 300px; }

/* Styles for PDF Report Content (injected via JS) */
.pdf-body { font-family: sans-serif; font-size: 10pt; line-height: 1.4; }
.pdf-h1 { font-size: 18pt; border-bottom: 1px solid #ccc; margin-bottom: 15pt; padding-bottom: 5pt; page-break-after: avoid; color: #333; }
.pdf-h2 { font-size: 14pt; margin-top: 20pt; margin-bottom: 8pt; border-bottom: 1px solid #eee; padding-bottom: 4pt; page-break-after: avoid; page-break-inside: avoid; color: #444; }
.pdf-h3 { font-size: 12pt; font-weight: 600; margin-top: 15pt; margin-bottom: 6pt; page-break-after: avoid; color: #555; }
.pdf-ul { list-style: disc; margin-left: 25pt; margin-bottom: 10pt; page-break-inside: avoid; } .pdf-li { margin-bottom: 6pt; page-break-inside: avoid; }
.pdf-dl { margin-left: 15pt; margin-bottom: 10pt; } .pdf-dt { font-weight: bold; margin-top: 8pt; } .pdf-dd { margin-left: 20pt; margin-bottom: 6pt; }
.pdf-code { font-family: monospace; background-color: #f0f0f0; padding: 2pt 4pt; font-size: 9pt; border-radius: 3px; word-break: break-all; }
.pdf-pre-code { 
    display: block; 
    white-space: pre-wrap; 
    background-color: #f0f0f0; 
    padding: 10pt; 
    margin-top: 5pt; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    font-size: 8pt; /* Even smaller for PDF */
    word-wrap: break-word; 
    page-break-inside: avoid !important; 
}
.pdf-p { margin-bottom: 10pt; }
.report-section { 
    margin-bottom: 25pt; 
    page-break-inside: avoid; 
    /* Add some styling to potentially help layout engine? */
    /* border: 1px solid transparent;  Might help delineate sections */
    /* clear: both; */
    /* ... */ 
}
.dsl-code-section {
     page-break-before: auto; /* Allow it to start on new page if needed */
}
.report-chart-container { 
    text-align: center; 
    margin-top: 10pt; 
    page-break-inside: avoid !important; 
    width: 100%; /* Ensure container takes width */
    max-width: 650px; /* Set a max width */
    margin-left: auto; /* Center container */
    margin-right: auto; /* Center container */
}
.report-chart-container h4 { page-break-after: avoid; } /* Keep chart title with chart */
.report-chart-container img { 
    max-width: 100%; 
    height: auto; 
    border: 1px solid #ccc; 
    display: block; /* Center image */
    margin-left: auto; /* Center image */
    margin-right: auto; /* Center image */
    margin-top: 5px; /* Add space above image */
}
.report-svg-container { margin: 15pt auto; width: 100%; max-width: 180mm; /* Limit SVG width */ page-break-inside: avoid; }
.report-svg-container svg { max-width: 100%; height: auto; display: block; margin: auto; border: 1px solid #eee; background-color: white; }
.individual-chart-section { page-break-before: auto; page-break-inside: avoid; margin-bottom: 15pt; }
.page-break { page-break-before: always; } /* Utility class for forced breaks */

/* Add page break avoidance to tables and rows */
/* Let tables break if necessary, but try to keep rows together */
table { 
    page-break-inside: auto; 
    border-collapse: collapse; /* Needed for some PDF renderers */
}
table tr {
    page-break-inside: avoid; 
}
table th, table td {
     border: 1px solid #eee; /* Add light borders for PDF table structure */
     padding: 4pt 6pt;
}

/* A/B Test Interpretation Controls */
.ab-interp-controls button {
    padding: 0.3rem 0.8rem; 
    margin-right: 0.5rem; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    background-color: #f0f0f0; 
    cursor: pointer;
}
.ab-interp-controls button.active { 
    background-color: #e0e0e0; 
    font-weight: bold; 
    border-color: #aaa; 
}
.ab-interp-container { 
    display: none; 
}
.ab-interp-container.active { 
    display: block; 
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    width: 500px;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
    color: #6b7280;
}

.modal-close-btn:hover {
    color: #111827;
}

/* Model title styles */
.model-title {
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background-color: #f8fafc;
    border-left: 4px solid #3b82f6;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e40af;
}

/* Editor styles */
.editor-container {
    display: flex;
    height: 400px;
    position: relative;
    border: 1px solid #ccc;
    font-family: monospace;
    line-height: 1.5;
    font-size: 0.85rem; /* Reduced font size to show more lines */
}

#dslInput {
    flex: 1;
    resize: none;
    padding: 8px;
    border: none;
    outline: none;
    font-family: monospace;
    line-height: 1.5;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow-y: auto;
}

/* Syntax highlighting classes - will be applied by JavaScript */
.dsl-keyword-blue {
    color: #0066cc; /* Blue color for DSL keywords */
    font-weight: bold;
}

.dsl-keyword-orange {
    color: #ff6600; /* Orange color for abtest */
    font-weight: bold;
}

.dsl-value-green {
    color: #008800; /* Green color for values */
}

.editor-wrapper {
    position: relative;
    flex: 1;
    height: 100%;
}

/* === End Consolidated Styles === */

/* Editor container needs to have proper height */
#editor-container {
    flex: 1;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative; /* Needed for CodeMirror layout */
}

/* Dropdown Menu Styles */
.dropdown-container {
    position: relative;
}

.dropdown-menu {
    transition: all 0.2s ease;
    transform-origin: top right;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 50;
}

.dropdown-menu.active {
    display: block !important;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Add these styles for the new DSL version selector and syntax guide */

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-dropdown {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    color: #374151;
    background-color: #fff;
    cursor: pointer;
    outline: none;
}

.select-dropdown:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.action-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    border: none;
    transition: all 0.2s ease;
}

.action-button.primary {
    background-color: #10b981;
    color: white;
}

.action-button.primary:hover {
    background-color: #059669;
}

.dsl-syntax-help {
    padding: 20px;
    margin-top: 20px;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.dsl-syntax-help h3 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
}

.syntax-examples {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.syntax-examples h4 {
    font-size: 16px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.syntax-examples pre {
    background-color: #f3f4f6;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* Style for hidden elements */
.hidden {
    display: none !important;
}

#resultsChartContainer,
.detail-chart-wrapper {
    height: 300px;
    position: relative; /* Important for Chart.js overlay elements like placeholders */
}

/* Ensure canvases within these containers fill the height */
#resultsChartContainer canvas,
.detail-chart-wrapper canvas {
    /* Height is managed by the container and Chart.js, remove fixed JS height */
    /* We rely on maintainAspectRatio: false in Chart.js options */
}

/* === Consolidated CodeMirror Custom Styles === */
.cm-s-default.CodeMirror {
    font-size: 0.75rem !important; /* Match previous smaller font size */
    line-height: 1.35 !important; /* Keep reduced line height */
    font-family: 'Fira Code', monospace !important; 
    height: 100% !important;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
}

/* Other Tokens */
.cm-s-default .cm-comment { color: #15803d !important; font-style: italic;} 
.cm-s-default .cm-number { color: #0369a1 !important; } 
.cm-s-default .cm-variable { color: #374151 !important; } 
.cm-s-default .cm-operator { color: #dc2626 !important; } 
.cm-s-default .cm-polarity { color: #d97706 !important; font-weight: bold; } 
.cm-s-default .cm-function { color: #0e7490 !important; font-weight: bold; } 
.cm-s-default .cm-map-point { color: #075985 !important; font-weight: 500; } 
.cm-s-default .cm-module-reference { color: #6d28d9 !important; font-weight: 500; }

/* Specific DSL Keyword Highlighting - using UNIQUE tokens */
.cm-s-default .cm-keyword-plot { color: #9333ea !important; font-weight: bold !important; } /* Purple */
.cm-s-default .cm-keyword-sweep { color: #f97316 !important; font-weight: bold !important; } /* Orange */
.cm-s-default .cm-keyword-limit { color: #2563eb !important; font-weight: bold !important; } /* Specific Blue for Limit */

/* Default keywords (Standard cm-keyword class) */
.cm-s-default .cm-keyword { 
    color: #0066cc !important; /* Default Blue */
    font-weight: bold !important;
}
/* === End Consolidated Styles === */ 