/* ==========================================================================
   RICERCA AVANZATA - Search form and results
   ========================================================================== */

/* ===== SEARCH FORM ===== */

.search-form {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 32px;
}

/* Row layout — explicit rows instead of auto-fill */
.search-form-row {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.search-form-row:last-of-type {
    margin-bottom: 0;
}

.search-form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.search-form-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* ===== FIELDS ===== */

.search-form-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: #1f2937;
    background: white;
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.search-form-field select:focus {
    border-color: #3E78B2;
    box-shadow: 0 0 0 2px rgba(62, 120, 178, 0.15);
}

.search-form-field select optgroup {
    font-weight: 600;
    color: #6b7280;
}

.search-form-field select option {
    font-weight: 400;
    color: #1f2937;
}

/* ===== CHOICES.JS OVERRIDES ===== */

.search-form-field .choices {
    margin-bottom: 0;
}

.search-form-field .choices .choices__inner {
    min-height: 42px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.search-form-field .choices.is-open .choices__inner,
.search-form-field .choices.is-focused .choices__inner {
    border-color: #3E78B2;
    box-shadow: 0 0 0 2px rgba(62, 120, 178, 0.15);
}

.search-form-field .choices .choices__list--multiple .choices__item {
    background: #3E78B2;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 13px;
    font-family: inherit;
    color: white;
    margin: 2px;
}

.search-form-field .choices .choices__list--multiple .choices__item .choices__button {
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    padding-left: 6px;
    margin-left: 6px;
}

.search-form-field .choices .choices__list--dropdown,
.search-form-field .choices .choices__list[aria-expanded] {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-top: 2px;
    z-index: 100;
}

.search-form-field .choices .choices__list--dropdown .choices__item--selectable.is-highlighted,
.search-form-field .choices .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
    background: #eff6ff;
    color: #1f2937;
}

.search-form-field .choices .choices__placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* ===== ACTIONS ===== */

.search-form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}

.search-form-submit {
    display: inline-block;
    padding: 10px 32px;
    background: #3E78B2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.search-form-submit:hover {
    background: #2d5f94;
}

.search-form-reset {
    font-size: 14px;
    color: #6b7280;
    text-decoration: none;
}

.search-form-reset:hover {
    color: #374151;
    text-decoration: underline;
}

.search-back-nav {
    text-align: right;
    margin-bottom: 20px;
}

.btn-back-registry {
    display: inline-block;
    padding: 10px 20px;
    background: #5a8f8a;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-back-registry:hover {
    background: #4a7a75;
}

/* ===== RESULTS ===== */

.search-results-section {
    margin-top: 8px;
}

.search-result-count {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

/* ===== MOBILE ===== */

@media (max-width: 768px) {
    .search-form {
        padding: 16px;
    }

    .search-form-row-3,
    .search-form-row-2 {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .search-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form-submit {
        text-align: center;
    }

    .search-form-reset {
        text-align: center;
    }
}