﻿/* Query Builder - DevOps Style */
.query-builder-container {
    background: var(--bs-body-bg);
    color: #000000;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.qb-header {
    /*background: linear-gradient(90deg, #2c2c3e 0%, #3a3a4e 100%);*/
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid #4a9eff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.qb-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .qb-header-left i {
        font-size: 1.75rem;
        color: #000000;
    }

    .qb-header-left h4 {
        margin: 0;
        font-weight: 600;
        color: #000000;
        font-size: 1.25rem;
    }

.qb-header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-qb {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

    .btn-qb i {
        font-size: 1rem;
    }

.btn-qb-test {
    /*background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);*/
    color: black;
}

    .btn-qb-test:hover:not(:disabled) {
        /*background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);*/
        box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
        transform: translateY(-1px);
    }

    .btn-qb-test:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.btn-qb-save {
    /*background: linear-gradient(135deg, #4a9eff 0%, #357abd 100%);*/
    color: black;
}

    .btn-qb-save:hover {
        /*background: linear-gradient(135deg, #357abd 0%, #2563a8 100%);*/
        box-shadow: 0 4px 8px rgba(74, 158, 255, 0.3);
        transform: translateY(-1px);
    }

.btn-qb-cancel {
    /*background: linear-gradient(135deg, #666 0%, #555 100%);*/
    color: black;
    padding: 0.5rem 0.75rem;
}

    .btn-qb-cancel:hover {
        /*background: linear-gradient(135deg, #555 0%, #444 100%);*/
    }

.qb-body {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.qb-section {
    /*background: rgba(42, 42, 62, 0.6);*/
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

    .qb-section:hover {
        border-color: rgba(74, 158, 255, 0.4);
        box-shadow: 0 4px 12px rgba(74, 158, 255, 0.1);
    }

.qb-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

    .qb-section-header label {
        font-weight: 600;
        color: #000000;
        margin: 0;
        flex-grow: 1;
    }

.qb-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Courier New', monospace;
}

.qb-badge-blue {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.qb-badge-green {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.qb-badge-purple {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.qb-badge-orange {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.qb-badge-gray {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.qb-select,
.qb-select-sm {
    /*background: rgba(30, 30, 46, 0.8);*/
    color: #000000;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.qb-select {
    width: 100%;
}

.qb-select-sm {
    min-width: 120px;
}

    .qb-select:focus,
    .qb-select-sm:focus {
        outline: none;
        border-color: #4a9eff;
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
    }

.qb-input-sm {
    /*background: rgba(30, 30, 46, 0.8);*/
    color: #000000;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

    .qb-input-sm:focus {
        outline: none;
        border-color: #4a9eff;
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
    }

.qb-columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.qb-column-item {
    /*background: rgba(30, 30, 46, 0.6);*/
    border: 1px solid rgba(74, 158, 255, 0.15);
    border-radius: 6px;
    padding: 0.75rem;
    transition: all 0.2s ease;
}

    .qb-column-item:hover {
        border-color: rgba(74, 158, 255, 0.3);
        /*background: rgba(30, 30, 46, 0.8);*/
    }

.qb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #000000;
    font-weight: 500;
}

    .qb-checkbox-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
        cursor: pointer;
        accent-color: #000000;
    }

.qb-column-config {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.qb-conditions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.qb-condition-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    /*background: rgba(30, 30, 46, 0.6);*/
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.qb-logical-op {
    /*background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);*/
    color: black;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 60px;
}

.btn-qb-sm {
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-qb-add {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    margin-left: auto;
}

    .btn-qb-add:hover {
        background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
        box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
    }

.btn-qb-remove {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: black;
}

    .btn-qb-remove:hover {
        /*background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%);*/
        box-shadow: 0 2px 6px rgba(244, 67, 54, 0.3);
    }

.qb-groupby-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.qb-checkbox-label-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #000000;
    padding: 0.5rem;
    /*background: rgba(30, 30, 46, 0.6);*/
    border-radius: 4px;
    border: 1px solid rgba(156, 39, 176, 0.2);
    transition: all 0.2s ease;
}

    .qb-checkbox-label-compact:hover {
        border-color: rgba(156, 39, 176, 0.4);
        /*background: rgba(30, 30, 46, 0.8);*/
    }

    .qb-checkbox-label-compact input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        accent-color: #9c27b0;
    }

.qb-section-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.qb-preview-section {
    /*background: rgba(30, 30, 46, 0.9);*/
    border-color: rgba(96, 125, 139, 0.4);
}

.qb-preview {
    /*background: #1a1a2e;*/
    border: 1px solid rgba(96, 125, 139, 0.3);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
}

    .qb-preview pre {
        margin: 0;
        color: #4a9eff;
        font-family: 'Cascadia Code', 'Courier New', monospace;
        font-size: 0.9rem;
        white-space: pre-wrap;
        word-break: break-word;
    }

    .qb-preview code {
        color: #4a9eff;
    }

.qb-test-result {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

    .qb-test-result.success {
        /*background: rgba(76, 175, 80, 0.2);*/
        border: 1px solid rgba(76, 175, 80, 0.5);
        color: #4caf50;
    }

    .qb-test-result.error {
        /*background: rgba(244, 67, 54, 0.2);*/
        border: 1px solid rgba(244, 67, 54, 0.5);
        color: #f44336;
    }

    .qb-test-result i {
        font-size: 1.25rem;
    }

/* Scrollbar Styling */
.qb-preview::-webkit-scrollbar {
    height: 8px;
}

.qb-preview::-webkit-scrollbar-track {
    /*background: rgba(30, 30, 46, 0.5);*/
    border-radius: 4px;
}

.qb-preview::-webkit-scrollbar-thumb {
    background: rgba(74, 158, 255, 0.5);
    border-radius: 4px;
}

    .qb-preview::-webkit-scrollbar-thumb:hover {
        /*background: rgba(74, 158, 255, 0.7);*/
    }

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qb-section {
    animation: slideIn 0.3s ease;
}

.flex-grow-1 {
    flex-grow: 1;
}

/* Query Mode Selector */
.qb-mode-selector {
    display: flex;
    gap: 1rem;
}

.qb-mode-option {
    flex: 1;
    cursor: pointer;
    position: relative;
}

    .qb-mode-option input[type="radio"] {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

.qb-mode-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    /*background: rgba(30, 30, 46, 0.6);*/
    border: 2px solid rgba(74, 158, 255, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.qb-mode-option:hover .qb-mode-content {
    border-color: rgba(74, 158, 255, 0.4);
    /*background: rgba(30, 30, 46, 0.8);*/
    transform: translateY(-2px);
}

.qb-mode-option.active .qb-mode-content {
    border-color: #4a9eff;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.2) 0%, rgba(53, 122, 189, 0.2) 100%);
    box-shadow: 0 0 12px rgba(74, 158, 255, 0.3);
}

.qb-mode-content i {
    font-size: 2rem;
    color: #000000;
}

.qb-mode-content span {
    font-weight: 600;
    color: #000000;
    font-size: 0.9rem;
}

.qb-badge-primary {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.qb-badge-cyan {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

/* JOIN Section Styling */
.qb-join-section {
    border-color: rgba(0, 188, 212, 0.3);
}

.qb-joins-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.qb-join-item {
    /*background: rgba(30, 30, 46, 0.8);*/
    border: 1px solid rgba(0, 188, 212, 0.3);
    border-radius: 6px;
    padding: 1rem;
    transition: all 0.2s ease;
}

    .qb-join-item:hover {
        border-color: rgba(0, 188, 212, 0.5);
        /*background: rgba(30, 30, 46, 0.95);*/
        box-shadow: 0 2px 8px rgba(0, 188, 212, 0.2);
    }

.qb-join-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.qb-join-number {
    /*background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);*/
    color: black;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    min-width: 30px;
    text-align: center;
}

.qb-join-on {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0. 75rem;
    /*background: rgba(0, 188, 212, 0.05);*/
    border-radius: 4px;
    border: 1px dashed rgba(0, 188, 212, 0.3);
}

.qb-join-on-label {
    font-weight: 700;
    color: #00bcd4;
    font-size: 0.85rem;
    text-transform: uppercase;
    min-width: 30px;
}

.qb-join-equals {
    font-weight: 700;
    color: #00bcd4;
    font-size: 1.1rem;
    padding: 0 0.25rem;
}

.qb-empty-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #9e9e9e;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

    .qb-empty-message i {
        font-size: 1.25rem;
    }

/* Responsive adjustments */
@media (max-width: 992px) {
    .qb-split-container {
        grid-template-columns: 1fr;
    }

    .qb-panel-right {
        border-left: none;
        border-top: 1px solid rgba(74, 158, 255, 0.2);
    }
}

@media (max-width: 768px) {
    .qb-mode-selector {
        flex-direction: column;
    }

    .qb-join-header {
        flex-wrap: wrap;
    }

    .qb-join-on {
        flex-direction: column;
        align-items: stretch;
    }

    .qb-join-on-label,
    .qb-join-equals {
        text-align: center;
    }
}

/* Split View Layout */
.qb-split-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0;
    padding: 0;
    height: calc(100vh - 80px);
    /* Adjust based on header height */
    overflow: hidden;
}

.qb-panel-left {
    padding: 1.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

.qb-panel-right {
    /*background: rgba(30, 30, 46, 0.4);*/
    border-left: 1px solid rgba(74, 158, 255, 0.2);
    padding: 1.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

.qb-sticky-preview {
    position: sticky;
    top: 0;
}

.btn-qb-test-sm {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.qb-test-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 6px;
    font-weight: 500;
}

/* Scrollbar refinements */
/*.qb-panel-left::-webkit-scrollbar,
.qb-panel-right::-webkit-scrollbar {
    width: 8px;
}

.qb-panel-left::-webkit-scrollbar-track,
.qb-panel-right::-webkit-scrollbar-track {
    background: rgba(30, 30, 46, 0.5);
}

.qb-panel-left::-webkit-scrollbar-thumb,
.qb-panel-right::-webkit-scrollbar-thumb {
    background: rgba(74, 158, 255, 0.3);
    border-radius: 4px;
}

.qb-panel-left::-webkit-scrollbar-thumb:hover,
.qb-panel-right::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 158, 255, 0.5);
}*/

/* Results Grid Styling */
.qb-results-grid {
    margin-top: 1rem;
    overflow-x: auto;
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 6px;
    /*background: rgba(30, 30, 46, 0.6);*/
}

.qb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: #e0e0e0;
}

    .qb-table th {
        /*background: rgba(74, 158, 255, 0.1);*/
        padding: 0.75rem 1rem;
        text-align: left;
        font-weight: 600;
        color: #4a9eff;
        border-bottom: 2px solid rgba(74, 158, 255, 0.2);
        white-space: nowrap;
        position: sticky;
        top: 0;
    }

    .qb-table td {
        padding: 0.6rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        white-space: nowrap;
    }

    .qb-table tr:last-child td {
        border-bottom: none;
    }

/*.qb-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}*/
