/* ============================================================
   Demokratie-Wegweiser Plugin – Such-Formular Styles
   ============================================================ */

.dw-search-wrapper {
    max-width: 650px;
    margin: 1.5rem 0;
    position: relative;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.dw-search-input-group {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #d1d5db;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.dw-search-input-group:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dw-search-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin: 0 0 0 16px;
    color: #9ca3af;
}

.dw-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 12px;
    font-size: 17px;
    line-height: 1.5;
    background: transparent;
    min-width: 0;
    color: #1f2937;
}

.dw-search-input::placeholder {
    color: #9ca3af;
}

.dw-search-button {
    flex-shrink: 0;
    padding: 10px 22px;
    margin: 5px;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
    white-space: nowrap;
}

.dw-search-button:hover:not(:disabled) {
    background: #1d4ed8;
}

.dw-search-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Dropdown ===== */
.dw-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 2px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 380px;
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    margin-top: -2px;
}

.dw-search-results .dw-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

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

.dw-search-results .dw-result-item:hover,
.dw-search-results .dw-result-item.highlighted {
    background: #eff6ff;
}

.dw-result-type-badge {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dw-result-type-badge.state {
    background: #dbeafe;
    color: #1d4ed8;
}

.dw-result-type-badge.district {
    background: #d1fae5;
    color: #047857;
}

.dw-result-type-badge.city {
    background: #f3e8ff;
    color: #7c3aed;
}

.dw-result-info {
    flex: 1;
    min-width: 0;
}

.dw-result-name {
    font-weight: 600;
    font-size: 15px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dw-result-subtitle {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.dw-result-empty {
    padding: 18px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.dw-search-loading {
    padding: 18px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* ===== Embed-Modus (Custom HTML via data-dw-embed-search) ===== */
.dw-embed-active {
    position: relative;
}

.dw-embed-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    max-height: 320px;
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
}

.dw-embed-results .dw-result-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

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

.dw-embed-results .dw-result-item:hover,
.dw-embed-results .dw-result-item.highlighted {
    background: #eff6ff;
}

.dw-embed-results .dw-result-name {
    font-weight: 600;
    font-size: 15px;
    color: #111827;
}

.dw-embed-results .dw-result-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-top: 1px;
}

.dw-embed-results .dw-result-empty {
    padding: 14px 14px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* ===== Spinner ===== */
.dw-spinner {
    animation: dw-rotate 1.4s linear infinite;
    width: 22px;
    height: 22px;
}

.dw-spinner .path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dw-dash 1.4s ease-in-out infinite;
}

@keyframes dw-rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dw-dash {
    0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 89, 200; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 89, 200; stroke-dashoffset: -124; }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .dw-search-input-group {
        flex-wrap: wrap;
    }

    .dw-search-icon {
        display: none;
    }

    .dw-search-input {
        padding: 12px 14px;
        font-size: 16px;
        width: 100%;
    }

    .dw-search-button {
        width: calc(100% - 10px);
        margin: 0 5px 5px;
        padding: 12px;
        text-align: center;
    }
}
