/* ZILEX Chat Bot - Produktionsreife CSS Datei */
/* Diese Datei ist optimiert für Integration in bestehende Websites */

/* Chat Button Container - Fixed Position */
.zilex-chat-button-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999; /* Hoher z-index für Überlagerung */
}

/* Chat Button Icon */
.zilex-chat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 3px solid #ffffff;
    background: white;
    animation: zilex-float 3s ease-in-out infinite;
}

.zilex-chat-icon:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    /* Scale wird zur Float-Animation hinzugefügt */
    animation: zilex-float 3s ease-in-out infinite;
    transform: scale(1.05);
}

.zilex-chat-icon:active {
    transform: scale(0.95);
    animation: none;
}

/* Float Animation - sanftes Schweben */
@keyframes zilex-float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Pulse Animation */
@keyframes zilex-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 184, 159, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(46, 184, 159, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(46, 184, 159, 0);
    }
}

/* Pulse-Animation kann zusätzlich aktiviert werden */
.zilex-chat-icon.pulse {
    animation: zilex-float 3s ease-in-out infinite, zilex-pulse 2s infinite;
}

/* =============================================================================
   CHAT CONTAINER - VERSCHIEDENE STYLES
   ============================================================================= */

/* STYLE 1: Zentriertes Modal (Standard) - Groß & Modern */
.zilex-chat-container.style-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    resize: both; /* Größe anpassbar in beide Richtungen */
    min-width: 400px;
    min-height: 400px;
    max-width: calc(100vw - 40px); /* Max: Bildschirmbreite minus Rand */
    max-height: calc(100vh - 40px); /* Max: Bildschirmhöhe minus Rand */
}

/* STYLE 2: Seitlicher Slide-In (Rechts) - Sprechblase */
.zilex-chat-container.style-sidebar {
    position: fixed;
    top: 20px;
    bottom: 20px;
    right: 20px;
    width: 420px;
    height: auto; /* Auto-Höhe zwischen top und bottom */
    background: white;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    resize: horizontal; /* Nur horizontal anpassbar (Breite) */
    min-width: 320px;
    max-width: 600px; /* Maximal 600px breit */
}

/* STYLE 2: Sprechblasen-Pfeil für Sidebar */
.zilex-chat-container.style-sidebar::after {
    content: '';
    position: absolute;
    right: -15px;
    bottom: 60px;
    width: 0;
    height: 0;
    border-left: 20px solid white;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    filter: drop-shadow(3px 0 5px rgba(0, 0, 0, 0.1));
}

/* STYLE 3: Kompakt Corner - Klein und fein */
.zilex-chat-container.style-compact {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    resize: both; /* Größe anpassbar in beide Richtungen */
    min-width: 320px;
    min-height: 350px;
    max-width: calc(100vw - 100px); /* Max: Bildschirm minus Button-Platz */
    max-height: calc(100vh - 120px); /* Max: Bildschirm minus Button und Rand */
}

/* STYLE 4: Deluxe - Dynamisch: Modal → Compact beim Scrollen */
.zilex-chat-container.style-deluxe {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    resize: both;
    min-width: 400px;
    min-height: 400px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); /* Smooth Transition */
}

/* Deluxe: Compact Mode (beim Scrollen) */
.zilex-chat-container.style-deluxe.compact-mode {
    top: auto;
    left: auto;
    bottom: 90px;
    right: 20px;
    transform: none;
    width: 400px;
    height: 550px;
    border-radius: 16px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
    max-width: calc(100vw - 100px);
    max-height: calc(100vh - 120px);
}

/* Fallback für alte Integration */
.zilex-chat-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 450px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

/* Resize Handle (visueller Indikator) */
.zilex-chat-container[style*="resize"]::before {
    content: '⋮⋮';
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 12px;
    color: #ccc;
    pointer-events: none;
    line-height: 1;
    letter-spacing: -2px;
}

/* Chat Header */
.zilex-chat-header {
    background: linear-gradient(135deg, #2eb89f 0%, #1d9a85 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.zilex-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.zilex-close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.zilex-close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.zilex-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.zilex-user-message, 
.zilex-bot-message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.zilex-user-message {
    background: #2eb89f;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.zilex-bot-message {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Loading Animation */
.zilex-bot-message.loading {
    animation: zilex-loading-dots 1.5s infinite;
}

@keyframes zilex-loading-dots {
    0%, 20% {
        opacity: 0.4;
    }
    40% {
        opacity: 0.7;
    }
    60%, 100% {
        opacity: 1;
    }
}

/* Chat Input Container */
.zilex-chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.zilex-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 20px;
    max-height: 100px;
}

.zilex-chat-input:focus {
    border-color: #2eb89f;
}

.zilex-send-message {
    background: #2eb89f;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.zilex-send-message:hover {
    background: #1d9a85;
}

.zilex-send-message:active {
    transform: scale(0.98);
}

.zilex-send-message:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .zilex-chat-button-container {
        bottom: 16px;
        right: 16px;
    }
    
    .zilex-chat-icon {
        width: 56px;
        height: 56px;
    }
    
    .zilex-chat-container {
        width: calc(100vw - 32px);
        height: 70vh;
        bottom: 80px;
        right: 16px;
        left: 16px;
    }
    
    .zilex-chat-messages {
        padding: 12px;
    }
    
    .zilex-user-message, 
    .zilex-bot-message {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .zilex-chat-input-container {
        padding: 12px;
    }
}

/* Scrollbar Styling */
.zilex-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.zilex-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.zilex-chat-messages::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.zilex-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Accessibility */
.zilex-chat-icon:focus,
.zilex-close-chat:focus,
.zilex-chat-input:focus,
.zilex-send-message:focus {
    outline: 2px solid #2eb89f;
    outline-offset: 2px;
}

/* =============================================================================
   OVERLAY & ANIMATIONS
   ============================================================================= */

/* Dunkles Overlay für Modal und Deluxe Styles */
.zilex-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    backdrop-filter: blur(4px);
    animation: zilex-fade-in 0.3s ease-out;
    transition: opacity 0.6s ease; /* Smooth Fade für Deluxe Mode */
    pointer-events: auto;
}

/* Animation für Slide-In Effect */
@keyframes zilex-slide-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes zilex-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal & Deluxe Slide-In */
.zilex-chat-container.style-modal,
.zilex-chat-container.style-deluxe {
    animation: zilex-slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Sidebar Slide-In von rechts */
.zilex-chat-container.style-sidebar {
    animation: zilex-slide-from-right 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zilex-slide-from-right {
    from {
        opacity: 0;
        right: -100px;
    }
    to {
        opacity: 1;
        right: 20px;
    }
}

/* Compact Slide-In von unten rechts */
.zilex-chat-container.style-compact {
    animation: zilex-slide-from-corner 0.3s ease-out;
}

@keyframes zilex-slide-from-corner {
    from {
        opacity: 0;
        transform: translate(20px, 20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

.zilex-chat-container {
    animation: zilex-slide-in 0.3s ease-out;
}

/* =============================================================================
   RESPONSIVE DESIGN - MOBILE OPTIMIERUNG
   ============================================================================= */

/* Mobile Anpassungen für alle Styles */
@media (max-width: 768px) {
    /* Modal - Vollbild auf Mobile */
    .zilex-chat-container.style-modal {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        transform: none;
        border-radius: 0;
        resize: none;
    }
    
    /* Sidebar - Schmaler auf Mobile */
    .zilex-chat-container.style-sidebar {
        top: 10px;
        bottom: 10px;
        right: 5%;
        left: 5%;
        width: auto;
        height: auto;
        max-width: none;
        border-radius: 20px;
        resize: none;
    }
    
    .zilex-chat-container.style-sidebar::after {
        display: none; /* Pfeil auf Mobile ausblenden */
    }
    
    /* Compact - Größer auf Mobile */
    .zilex-chat-container.style-compact {
        width: 90%;
        height: 70vh;
        bottom: 10px;
        right: 5%;
        left: 5%;
        resize: none;
    }
    
    /* Fullscreen - Echtes Vollbild auf Mobile */
    .zilex-chat-container.style-fullscreen {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
    
    /* Resize-Indikator auf Mobile ausblenden */
    .zilex-chat-container[style*="resize"]::before {
        display: none;
    }
    
    /* Chat-Button kleiner auf Mobile */
    .zilex-chat-icon {
        width: 50px;
        height: 50px;
    }
    
    .zilex-chat-button-container {
        bottom: 15px;
        right: 15px;
    }
}

/* Sehr kleine Bildschirme */
@media (max-width: 480px) {
    .zilex-chat-header h3 {
        font-size: 14px;
    }
    
    .zilex-user-message, 
    .zilex-bot-message {
        font-size: 13px;
        padding: 10px 14px;
        max-width: 85%;
    }
    
    .zilex-chat-input {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .zilex-send-message {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Dark Theme Support (Optional) */
@media (prefers-color-scheme: dark) {
    .zilex-chat-container {
        background: #2b2b2b;
        color: #ffffff;
    }
    
    .zilex-chat-messages {
        background: #1e1e1e;
    }
    
    .zilex-bot-message {
        background: #3b3b3b;
        color: #ffffff;
    }
    
    .zilex-chat-input {
        background: #3b3b3b;
        color: #ffffff;
        border-color: #555555;
    }
    
    .zilex-chat-input-container {
        background: #2b2b2b;
        border-color: #555555;
    }
    
    .zilex-chat-overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}