/* 
 * Test Executor Component Styles
 * Стили для прототипа компонентов системы тестирования SQL
 */

/* ========================================
 * SQL Editor Component
 * ======================================== */
.sql-editor-component {
    margin-bottom: 1rem;
}

.sql-editor-component .ace_editor {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

/* ========================================
 * Result Table Component
 * Scroll and height are handled inside the component: one scroll in .result-table-body.
 * width/min-width: flex parents + Bootstrap row gutters must not clip the grid or its borders.
 * ======================================== */
.result-table-component {
    margin-bottom: 0;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Rows / Execution time: same scale as DataTable cells (not Bootstrap .small) */
.result-table-component .result-table-metadata {
    font-size: var(--font-size-secondary);
    line-height: var(--line-height-dense, 1.35);
}

/* Single scrollport: only .result-table-body scrolls (nested overflow-x on .dash-table-container
   caused subpixel shifts — left header border flickered with odd/even panel width). */
.result-table-component .result-table-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0 4px;
    box-sizing: border-box;
}

.result-table-component .result-table-body .dash-spreadsheet-container,
.result-table-component .result-table-body .dash-spreadsheet-inner,
.result-table-component .result-table-body .dt-table-container,
.result-table-component .result-table-body .dt-table-container__row,
.result-table-component .result-table-body .dt-table-container__row .cell {
    overflow: visible !important;
}

/* Content height = table only, no empty space at bottom of scroll */
.result-table-component .result-table-body .dash-spreadsheet-inner {
    min-height: 0 !important;
}

.result-table-component .result-table-body .dash-table-container,
.result-table-component .result-table-body .dash-spreadsheet-container {
    padding-bottom: 0 !important;
}

/* Compact grid: table width = content; scroll only on .result-table-body (overflow visible here) */
.result-table-component .result-table-body .dash-table-container {
    overflow: visible !important;
    width: max-content;
    margin-left: 0 !important;
    margin-right: auto !important;
}
.result-table-component .result-table-body .dash-spreadsheet-container {
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* Dash DataTable ships tr { min-height: 30px; height: 30px; } for spreadsheet rows — overrides padding/line-height */
.result-table-component .dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner tr {
    min-height: 0 !important;
    height: auto !important;
}

.result-table-component table {
    font-size: var(--font-size-secondary);
    width: max-content !important;
    line-height: 1;
}
.result-table-component .dash-table-container .dash-spreadsheet-container th,
.result-table-component .dash-table-container .dash-spreadsheet-container td {
    line-height: 1;
    padding: 1px 2px !important;
}

/* Dash DataTable wraps values; avoid stacking padding on td/th (do not force height — can break table layout) */
.result-table-component .dash-table-container .dash-spreadsheet-container th .dash-cell-value-container,
.result-table-component .dash-table-container .dash-spreadsheet-container td .dash-cell-value-container,
.result-table-component .dash-table-container .dash-spreadsheet-container th .dash-cell-value,
.result-table-component .dash-table-container .dash-spreadsheet-container td .dash-cell-value {
    padding: 0 !important;
    min-height: 0;
}

/* Result Card */
.result-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    width: fit-content;
    max-width: 100%;
}

.result-card .card-body {
    overflow-x: auto;
}

/* ========================================
 * Schema Viewer Component
 * ======================================== */
/* Compact schema viewer: less padding and smaller font like result tables */
.schema-viewer-component {
    background-color: var(--accent-color);
    border-radius: 0.375rem;
    padding: 0.2rem;
}

.schema-viewer-component .schema-viewer-title {
    font-size: var(--font-size-section-title);
    line-height: 1.25;
}

/* Grid layout for tables */
.schema-tables-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

/* Individual table card */
.schema-table-card {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 4px 6px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    flex: 0 1 auto;
    min-width: 160px;
    max-width: 320px;
}

.schema-table-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(20, 70, 160, 0.15);
}

/* Table header in card */
.schema-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 3px;
    margin-bottom: 3px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Table icon */
.schema-table-icon {
    color: var(--primary-color);
}

/* Table name */
.schema-table-name {
    color: var(--text-primary);
}

/* Eye buttons: no border, blue like a link; size unchanged */
.schema-table-menu-btn {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--primary-color, #0066cc) !important;
}

.schema-table-menu-btn:hover {
    color: var(--primary-color, #0066cc) !important;
    background: rgba(0, 102, 204, 0.08) !important;
}

/* Schema viewer eye button: compact height */
.schema-viewer-component .schema-table-menu-btn {
    padding: 0 !important;
    height: 20px;
    min-height: 20px;
    line-height: 1;
}

/* Table badge */
.schema-table-badge {
    background-color: var(--primary-color);
    color: white;
}

/* Columns list */
.schema-columns-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 180px;
    overflow-y: auto;
}

/* Individual column item */
.schema-column-item {
    padding: 1px 3px;
    border-radius: 2px;
    transition: background-color 0.15s ease;
    color: var(--text-primary);
    line-height: 1.25;
}

.schema-column-item:hover {
    background-color: var(--accent-color);
}

/* Column icon */
.schema-column-icon {
    color: var(--text-secondary);
}

/* Column name */
.schema-column-name {
    color: var(--text-primary);
}

/* Column type */
.schema-column-type {
    color: var(--text-secondary);
}

/* Scrollbar styling for columns list */
.schema-columns-list::-webkit-scrollbar {
    width: 6px;
}

.schema-columns-list::-webkit-scrollbar-track {
    background: var(--accent-color);
    border-radius: 3px;
}

.schema-columns-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.schema-columns-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Legacy accordion styles (if needed) */
.schema-viewer-component .accordion-button {
    font-size: var(--font-size-secondary);
    padding: 3px 8px;
    background-color: var(--accent-color);
    color: var(--text-primary);
}

.schema-viewer-component .accordion-body {
    padding: 4px 8px;
    background-color: var(--background-color);
    color: var(--text-primary);
}

.schema-viewer-component .bi {
    color: var(--primary-color);
}

.schema-viewer-component h6 {
    color: var(--text-primary);
    font-size: var(--font-size-section-title);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .schema-tables-grid {
        gap: 3px;
    }

    .schema-table-card {
        padding: 4px 6px;
        min-width: 140px;
        max-width: 100%;
        flex: 1 1 100%;
    }
    
    .schema-viewer-component {
        padding: 0.5rem;
    }
}

@media (min-width: 1400px) {
    .schema-table-card {
        min-width: 220px;
        max-width: 400px;
    }
}

/* ========================================
 * Validation Panel Component
 * ======================================== */
.validation-panel-component {
    margin-bottom: 1rem;
}

/* ========================================
 * Task Navigation Component
 * ======================================== */
.task-navigation-component {
    background-color: #ffffff;
}

.task-navigation-component .btn {
    min-width: 40px;
    font-weight: 500;
}

.task-navigation-component .btn-success {
    background-color: var(--bs-success);
    border-color: var(--bs-success);
}

.task-navigation-component .btn-outline-primary:hover {
    background-color: var(--bs-primary);
    color: white;
}

/* ========================================
 * General Test Executor Styles
 * ======================================== */

/* Tabs */
.test-executor-page .nav-tabs .nav-link {
    font-weight: 500;
    color: #6c757d;
}

.test-executor-page .nav-tabs .nav-link.active {
    color: var(--bs-primary);
    font-weight: 600;
}

/* Buttons */
.test-executor-page .btn-group .btn {
    font-weight: 500;
}

/* Code blocks */
.test-executor-page pre {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Cards */
.test-executor-page .card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Badges */
.test-executor-page .badge {
    font-weight: 500;
    font-size: 0.75rem;
}

/* List items */
.test-executor-page .list-group-item {
    border-color: #dee2e6;
}

/* ========================================
 * Responsive Design
 * ======================================== */
@media (max-width: 768px) {
    .sql-editor-component .ace_editor {
        font-size: var(--font-size-secondary);
    }
    
    .task-navigation-component .btn {
        min-width: 35px;
        font-size: 0.875rem;
    }
    
    .result-table-component table {
        font-size: 0.75rem;
    }
}

/* ========================================
 * Dark Mode Support (Optional)
 * Question content and pre stay light to avoid black flash when switching questions.
 * ======================================== */
@media (prefers-color-scheme: dark) {
    /* Schema viewer component всегда остается с серым фоном независимо от темы */
    .schema-viewer-component {
        background-color: #f0f0f0;
        color: #19191A;
    }

    /* Keep question area and code block light so no flash on question switch */
    .test-executor-page .question-card,
    .test-executor-page .panel-content,
    .test-executor-page pre {
        background-color: #ffffff !important;
        border-color: #dee2e6;
        color: #212529;
    }

    /* Result-type component: keep all blocks light (table input, context tables, add-row buttons) */
    .test-executor-page .result-table-input,
    .test-executor-page .result-table-input th,
    .test-executor-page .result-table-input td,
    .test-executor-page .result-table-input input.null-value,
    .test-executor-page .result-table-input input.null-value:focus {
        background-color: #ffffff !important;
        border-color: #dee2e6 !important;
        color: #212529 !important;
    }
    .test-executor-page .result-type-input-component .sql-code-prism,
    .test-executor-page .result-type-input-component .sql-code {
        background-color: #f8f9fa !important;
        border-color: #dee2e6 !important;
        color: #212529 !important;
    }
    .test-executor-page .table-data-display,
    .test-executor-page .table-data-display .data-table {
        background-color: #ffffff !important;
        border-color: #dee2e6 !important;
        color: #212529 !important;
    }
    .test-executor-page .table-data-display h4 {
        color: #212529 !important;
    }
    .test-executor-page .add-row-btn,
    .test-executor-page .add-column-btn {
        background-color: #f8f9fa !important;
        border-color: #dee2e6 !important;
        color: #212529 !important;
    }
    .test-executor-page .add-row-btn:hover,
    .test-executor-page .add-column-btn:hover {
        background-color: #e9ecef !important;
        border-color: #dee2e6 !important;
        color: #212529 !important;
    }
}

/* ========================================
 * Animation & Transitions
 * ======================================== */
.task-navigation-component .btn {
    transition: all 0.2s ease-in-out;
}

.task-navigation-component .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.validation-panel-component .alert {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
 * Utility Classes
 * ======================================== */
.test-executor-page .font-monospace {
    font-family: 'Courier New', Courier, monospace;
}

.test-executor-page .small {
    font-size: 0.875rem;
}

.test-executor-page .text-muted {
    color: #6c757d !important;
}

/* Border utilities */
.test-executor-page .border-primary {
    border-color: var(--bs-primary) !important;
}

/* Spacing utilities */
.test-executor-page .gap-1 {
    gap: 0.25rem;
}

.test-executor-page .gap-2 {
    gap: 0.5rem;
}

