/* WP Rifiuti – Public Styles */

.wpr-search-wrap {
    margin-left: auto;
    margin-right: auto;
    isolation: isolate;
    position: relative;
    font-family: inherit;
    width: 100%;
    max-width: 680px;
    box-sizing: border-box;
}

.wpr-title {
    font-size: 32px !important;
    margin-bottom: 20px;
    text-align: center;
}

/* Form */
.wpr-form {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.wpr-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 220px;
}
.wpr-field label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}
.wpr-select-comune,
.wpr-input-rifiuto {
    box-sizing: border-box !important;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
}
.wpr-select-comune {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' stroke='%23666' stroke-width='1' fill='none' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    outline: none;
    cursor: pointer;
}
.wpr-select-comune:focus,
.wpr-input-rifiuto:focus,
.wpr-input-rifiuto.wpr-open {
    border-color: var(--form_focus_border_color, #ccc) !important;
    outline: none !important;
    box-shadow: none !important;
}
.wpr-input-rifiuto:disabled {
    background: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

/* Autocomplete */
.wpr-autocomplete-wrap { position: relative; z-index: 2147483647; transform: translateZ(0); }
.wpr-suggestions {
    position: absolute;
    top: calc(100% - 1px); left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--form_focus_border_color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 2147483647;
    box-shadow: none;
    display: none;
}
.wpr-suggestions .wpr-sug-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    transition: background .15s;
}
.wpr-suggestions .wpr-sug-item:last-child { border-bottom: none; }
.wpr-suggestions .wpr-sug-item:hover,
.wpr-suggestions .wpr-sug-item.focused { background: #f0f7ff; }
.wpr-suggestions .wpr-sug-item mark {
    background: #FFF176;
    border-radius: 2px;
    padding: 0;
    display: inline;
    font-style: normal;
    letter-spacing: normal;
    word-spacing: normal;
}

/* Dot configurato/non */
.wpr-sug-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 8px;
    align-self: center;
}
.wpr-dot-ok { background: #2E7D32; }
.wpr-dot-no { background: #ddd; }

/* Categoria pill nel suggerimento */
.wpr-sug-cat {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 10px;
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Result card */
.wpr-result-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px 24px;
    border-radius: 10px;
    background: #f8fffe;
    border: 1px solid #e0f2f1;
    margin-top: 8px;
    animation: wpr-fadein .25s ease;
    box-sizing: border-box;
    width: 100%;
}
.wpr-result-card.wpr-not-configured {
    background: #fafafa;
    border-color: #e0e0e0;
    box-sizing: border-box;
    width: 100%;
}
.wpr-result-icon { font-size: 2em; line-height: 1; }
.wpr-result-body { flex: 1; }
.wpr-result-body h3 { margin: 0 0 8px; font-size: 1.1em; }

.wpr-result-cat { margin-bottom: 10px; }
.wpr-cat-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.wpr-result-sentence {
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 8px;
}
.wpr-note {
    font-size: 13px;
    color: #555;
    background: #fffde7;
    border-left: 3px solid #F9A825;
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
    margin: 8px 0 0;
}

/* Color dot inline */
.wpr-color-dot {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    margin: 0 2px;
    border: 1px solid rgba(0,0,0,.15);
}

/* Loading */
.wpr-result-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 14px;
    padding: 12px 0;
}
.wpr-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid #ddd;
    border-top-color: #1565C0;
    border-radius: 50%;
    animation: wpr-spin .7s linear infinite;
}

/* Status messages */
.wpr-result-not-found,
.wpr-result-error {
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    color: #555;
    background: #fafafa;
    border: 1px solid #eee;
}
.wpr-result-error { background: #fff3f3; border-color: #ffcdd2; color: #C62828; }

.wpr-notice {
    color: #999;
    font-style: italic;
}

@keyframes wpr-spin    { to { transform: rotate(360deg); } }
@keyframes wpr-fadein  { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Responsive */
@media (max-width: 520px) {
    .wpr-form { flex-direction: column; }
    .wpr-result-card { flex-direction: column; gap: 10px; padding: 16px; }
}

/* Input con suggerimenti aperti: angoli inferiori piatti */
.wpr-input-rifiuto.wpr-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: var(--form_focus_border_color, #4a7c59);
}

.wpr-sug-text {
    flex: 1;
    min-width: 0;
}

/* ── Mobile ── */
@media (max-width: 600px) {

    .wpr-search-wrap {
    margin-left: auto;
    margin-right: auto;
    isolation: isolate;
    position: relative; max-width: 100%; }
    .wpr-title { font-size: 1.2em; margin-bottom: 14px; }

    .wpr-form { flex-direction: column; gap: 10px; }
    .wpr-field { min-width: 0; }

    .wpr-select-comune,
    .wpr-input-rifiuto {
        font-size: 16px; /* evita zoom automatico iOS */
        padding: 12px 14px;
    }

    .wpr-suggestions {
        max-height: 220px;
    }

    .wpr-suggestions .wpr-sug-item {
        padding: 12px 14px;
        font-size: 15px;
    }

    .wpr-sug-cat {
        font-size: 10px;
        padding: 1px 6px;
        flex-shrink: 0;
    }

    .wpr-result-card {
        flex-direction: column;
        gap: 10px;
        padding: 16px;
    }

    .wpr-result-icon { font-size: 1.6em; }
    .wpr-result-sentence { font-size: 15px; }
}

/* ── Select comune custom ── */
.wpr-select-wrap {
    position: relative;
    width: 100%;
}
.wpr-select-wrap::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #666;
    pointer-events: none;
}
.wpr-select-comune {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 15px;
    box-sizing: border-box;
    background: #fff;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.wpr-select-comune:focus {
    outline: none;
}

/* Result non sposta il layout - occupa spazio già riservato */
.wpr-form { margin-bottom: 0; }
.wpr-result { margin-top: 16px; width: 100%; box-sizing: border-box; }
