/* ============================================================
   Letwork Search — Styles
   ============================================================ */

:root {
    --lws-primary: #f7941d;
    --lws-primary-hover: #e5850f;
    --lws-secondary: #2d3748;
    --lws-text: #333;
    --lws-text-light: #595959; /* ≥4.5:1 on white (WCAG AA) */
    --lws-white: #fff;
    --lws-gray-50: #fafafa;
    --lws-gray-100: #f5f5f5;
    --lws-gray-200: #e5e7eb;
    --lws-gray-300: #d1d5db;
    --lws-border: #e0e0e0;
    --lws-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    --lws-radius: 12px;
    --lws-transition: 0.2s ease;
}

/* ── Search Trigger (header button) ── */

.lws-trigger-wrap {
    flex: 1 1 0% !important;
    display: flex !important;
    align-items: center !important;
    min-width: 0 !important;
}

@media (max-width: 1024px) {
    .lws-trigger-wrap {
        display: none !important;
    }
}

.lws-trigger {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 22px;
    border: 2px solid var(--lws-gray-200);
    border-radius: 10px;
    background: var(--lws-white);
    color: var(--lws-text-light);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--lws-transition);
    white-space: nowrap;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    min-height: 46px;
    height: 46px;
    box-sizing: border-box;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.lws-trigger:hover {
    border-color: var(--lws-primary);
    color: var(--lws-text);
    box-shadow: 0 2px 8px rgba(247, 148, 29, 0.15);
}

.lws-trigger__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--lws-primary);
}

.lws-trigger__text {
    flex: 1;
    text-align: left;
}

/* ── Overlay ── */

.lws-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.lws-overlay--open {
    opacity: 1;
    visibility: visible;
}

.lws-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.lws-overlay__container {
    position: relative;
    width: 100%;
    max-width: 920px;
    margin: 0 16px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    max-height: 82vh;
}

/* ── Search Header (search mode only) ── */

.lws-search-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    text-align: center;
    transition: opacity 0.3s, transform 0.3s;
}

.lws-search-header__icon {
    width: 80px;
    height: 80px;
    border-radius: 16px;
}

.lws-search-header__text {
    margin: 0;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
    line-height: 1.5;
    max-width: 460px;
}

.lws-overlay--chat .lws-search-header {
    display: none;
}

/* ── Search Box ── */

.lws-search-box {
    background: var(--lws-white);
    border-radius: var(--lws-radius);
    box-shadow: var(--lws-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 75vh;
    transition: max-height 0.3s;
}

/* Chat mode: results above, input below */
.lws-overlay--chat .lws-search-box {
    flex-direction: column;
    max-height: 75vh;
}

/* ── Input Wrap ── */

.lws-search-box__input-wrap {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 10px;
    border-top: none;
    border-bottom: 1px solid var(--lws-gray-200);
    order: -1;
}

.lws-overlay--chat .lws-search-box__input-wrap {
    order: 1;
    border-bottom: none;
    border-top: 1px solid var(--lws-gray-200);
}

.lws-search-box__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.lws-search-box__icon--search {
    color: var(--lws-primary);
}

.lws-search-box__icon--bot {
    display: none;
    border-radius: 6px;
    background: transparent;
}

.lws-overlay--chat .lws-search-box__icon--search {
    display: none;
}

.lws-overlay--chat .lws-search-box__icon--bot {
    display: block;
}

.lws-search-box__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 500;
    color: var(--lws-text);
    background: transparent;
    font-family: inherit;
    line-height: 1.4;
}

.lws-search-box__input::placeholder {
    color: var(--lws-text-light);
    font-weight: 400;
}

.lws-search-box__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--lws-gray-100);
    border-radius: 6px;
    cursor: pointer;
    color: var(--lws-text-light);
    transition: all var(--lws-transition);
    flex-shrink: 0;
}

.lws-search-box__close:hover {
    background: var(--lws-gray-200);
    color: var(--lws-text);
}

.lws-overlay--chat .lws-search-box__close {
    display: none;
}

/* ── Send Button ── */

.lws-send-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--lws-primary);
    border-radius: 50%;
    cursor: pointer;
    color: var(--lws-white);
    transition: all var(--lws-transition);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(247, 148, 29, 0.3);
}

.lws-send-btn:hover {
    background: var(--lws-primary-hover);
    transform: scale(1.05);
}

.lws-overlay--chat .lws-send-btn,
.lws-search-box--question .lws-send-btn {
    display: flex;
}

/* ── Results / Chat Area ── */

.lws-results {
    overflow-y: auto;
    padding: 0;
    order: 0;
    flex: 1;
    min-height: 0;
}

.lws-results:empty {
    display: none;
}

.lws-overlay--chat .lws-results {
    order: 0;
    min-height: 200px;
}

/* ── Floating Bot Icon (chat mode) ── */

.lws-fab {
    display: none;
    position: absolute;
    bottom: 0;
    right: -72px;
    width: 52px;
    height: 52px;
    border: 2px solid var(--lws-primary);
    background: var(--lws-white);
    border-radius: 50%;
    cursor: pointer;
    padding: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lws-fab img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: transparent;
    object-fit: contain;
    transform: rotate(90deg);
}

.lws-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(247, 148, 29, 0.3);
}

.lws-overlay--chat .lws-fab {
    display: block;
    animation: lws-fab-in 0.3s ease;
}

@keyframes lws-fab-in {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

/* ── Loading ── */

.lws-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--lws-text-light);
    font-size: 14px;
}

.lws-loading__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--lws-gray-200);
    border-top-color: var(--lws-primary);
    border-radius: 50%;
    animation: lws-spin 0.6s linear infinite;
}

@keyframes lws-spin {
    to { transform: rotate(360deg); }
}

/* ── Result Groups ── */

.lws-group {
    border-bottom: 1px solid var(--lws-gray-200);
}

.lws-group:last-child {
    border-bottom: none;
}

.lws-group__title {
    padding: 12px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--lws-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Result Items ── */

.lws-result {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--lws-text);
    transition: background-color var(--lws-transition);
}

.lws-result:hover,
.lws-result--active {
    background-color: var(--lws-gray-50);
}

.lws-result__img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--lws-gray-100);
    flex-shrink: 0;
}

.lws-result__img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--lws-gray-100);
    border-radius: 6px;
    flex-shrink: 0;
    color: var(--lws-gray-300);
}

.lws-result__body {
    flex: 1;
    min-width: 0;
}

.lws-result__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--lws-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.lws-result:hover .lws-result__title {
    color: var(--lws-primary);
}

.lws-result__excerpt {
    font-size: 12px;
    color: var(--lws-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    margin-top: 2px;
}

.lws-result__price {
    font-size: 14px;
    font-weight: 700;
    color: var(--lws-primary);
    flex-shrink: 0;
    white-space: nowrap;
}

.lws-result__arrow {
    width: 16px;
    height: 16px;
    color: var(--lws-gray-300);
    flex-shrink: 0;
    transition: color var(--lws-transition);
}

.lws-result:hover .lws-result__arrow {
    color: var(--lws-primary);
}

/* ── Footer ── */

.lws-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--lws-gray-200);
    text-align: center;
}

.lws-footer__link {
    font-size: 13px;
    font-weight: 600;
    color: var(--lws-primary);
    text-decoration: none;
}

.lws-footer__link:hover {
    color: var(--lws-primary-hover);
}

/* ── Empty State ── */

.lws-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--lws-text-light);
}

.lws-empty__icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--lws-gray-300);
}

.lws-empty__text {
    font-size: 14px;
    margin: 0 0 4px;
}

.lws-empty__hint {
    font-size: 12px;
}

/* ── Mode Hint ── */

.lws-mode-hint {
    padding: 10px 20px;
    font-size: 13px;
    color: var(--lws-text-light);
    text-align: center;
    background: var(--lws-gray-50);
}

/* ── Chat Reset ── */

.lws-chat-reset {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px 8px 20px;
    font-size: 12px;
    text-align: left;
    border-bottom: 1px solid var(--lws-gray-200);
    background: var(--lws-gray-50);
    position: sticky;
    top: 0;
    z-index: 1;
}

.lws-chat-close {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--lws-gray-500, #777);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s, color .15s;
}

.lws-chat-close:hover {
    background: var(--lws-gray-200, #e5e5e5);
    color: #222;
}

.lws-chat-reset a {
    color: var(--lws-primary);
    text-decoration: none;
    font-weight: 600;
}

.lws-chat-reset a:hover {
    color: var(--lws-primary-hover);
}

/* ── Chat Bubbles ── */

/* Formatierte Bot-Antworten (Listen, Absätze, Fett) */
.lws-bubble__content p {
    margin: 0 0 8px;
}
.lws-bubble__content p:last-child {
    margin-bottom: 0;
}
.lws-bubble__content ul,
.lws-bubble__content ol {
    margin: 6px 0 10px;
    padding-left: 20px;
}
.lws-bubble__content li {
    margin: 3px 0;
    line-height: 1.45;
}
.lws-bubble__content strong {
    font-weight: 600;
}
.lws-bubble__content a {
    color: var(--lws-primary, #f08000);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.lws-chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.lws-bubble {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: lws-bubble-in 0.3s ease;
}

@keyframes lws-bubble-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.lws-bubble--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.lws-bubble--bot {
    align-self: flex-start;
}

.lws-bubble__avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
}

.lws-bubble__avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
}

.lws-bubble__content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.lws-bubble--user .lws-bubble__content {
    background: var(--lws-gray-100);
    color: var(--lws-text);
    border-bottom-right-radius: 4px;
}

.lws-bubble--bot .lws-bubble__content {
    background: linear-gradient(135deg, #fff8f0 0%, #fff 100%);
    border: 1px solid rgba(247, 148, 29, 0.15);
    color: var(--lws-text);
    border-bottom-left-radius: 4px;
}

.lws-bubble__content p {
    margin: 0 0 8px;
}

.lws-bubble__content p:last-child {
    margin-bottom: 0;
}

.lws-bubble__disclaimer {
    margin-top: 8px;
    font-size: 11px;
    color: var(--lws-text-light);
    font-style: italic;
    opacity: 0.8;
}

/* ── Chat Products ── */

.lws-chat-products {
    padding: 0 0 0 42px;
    animation: lws-bubble-in 0.3s ease;
}

.lws-chat-products__title {
    font-size: 11px;
    font-weight: 700;
    color: var(--lws-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.lws-chat-products__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lws-chat-products__list .lws-result {
    padding: 8px 12px;
    border-radius: var(--lws-radius);
    border: 1px solid var(--lws-gray-200);
}

.lws-chat-products__list .lws-result:hover {
    border-color: var(--lws-primary);
}

/* ── Typing Indicator ── */

.lws-typing {
    display: flex;
    gap: 10px;
    align-self: flex-start;
    align-items: center;
    animation: lws-bubble-in 0.3s ease;
}

.lws-typing__dots {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #fff8f0 0%, #fff 100%);
    border: 1px solid rgba(247, 148, 29, 0.15);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.lws-typing__dot {
    width: 8px;
    height: 8px;
    background: var(--lws-primary);
    border-radius: 50%;
    animation: lws-typing-bounce 1.4s ease-in-out infinite;
    opacity: 0.4;
}

.lws-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.lws-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes lws-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Mobile ── */

@media (max-width: 640px) {
    .lws-overlay {
        padding-top: 0;
    }

    .lws-overlay__container {
        max-width: none;
        margin: 0;
        height: 100%;
        max-height: 100vh;
    }

    .lws-search-box {
        border-radius: 0;
        max-height: 100vh;
        height: 100%;
    }

    .lws-search-box__input {
        font-size: 16px;
    }

    .lws-trigger {
        min-width: auto;
        padding: 10px 14px;
        min-height: 48px;
        height: 48px;
    }

    .lws-trigger__text {
        display: none;
    }

    .lws-search-header__icon {
        width: 44px;
        height: 44px;
    }

    .lws-search-header__text {
        font-size: 13px;
    }

    .lws-fab {
        bottom: 0;
        right: 8px;
        position: fixed;
    }
}

/* ── Quellen-Verlinkung ── */
.lws-sources {
    margin: 6px 0 4px 52px;
    font-size: 13px;
}
.lws-sources__title {
    font-weight: 600;
    color: #555;
    margin-bottom: 3px;
}
.lws-sources__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.lws-sources__list li {
    margin: 0 0 2px;
}
.lws-sources__list a {
    color: #f08000;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.lws-sources__list a:hover {
    text-decoration: none;
}
.lws-sources__type {
    color: #999;
    font-size: 12px;
}

/* ── Persistenter Launcher unten rechts (Look der vorhandenen Buttons, #to-top) ── */
.lws-launcher {
    position: fixed;
    right: 20px;
    bottom: 140px;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    border: none;
    background: #f59100;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: background-color .2s ease, transform .15s ease;
}
.lws-launcher:hover {
    background: #d97400;
    transform: translateY(-2px);
}
.lws-launcher__icon {
    width: 1.9rem;
    height: 1.9rem;
    display: block;
    color: #fff;
}
.lws-launcher--hidden {
    display: none !important;
}
@media (max-width: 600px) {
    .lws-launcher {
        right: 12px;
        bottom: 130px;
    }
}

/* ── Quick-Replies ── */
.lws-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 6px 52px;
}
.lws-suggestion {
    border: 1px solid #f08000;
    background: #fff;
    color: #f08000;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.lws-suggestion:hover,
.lws-suggestion:focus {
    background: #f08000;
    color: #fff;
}
