/**
 * AI Assistant Widget stylesheet
 * Relocated to VSM Website Chatbot bundle.
 */

.ai-assistant {
    position: fixed !important;
    right: 76px;
    bottom: 100px !important;
    margin-bottom: 0 !important;
    width: min(94vw, 520px);
    z-index: 999;
    font-family: "Figtree", sans-serif;
    pointer-events: none;
}

.ai-assistant__toggle {
    position: fixed;
    right: 0;
    bottom: 100px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
}

.ai-assistant__toggle:focus-visible {
    outline: 3px solid rgba(146, 160, 255, 0.45);
    outline-offset: 4px;
}

.ai-assistant__toggle-icon {
    width: 100%;
    height: 100%;
    display: block;
}

.ai-assistant__toggle-icon rect,
.ai-assistant__toggle-icon path {
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.ai-assistant__toggle:hover .ai-assistant__icon-rect,
.ai-assistant__toggle:focus-visible .ai-assistant__icon-rect {
    fill: #113534;
}

.ai-assistant__toggle:hover .ai-assistant__icon-path--outline,
.ai-assistant__toggle:focus-visible .ai-assistant__icon-path--outline {
    stroke: #92a0ff;
}

.ai-assistant__toggle:hover .ai-assistant__icon-path--bubble,
.ai-assistant__toggle:focus-visible .ai-assistant__icon-path--bubble {
    fill: #92a0ff;
    stroke: #92a0ff;
}

.ai-assistant__toggle:hover .ai-assistant__icon-path--detail,
.ai-assistant__toggle:focus-visible .ai-assistant__icon-path--detail {
    fill: #113534;
}

.ai-assistant__panel {
    width: 100%;
    background: var(--bs-white, #fff);
    border: 1px solid var(--bs-gray-300, #dee2e6);
    border-radius: 0;
    box-shadow: 0 18px 36px rgba(17, 54, 52, 0.22);
    display: flex;
    flex-direction: column;
    height: min(820px, calc(100vh - 250px));
    max-height: min(820px, calc(100vh - 250px));
    visibility: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
    pointer-events: none;
    overflow: hidden;
}

.ai-assistant.is-open .ai-assistant__panel {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition-delay: 0s;
    pointer-events: auto;
}

.ai-assistant__header {
    background: var(--bs-primary, #113634);
    color: var(--bs-white, #fff);
    padding: 1rem 1.35rem;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ai-assistant__restart {
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
    color: var(--bs-white, #fff);
    border-radius: 999px;
    padding: 0.25rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ai-assistant__restart:hover,
.ai-assistant__restart:focus-visible {
    background: var(--bs-white, #fff);
    color: var(--bs-primary, #113634);
    border-color: var(--bs-white, #fff);
    outline: none;
}

.ai-assistant__messages {
    padding: 1.05rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1 1 auto;
    overflow-y: auto;
    background: var(--bs-light, #f3f3f3);
    border-bottom: 1px solid var(--bs-gray-200, #e9ecef);
    min-height: 0;
}

.ai-assistant__messages::-webkit-scrollbar {
    width: 0.55rem;
}

.ai-assistant__messages::-webkit-scrollbar-thumb {
    background: rgba(17, 54, 52, 0.3);
    border-radius: 0.5rem;
}

.ai-assistant__message {
    padding: 0.65rem 0.95rem;
    border-radius: 0;
    line-height: 1.5;
    font-size: 0.84rem;
    color: var(--bs-primary, #113634);
    background: var(--bs-white, #fff);
    box-shadow: 0 6px 16px rgba(17, 54, 52, 0.08);
    word-break: break-word;
}

.ai-assistant__message p {
    margin: 0 0 0.65rem;
}

.ai-assistant__message p:last-child {
    margin-bottom: 0;
}

.ai-assistant__message p a:not(.btn),
.ai-assistant__message li a:not(.btn) {
    --bs-link-color-rgb: var(--bs-primary-rgb, 17, 54, 52);
    color: rgba(var(--bs-link-color-rgb), 1);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ai-assistant__message p a:not(.btn):hover,
.ai-assistant__message li a:not(.btn):hover {
    text-decoration-thickness: 2px;
}

.ai-assistant__message--user {
    background: var(--bs-success, #dbe8e2);
    align-self: flex-end;
}

.ai-assistant__message--bot {
    align-self: flex-start;
}

.ai-assistant__message--quick-actions {
    background: rgba(17, 54, 52, 0.08);
    border: 1px solid rgba(17, 54, 52, 0.1);
    box-shadow: none;
}

.ai-assistant__quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    width: 100%;
    justify-content: flex-start;
}

.ai-assistant__quick-action {
    border: 1px solid rgba(17, 54, 52, 0.25);
    background: rgba(17, 54, 52, 0.08);
    color: var(--bs-primary, #113634);
    border-radius: 14px;
    padding: 0.3rem 0.95rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.3;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    pointer-events: auto;
    text-align: left;
}

.ai-assistant__quick-action--summary {
    background: var(--bs-primary, #113634);
    color: var(--bs-white, #fff);
    border-color: transparent;
}

.ai-assistant__quick-action:hover,
.ai-assistant__quick-action:focus-visible {
    background: var(--bs-primary, #113634);
    color: var(--bs-white, #fff);
    border-color: transparent;
    outline: none;
}

.ai-assistant__message--loading {
    background: transparent;
    box-shadow: none;
    padding: 0.2rem 0;
}

.ai-assistant__typing {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.ai-assistant__typing span {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: rgba(17, 54, 52, 0.45);
    animation: ai-assistant-typing 1s infinite ease-in-out;
}

.ai-assistant__sources {
    margin-top: 2rem;
    padding: 0.85rem 1rem;
    background: rgba(17, 54, 52, 0.06);
    border-radius: 0.75rem;
    color: var(--bs-primary, #113634);
    font-size: 0.78rem;
    list-style: none;
}

.ai-assistant__sources li + li {
    margin-top: 0.3rem;
}

.ai-assistant__sources a {
    font-weight: 600;
    color: inherit;
    text-decoration: none !important;
}

.ai-assistant__citation {
    font-weight: 600;
    color: var(--bs-primary, #113634);
    text-decoration: none;
}

.ai-assistant__sources span {
    display: block;
    color: rgba(17, 54, 52, 0.65);
    font-size: 0.72rem;
    margin-top: 0.15rem;
}

.ai-assistant__cta-block {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(17, 54, 52, 0.06);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ai-assistant__cta-lead {
    margin: 0;
    font-weight: 600;
    color: var(--bs-primary, #113634);
}

.ai-assistant__inline-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.ai-assistant__footer {
    padding: 0.95rem 1.2rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: var(--bs-white, #fff);
    flex: 0 0 auto;
}

.ai-assistant__message.ai-assistant__message--bot ul,
.ai-assistant__message.ai-assistant__message--bot ol {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    padding-left: 1rem;
}

.ai-assistant__hint {
    font-size: 0.74rem;
    color: rgba(17, 54, 52, 0.7);
    line-height: 1.45;
}

.ai-assistant__error {
    color: var(--bs-danger, #dc3545);
}

.ai-assistant .ai-assistant__textarea.form-control {
    min-height: 5.6rem !important;
}

.ai-assistant__button[disabled] {
    opacity: 0.75;
    pointer-events: none;
}

.ai-assistant :is(.form-select, .form-control):focus,
.ai-assistant :is(.form-select, .form-control):active {
    box-shadow: none;
}

.ai-assistant .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@keyframes ai-assistant-typing {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.35;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@supports (height: 100dvh) {
    .ai-assistant__panel {
        height: min(820px, calc(100dvh - 250px));
        max-height: min(820px, calc(100dvh - 250px));
    }
}

@media (max-width: 720px) {
    .ai-assistant {
        width: min(94vw, 400px);
    }

    .ai-assistant__panel {
        height: min(720px, calc(100vh - 250px));
        max-height: min(720px, calc(100vh - 250px));
    }

    .ai-assistant__messages {
        padding: 0.95rem 1.05rem;
        gap: 0.6rem;
        min-height: 0;
    }

    .ai-assistant__message {
        font-size: 0.8rem;
        padding: 0.6rem 0.75rem;
    }

    .ai-assistant__sources {
        font-size: 0.74rem;
    }

    .ai-assistant__footer {
        padding: 0.85rem 1.05rem 1.05rem;
        gap: 0.75rem;
    }

    .ai-assistant__textarea {
        min-height: 5.1rem;
    }
}

@media (max-width: 768px) {
    .ai-assistant__toggle {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 576px) {
    .ai-assistant {
        right: 55px;
        width: min(96vw, 340px);
    }

    .ai-assistant__panel {
        height: min(640px, calc(100vh - 250px));
        max-height: min(640px, calc(100vh - 250px));
    }

    @supports (height: 100dvh) {
        .ai-assistant__panel {
            height: min(640px, calc(100dvh - 250px));
            max-height: min(640px, calc(100dvh - 250px));
        }
    }

    .ai-assistant__header {
        padding: 0.75rem 0.9rem;
        font-size: 0.9rem;
    }

    .ai-assistant__messages {
        padding: 0.75rem 0.95rem;
        gap: 0.5rem;
        min-height: 0;
    }

    .ai-assistant__message {
        font-size: 0.76rem;
        padding: 0.55rem 0.65rem;
    }

    .ai-assistant__sources {
        font-size: 0.72rem;
    }

    .ai-assistant__footer {
        padding: 0.7rem 0.9rem 0.85rem;
        gap: 0.6rem;
    }

    .ai-assistant__hint {
        font-size: 0.7rem;
    }

    .ai-assistant .ai-assistant__textarea.form-control {
        min-height: 3.2rem !important;
        height: 3.2rem !important;
    }
}

/* Allow a wider but shorter panel on low-height viewports while keeping 150px top spacing */
@media (max-height: 900px) {
    .ai-assistant {
        width: min(calc(100vw - 76px), 760px);
    }

    .ai-assistant__panel {
        height: min(620px, calc(100vh - 250px));
        max-height: min(620px, calc(100vh - 250px));
    }

    .ai-assistant__footer {
        padding-bottom: 0.8rem;
        gap: 0.55rem;
    }

    .ai-assistant .ai-assistant__textarea.form-control {
        min-height: 3.2rem !important;
        height: 3.2rem !important;
    }
}

@supports (height: 100dvh) {
    @media (max-height: 900px) {
        .ai-assistant__panel {
            height: min(620px, calc(100dvh - 250px));
            max-height: min(620px, calc(100dvh - 250px));
        }
    }
}

/* Hidden form container - use visibility/position to allow scripts to execute */
.ai-assistant__embedded-form[aria-hidden="true"] {
    position: absolute;
    left: -9999px;
    top: -9999px;
    visibility: hidden;
    pointer-events: none;
}

/* Form wrapper and intro styles */
.ai-assistant__form-wrapper {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(17, 54, 52, 0.12);
}

.ai-assistant__form-intro {
    margin: 0 0 1rem;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--bs-primary, #113634);
    font-weight: 500;
}

.ai-assistant__form-intro a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ai-assistant__form-wrapper .ai-assistant__form {
    background: transparent;
    padding: 0;
}

.ai-assistant__form-wrapper label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.78rem;
    color: var(--bs-primary, #113634);
}

.ai-assistant__form-wrapper input[type="text"],
.ai-assistant__form-wrapper input[type="email"],
.ai-assistant__form-wrapper input[type="tel"],
.ai-assistant__form-wrapper textarea,
.ai-assistant__form-wrapper select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--bs-gray-300, #dee2e6);
    border-radius: 0;
    font-size: 0.82rem;
    font-family: inherit;
    background: var(--bs-white, #fff);
    transition: border-color 0.15s ease;
}

.ai-assistant__form-wrapper input:focus,
.ai-assistant__form-wrapper textarea:focus,
.ai-assistant__form-wrapper select:focus {
    outline: none;
    border-color: var(--bs-primary, #113634);
}

.ai-assistant__form-wrapper textarea {
    min-height: 4rem;
    resize: vertical;
}

.ai-assistant__form-wrapper .widget-checkbox label,
.ai-assistant__form-wrapper .form-check-label {
    font-weight: 400;
    font-size: 0.75rem;
    line-height: 1.4;
}

.ai-assistant__form-wrapper .widget:not(.form-floating).widget-submit {
    margin-top: 1rem;
    margin-bottom: 0;
}

.ai-assistant__form-wrapper .checkbox_container {
    padding-inline: 0;
}

.ai-assistant__form-wrapper .form-check {
    padding-left: 2rem;
}

.ai-assistant__form-wrapper .form-check .form-check-input {
    margin-left: -2rem;
}


.ai-assistant__form-wrapper button[type="submit"]:disabled,
.ai-assistant__form-wrapper input[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}


.ai-assistant__form-wrapper .widget-explanation {
    font-size: 0.72rem;
    color: #666;
}

@media (max-width: 576px) {
    .ai-assistant__form-wrapper {
        margin-top: 1rem;
        padding-top: 0.75rem;
    }

    .ai-assistant__form-intro {
        font-size: 0.78rem;
        margin-bottom: 0.75rem;
    }

    .ai-assistant__form-wrapper input[type="text"],
    .ai-assistant__form-wrapper input[type="email"],
    .ai-assistant__form-wrapper input[type="tel"],
    .ai-assistant__form-wrapper textarea,
    .ai-assistant__form-wrapper select {
        padding: 0.45rem 0.55rem;
        font-size: 0.8rem;
    }
}

/* Honeypot protection - hide honeypot fields properly */
.ai-assistant__form-wrapper .widget[class*="hp"],
.ai-assistant__form-wrapper .widget-hp,
.ai-assistant__form-wrapper .hp-wrapper,
.ai-assistant__form-wrapper .formbody > .widget:has(input[name*="hp_"]),
.ai-assistant__form-wrapper .formbody > .widget:has(input[name*="honeypot"]),
.ai-assistant__form-wrapper .formbody > .widget:has(input[name*="_hp"]),
.ai-assistant__form-wrapper input[name*="hp_"],
.ai-assistant__form-wrapper input[name*="honeypot"],
.ai-assistant__form-wrapper input[name*="_hp"] {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* Alternative: Contao often uses aria-hidden for spam protection */
.ai-assistant__form-wrapper .widget[aria-hidden="true"],
.ai-assistant__form-wrapper [style*="display:none"],
.ai-assistant__form-wrapper [style*="display: none"] {
    display: none !important;
}

/* Contao captcha question styling */
.ai-assistant__form-wrapper .widget-captcha {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(17, 54, 52, 0.1);
}

.ai-assistant__form-wrapper .captcha_text {
    font-size: 0.78rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.ai-assistant__form-wrapper .captcha {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-assistant__form-wrapper .captcha input {
    max-width: 80px;
}
