/**
 * Query Search Builder Styles
 */

#query-search-app {
    max-width: 900px;
    margin: 0 auto;
}

/* Query Builder Container */
.query-builder {
    background: transparent;
    border: 0;
    border-radius: 8px;
    padding: 0;
    margin-bottom: 1rem;
}

/* Gruppo */
.group {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.5rem 0;
}

.group.root-group {
    border-color: #bc6c25;
    border-width: 1px;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.group-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 600;
}

.group-content {
    padding: 0.5rem 0;
}

.group-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

/* Condizione */
.condition {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #fff;
    border-radius: 4px;
    flex-wrap: wrap;
}

.condition select,
.condition input {
    padding: 0.375rem 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
}

.field-select {
    min-width: 120px;
}

.op-select {
    min-width: 120px;
}

.value-input {
    flex: 1;
    min-width: 150px;
}

.value-input[type="date"] {
    min-width: 140px;
    flex: 0 0 auto;
}

/* Flatpickr date inputs */
.date-input {
    min-width: 120px;
    max-width: 140px;
    flex: 0 0 auto;
}

.date-input.flatpickr-input {
    background: #fff;
}

/* L'input alternativo creato da Flatpickr (quello visibile) */
input.flatpickr-input[readonly] {
    background: #fff;
    cursor: pointer;
    min-width: 120px;
    max-width: 140px;
}

/* Container per i campi between */
.between-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.value-input-2 {
    min-width: 140px;
    padding: 0.375rem 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
}

.between-separator {
    padding: 0 0.25rem;
    color: #6c757d;
    font-size: 0.85rem;
    font-style: italic;
}

/* Connettore logico */
.logic-connector {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0;
}

.logic-select {
    padding: 0.25rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
}

.logic-select:hover {
    border-color: #bc6c25;
}

/* Bottoni */
.btn-remove,
.btn-remove-group {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.btn-remove:hover,
.btn-remove-group:hover {
    color: #a71d2a;
}

.btn-add-condition,
.btn-add-group {
    padding: 0.25rem 0.75rem;
    border: 1px dashed #6c757d;
    border-radius: 4px;
    background: none;
    color: #6c757d;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-add-condition:hover,
.btn-add-group:hover {
    border-color: #bc6c25;
    color: #bc6c25;
    background: #e7f1ff;
}

/* Azioni principali */
.query-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background: #bc6c25;
    color: #fff;
}

.btn-primary:hover {
    background: #0b5ed7;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #5c636a;
}

/* Preview query */
.query-preview {
    background: #212529;
    color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-family: monospace;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.query-preview code {
    color: #7dd3fc;
    flex: 1;
}

.btn-help {
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-help:hover {
    background: #5c636a;
}

/* Help panel */
.query-help {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.query-help[hidden] {
    display: none;
}

.btn-close-help {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
}

.btn-close-help:hover {
    color: #212529;
}

.query-help h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #212529;
}

.query-help h4 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 0.95rem;
}

.query-help ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.query-help li {
    margin-bottom: 0.35rem;
}

.query-help code {
    background: #f1f3f4;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
    color: #d63384;
}

.help-example {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    border-radius: 0 4px 4px 0;
}

.help-example.correct {
    background: #d1e7dd;
    border-left-color: #198754;
}

.help-example code {
    display: block;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.05);
}

.help-example p {
    margin: 0;
    font-size: 0.9rem;
    color: #495057;
}

/* Risultati */
.search-results {
    margin-top: 2rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.error {
    background: #f8d7da;
    color: #842029;
    padding: 1rem;
    border-radius: 4px;
}

.no-results {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

.results-count {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-item {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.result-item:last-child {
    border-bottom: none;
}

.result-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #bc6c25;
    text-decoration: none;
}

.result-title:hover {
    text-decoration: underline;
}

.result-description {
    margin: 0.5rem 0;
    color: #495057;
    font-size: 0.95rem;
}

.result-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Responsive */
@media (max-width: 600px) {
    .condition {
        flex-direction: column;
        align-items: stretch;
    }

    .condition select,
    .condition input {
        width: 100%;
    }

    .query-actions {
        flex-direction: column;
    }
}
