/* =========================================
   0. CSS Variablen (Defaults)
   ========================================= */
:root {
    --lux-primary: #2563EB;
    --lux-primary-hover: #1d4ed8;
    --lux-secondary: #F8FAFC;
    --lux-bubble-bg: #ffffff;
    --lux-text: #1e293b;
    --lux-text-light: #64748b;
    
    /* Nachrichten Farben (Defaults) */
    --lux-msg-bot-bg: #ffffff;
    --lux-msg-bot-text: #1e293b;
    --lux-msg-user-bg: #2563EB;
    --lux-msg-user-text: #ffffff;
    
    /* Dimensionen */
    --lux-window-width: 380px;
    --lux-window-height: 650px;
    --lux-radius: 16px;
    --lux-bubble-size: 60px;
    
    /* Z-Index: Muss über allem liegen */
    --lux-z-index: 2147483647; 
}

/* =========================================
   1. Chat Bubble (Der runde Button)
   ========================================= */
#lux-bubble {
    position: fixed;
    bottom: var(--lux-pos-bottom, 25px);
    right: var(--lux-pos-right, 25px);
    left: var(--lux-pos-left, auto);
    top: var(--lux-pos-top, auto);
    width: var(--lux-bubble-size);
    height: var(--lux-bubble-size);
    background: var(--lux-bubble-bg);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15), 0 8px 30px rgba(37, 99, 235, 0.2);
    cursor: pointer;
    z-index: var(--lux-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#lux-bubble:hover {
    transform: scale(1.1);
}

#lux-bubble img, #lux-bubble svg {
    width: 50%;
    height: 50%;
    object-fit: contain;
    fill: #fff;
}

/* =========================================
   2. Chat Window (Hauptfenster)
   ========================================= */
#lux-window {
    position: fixed;
    bottom: var(--lux-win-bottom, 100px);
    right: var(--lux-pos-right, 25px);
    left: var(--lux-pos-left, auto);
    top: var(--lux-win-top, auto);
    
    width: var(--lux-window-width);
    height: var(--lux-window-height);
    max-height: calc(100vh - 120px);
    max-width: calc(100vw - 40px);
    
    background: #fff;
    border-radius: var(--lux-radius);
    box-shadow: 0 12px 48px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
    
    display: none; /* Wird per JS auf flex gesetzt */
    flex-direction: column;
    overflow: hidden;
    z-index: var(--lux-z-index);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    animation: luxFadeUp 0.3s ease-out;
}

@keyframes luxFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   3. Header (Fixiert oben)
   ========================================= */
.lux-header {
    background: var(--lux-primary);
    color: #fff;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: relative;
    z-index: 10;
}

.lux-header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
    object-fit: cover;
}

.lux-header-title {
    font-size: 16px;
    font-weight: 600;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Actions (Reset & Close) */
.lux-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.lux-reset, .lux-close {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
    color: #fff;
}
.lux-reset { font-size: 18px; font-weight: bold; }
.lux-close { font-size: 24px; }

.lux-reset:hover, .lux-close:hover { opacity: 1; }

/* =========================================
   4. Messages Area
   ========================================= */
.lux-messages {
    flex: 1;
    flex-grow: 1;
    min-height: 0;
    background: var(--lux-secondary);
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar Design */
.lux-messages::-webkit-scrollbar { width: 6px; }
.lux-messages::-webkit-scrollbar-track { background: transparent; }
.lux-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

/* Nachrichten Blasen */
.lux-msg {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    box-sizing: border-box; /* WICHTIG: Verhindert Breiten-Probleme */
}

/* Bot Style */
.lux-msg.bot {
    align-self: flex-start;
    background: var(--lux-msg-bot-bg);
    color: var(--lux-msg-bot-text); /* Variable genutzt */
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
}

/* User Style */
.lux-msg.user {
    align-self: flex-end;
    background: var(--lux-msg-user-bg);
    color: var(--lux-msg-user-text); /* Variable genutzt */
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.lux-msg p { margin: 0 0 8px 0; }
.lux-msg p:last-child { margin: 0; }

/* Loading Dots */
.lux-msg.loading {
    background: transparent;
    border: none;
    box-shadow: none;
    color: #94a3b8;
    padding: 0;
    margin-left: 10px;
    font-size: 20px;
    animation: luxPulse 1.5s infinite;
}
@keyframes luxPulse { 
    0% { opacity: 0.3; } 
    50% { opacity: 1; } 
    100% { opacity: 0.3; } 
}

/* =========================================
   5. Interactive Elements (Chips & Links)
   ========================================= */
.lux-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.lux-chip {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: var(--lux-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.lux-chip:hover {
    background: var(--lux-primary);
    color: #fff;
    border-color: var(--lux-primary);
    transform: translateY(-1px);
}

.lux-link-btn {
    display: inline-block;
    background: var(--lux-primary);
    color: #fff !important;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    margin-top: 5px;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}
.lux-link-btn:hover {
    background: var(--lux-primary-hover);
}

/* =========================================
   6. Input Area & Burger Menu
   ========================================= */
.lux-input-area {
    background: #fff;
    padding: 10px 15px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

/* Burger Button */
#lux-burger-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}
#lux-burger-btn:hover {
    background: #f1f5f9;
    color: var(--lux-primary);
    border-color: var(--lux-primary);
}

/* Burger Menu Popover */
#lux-burger-menu {
    position: absolute;
    bottom: 65px; /* Knapp über der Input Area */
    left: 10px;
    width: 200px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 200;
    overflow: hidden;
    animation: luxFadeUp 0.2s ease-out;
    display: none;
}

.lux-menu-header {
    background: #f8fafc;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    border-bottom: 1px solid #e2e8f0;
}

.lux-menu-item {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--lux-text);
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}
.lux-menu-item:hover { background: #f1f5f9; }
.lux-menu-item:last-child { border-bottom: none; }

.lux-menu-reset {
    color: #d63638;
    font-weight: 500;
}

/* Input Feld */
#lux-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    background: #f8fafc;
    transition: all 0.2s;
}
#lux-input:focus {
    background: #fff;
    border-color: var(--lux-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Senden Button */
#lux-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--lux-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.1s;
}
#lux-send:hover { transform: scale(1.05); }

/* =========================================
   7. FORMULARE (NEU: INLINE & POPUP)
   ========================================= */

/* A) INLINE KONTAKTFORMULAR (BUBBLE STYLE) */
.lux-inline-form {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    width: 100%; /* Füllt die 85% der Eltern-Bubble aus */
    box-sizing: border-box;
}

.lux-inline-form h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--lux-primary);
}

.lux-inline-form input,
.lux-inline-form textarea {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    box-sizing: border-box;
    background: #f8fafc;
    display: block;
}

/* HIER IST DIE ÄNDERUNG: RESIZE NUR VERTIKAL */
.lux-inline-form textarea {
    resize: vertical;
    min-height: 60px;
}

.lux-inline-form input:focus, 
.lux-inline-form textarea:focus {
    background: #fff;
    border-color: var(--lux-primary);
    outline: none;
}

/* B) POPUP BUCHUNGSFORMULAR (BLEIBT UNTEN) */
#lux-booking-form {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-height: 75%;
    height: auto;
    background: #fff;
    z-index: 100;
    padding: 20px;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
    animation: slideUp 0.3s ease-out;
    border-top: 1px solid #eee;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

#lux-booking-form p {
    margin-top: 0;
    color: var(--lux-text);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
}

#lux-booking-form input,
#lux-booking-form select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    background: #f8fafc;
}

#lux-booking-form label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    display: block;
    margin-bottom: 4px;
}

/* =========================================
   8. Footer (Unten fixiert, unter Input)
   ========================================= */
.lux-chat-footer-bottom {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 8px;
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    flex-shrink: 0;
}
.lux-chat-footer-bottom a { color: inherit; text-decoration: underline; }

/* Legacy Footer Support (falls noch benötigt) */
.lux-chat-footer { display: none; } 

/* =========================================
   9. Mobile Optimierung
   ========================================= */
@media (max-width: 480px) {
    #lux-window {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
    }
    .lux-header {
        padding-top: 15px; /* Statusbar Platz */
    }
    #lux-bubble {
        bottom: 20px;
        right: 20px;
    }
    #lux-booking-form {
        max-height: 85%;
    }
}

/* =========================================
   FIX: Close Button (X) im Buchungsformular
   ========================================= */
.lux-close-booking {
    position: absolute;   /* Löst das Element aus dem Fluss */
    top: 15px;            /* Abstand von oben */
    right: 15px;          /* Abstand von rechts */
    font-size: 28px;      /* Deutlich größer */
    font-weight: 400;     /* Nicht zu fett, eher elegant */
    color: #64748b;       /* Dezentes Grau */
    cursor: pointer;
    line-height: 1;
    padding: 5px;         /* Größere Klickfläche */
    z-index: 10;          /* Über dem Text liegen */
    transition: color 0.2s ease;
}

.lux-close-booking:hover {
    color: #ef4444;       /* Rot beim Drüberfahren (optional) */
    transform: scale(1.1);
}

/* Sicherstellen, dass der Titel nicht vom X überdeckt wird */
#lux-booking-form p strong {
    display: block;
    padding-top: 10px;    /* Etwas mehr Platz nach oben */
}

/* =========================================
   NEU: Formular Wrapper (Erzwingt 85% Breite)
   ========================================= */
.lux-msg.lux-form-wrapper {
    width: 85%;
    max-width: 85%;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}