/**
 * FAQ-Chat Widget Styles
 * höchstmass staff GmbH
 * 
 * Design-System:
 * --primary: #1e3a5f (Navy)
 * --accent: #e67e22 (Orange)
 * Font: Inter
 */

/* ============================================
   WIDGET ICON (Floating Button)
   Unified style: 56x56px at bottom right
============================================ */
#faq-chat-widget-icon {
    position: fixed;
    bottom: 156px; /* Above floating-search (92px) + 52px height + 12px gap */
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.35);
    z-index: 10000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
    outline: none;
}

#faq-chat-widget-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 58, 95, 0.45);
}

#faq-chat-widget-icon:focus {
    outline: 2px solid #e67e22;
    outline-offset: 2px;
}

#faq-chat-widget-icon svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

#faq-chat-widget-icon.open svg.icon-chat {
    display: none;
}

#faq-chat-widget-icon.open svg.icon-close {
    display: block;
}

#faq-chat-widget-icon svg.icon-close {
    display: none;
}

@media (max-width: 768px) {
    #faq-chat-widget-icon {
        bottom: 234px; /* Above floating-search (172px) + 48px height + 14px gap */
        right: 16px;
        width: 48px;
        height: 48px;
    }
    
    #faq-chat-widget-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   SPEECH BUBBLE (Teaser)
============================================ */
#faq-chat-bubble {
    position: fixed;
    bottom: 220px; /* Above chat-widget (156px) + 56px height + 8px gap */
    right: 28px;
    max-width: 260px;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    line-height: 1.45;
    font-size: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: faq-bubble-fadein 0.3s ease-out;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#faq-chat-bubble.fading-out {
    opacity: 0;
}

@keyframes faq-bubble-fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#faq-chat-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #ffffff;
}

#faq-chat-bubble::before {
    content: '';
    position: absolute;
    bottom: -9px;
    right: 19px;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid #e5e7eb;
}

#faq-chat-bubble .bubble-text {
    margin-right: 24px;
}

#faq-chat-bubble .bubble-text strong {
    color: #1e3a5f;
    display: block;
    margin-bottom: 4px;
}

#faq-chat-bubble .bubble-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

#faq-chat-bubble .bubble-close:hover {
    color: #6b7280;
}

#faq-chat-bubble.hidden {
    display: none;
}

@media (max-width: 768px) {
    #faq-chat-bubble {
        bottom: 290px; /* Above chat-widget (234px) + 48px height + 8px gap */
        right: 16px;
        max-width: 220px;
    }
}

/* ============================================
   CHAT CONTAINER
============================================ */
#faq-chat-container {
    position: fixed;
    bottom: 224px; /* Above chat-widget icon */
    right: 28px;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: faq-chat-slidein 0.25s ease-out;
    box-sizing: border-box;
}

@keyframes faq-chat-slidein {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#faq-chat-container.open {
    display: flex;
}

/* ============================================
   CONSENT OVERLAY
============================================ */
#faq-chat-consent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Seit dem 10.08.2026 traegt der Einwilligungsschritt den vollstaendigen
       Hinweis (Empfaenger, Filter, Speicherdauer, Widerruf) und ist damit
       hoeher als die 520 px des Fensters. Gescrollt wird deshalb NUR der Text
       (.consent-text) — Kaestchen und Schaltflaeche bleiben immer sichtbar.
       Waere stattdessen das ganze Overlay scrollbar, laege die Zustimmung
       unter der Kante, und wer nicht scrollt, findet sie nicht. */
    justify-content: flex-start;
    overflow: hidden;
    z-index: 100;
    padding: 24px 22px;
    text-align: center;
}

#faq-chat-consent.hidden {
    display: none;
}

/* Kleiner als früher (64 px): Der Einwilligungstext steht seit dem 10.08.2026
   wörtlich hier und braucht die Höhe dringender als das Symbol. */
.consent-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.25);
}

.consent-icon svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

.consent-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 8px;
}

.consent-text {
    font-size: 12.5px;
    color: #6b7280;
    line-height: 1.55;
    max-width: 300px;
    margin-bottom: 14px;
    /* Linksbuendig: Zentrierter Flattersatz ist bei diesem Textumfang
       schlecht lesbar — und gelesen werden soll er. */
    text-align: left;
    /* min-height: 0 ist noetig, damit der Flex-Kasten ueberhaupt schrumpfen
       darf — ohne das waechst er ueber das Fenster hinaus und scrollt nie. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

/* Der Einwilligungstext kommt seit dem 10.08.2026 wörtlich aus dem
   Odoo-Datensatz und bringt eigene <p>/<ul> mit. Ohne diese Regeln klebt er
   zusammen (Browser-Vorgabe für p ist 1em oben UND unten) und die Liste
   verliert ihre Einzüge. */
.consent-text p {
    margin: 0 0 9px;
}

.consent-text p:last-child {
    margin-bottom: 0;
}

.consent-text ul {
    margin: 0 0 9px;
    padding-left: 18px;
}

.consent-text li {
    margin-bottom: 4px;
}

.consent-text a {
    color: #e67e22;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.consent-text a:hover {
    color: #d35400;
}

.consent-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    text-align: left;
    max-width: 280px;
}

.consent-checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: #1e3a5f;
    cursor: pointer;
    flex-shrink: 0;
}

.consent-checkbox-row label {
    font-size: 12px;
    color: #4b5563;
    cursor: pointer;
    line-height: 1.5;
}

.consent-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.consent-btn-primary {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.consent-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(30, 58, 95, 0.4);
}

.consent-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.consent-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ============================================
   CHAT HEADER
============================================ */
.faq-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 100%);
    color: #ffffff;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.faq-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.faq-chat-header-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.faq-chat-header-avatar svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

.faq-chat-header-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.faq-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

.faq-chat-header-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.faq-chat-header-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.faq-chat-header-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Der Block "BUTTON ROW (Voice Controls)" ist am 10.08.2026 entfallen —
   der Sprach-Chat wurde wegen Datenschutz-Befund DS-04 abgeschaltet. */

/* ============================================
   CHAT MESSAGES
============================================ */
.faq-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
}

.faq-chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    word-break: break-word;
    animation: faq-msg-fadein 0.2s ease-out;
}

@keyframes faq-msg-fadein {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.faq-chat-message.user {
    align-self: flex-end;
    background: #1e3a5f;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.faq-chat-message.ai {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.faq-chat-message.hint {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
    border-radius: 12px;
}

.faq-chat-message.error {
    align-self: center;
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
    border-radius: 12px;
}

/* Typing indicator */
.faq-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.faq-typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: faq-typing-bounce 1.2s infinite ease-in-out;
}

.faq-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.faq-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.faq-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes faq-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ============================================
   INPUT AREA
============================================ */
.faq-chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* Widerruf-Zeile unter der Eingabe (Art. 7 Abs. 3 DSGVO) */
.faq-chat-footer {
    padding: 0 16px 10px;
    background: #ffffff;
    text-align: center;
    flex-shrink: 0;
}

.faq-chat-footer:empty,
.faq-chat-revoke[hidden] {
    display: none;
}

.faq-chat-revoke {
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: 11px;
    color: #9ca3af;
    text-decoration: underline;
    cursor: pointer;
}

.faq-chat-revoke:hover {
    color: #6b7280;
}

.faq-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

.faq-chat-input:focus {
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
    background: #ffffff;
}

.faq-chat-input::placeholder {
    color: #9ca3af;
}

.faq-chat-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a5f 0%, #2c4a6e 100%);
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.faq-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.faq-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.faq-chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    margin-left: 2px;
}

/* ============================================
   RESPONSIVE STYLES
============================================ */
@media (max-width: 991.98px) {
    #faq-chat-widget-icon {
        bottom: 234px;
        right: 16px;
    }

    #faq-chat-container {
        bottom: 296px;
        right: 16px;
        width: min(360px, calc(100vw - 32px));
        max-height: calc(100vh - 340px);
    }

    #faq-chat-bubble {
        bottom: 290px;
        right: 16px;
        max-width: min(260px, calc(100vw - 48px));
    }
}

@media (max-width: 480px) {
    #faq-chat-container {
        width: calc(100vw - 32px);
        right: 16px;
        left: auto;
        height: calc(100vh - 340px);
        max-height: calc(100vh - 200px);
    }

    .faq-chat-header {
        padding: 14px 16px;
    }

    .faq-chat-messages {
        padding: 12px;
    }

    .faq-chat-message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .faq-chat-input-area {
        padding: 12px;
    }
    
    .faq-chat-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .faq-chat-send-btn {
        width: 40px;
        height: 40px;
    }
    
    .consent-text {
        max-width: 100%;
    }
    
    .consent-checkbox-row {
        max-width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY
============================================ */
@media (prefers-reduced-motion: reduce) {
    #faq-chat-bubble,
    #faq-chat-container,
    .faq-chat-message,
    .faq-typing-indicator span {
        animation: none;
    }
    
    #faq-chat-widget-icon,
    .faq-chat-send-btn,
    .consent-btn-primary {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #faq-chat-container {
        border-width: 2px;
    }
    
    .faq-chat-message.ai {
        border: 1px solid #6b7280;
    }
    
    .faq-chat-input {
        border-width: 2px;
    }
}

/* Hidden utility class */
.faq-hidden {
    display: none !important;
}
