/**
 * leerraeume - ChatBot
 * Nutzt Design-Tokens aus style.css
 * Funktioniert in Light & Dark Mode
 */

/* ================================================
   CHAT BUTTON (Floating)
   ================================================ */

.chat-button {
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    width: 60px;
    height: 60px;
    background: var(--color-secondary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: var(--font-size-2xl);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
    transition: all var(--transition-base);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button:hover {
    background: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(230, 126, 34, 0.4);
}

.chat-button.chat-open {
    background: var(--color-primary);
}

/* ================================================
   CHAT WINDOW
   ================================================ */

.chat-window {
    position: fixed;
    right: var(--space-4);
    bottom: calc(var(--space-4) + 70px);
    width: 450px;
    max-width: calc(100vw - var(--space-5));
    height: 680px;
    max-height: calc(100vh - 150px);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-accent);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ================================================
   CONSENT MODAL (DSGVO)
   ================================================ */

.chat-consent-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    padding: var(--space-4);
}

.chat-consent-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.chat-consent-modal {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-accent);
    border-radius: var(--border-radius-lg);
    padding: var(--space-5);
    max-width: 500px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform var(--transition-base);
}

.chat-consent-overlay.show .chat-consent-modal {
    transform: scale(1);
}

.chat-consent-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.chat-consent-icon {
    font-size: 48px;
}

.chat-consent-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.chat-consent-content {
    color: var(--color-text);
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--space-4);
}

.chat-consent-content p {
    margin-bottom: var(--space-3);
}

.chat-consent-content strong {
    color: var(--color-secondary);
}

.chat-consent-content a {
    color: var(--color-secondary);
    text-decoration: underline;
}

.chat-consent-content a:hover {
    color: var(--color-primary);
}

.chat-consent-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

.chat-consent-btn {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-base);
    font-family: var(--font-body);
}

.chat-consent-btn-accept {
    background: var(--color-secondary);
    color: white;
}

.chat-consent-btn-accept:hover {
    background: var(--color-primary);
    transform: translateY(-2px);
}

.chat-consent-btn-decline {
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-text);
}

.chat-consent-btn-decline:hover {
    background: var(--color-bg);
}

@media (prefers-color-scheme: dark) {
    .chat-consent-btn-accept {
        color: black;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .chat-consent-modal {
        padding: var(--space-4);
    }
    
    .chat-consent-icon {
        font-size: 36px;
    }
    
    .chat-consent-title {
        font-size: var(--font-size-lg);
    }
    
    .chat-consent-actions {
        flex-direction: column;
    }
    
    .chat-consent-btn {
        width: 100%;
    }
}

/* ================================================
   CHAT HEADER
   ================================================ */

.chat-header {
    background: var(--color-secondary);
    color: white;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 600;
    font-size: var(--font-size-base);
}

.chat-status {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: var(--font-size-xl);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-base);
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ================================================
   CHAT MESSAGES
   ================================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-secondary);
}

/* ================================================
   MESSAGE BUBBLES
   ================================================ */

.chat-message {
    display: flex;
    gap: var(--space-2);
    animation: slideIn 0.3s ease;
}

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

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.chat-message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.chat-message-bubble {
    background: var(--color-bg);
    color: var(--color-text);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--border-radius-md);
    line-height: var(--line-height-relaxed);
    font-size: var(--font-size-sm);
    border: 1px solid var(--color-accent);
}

.chat-message-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    padding: 0 var(--space-2);
}

/* User Messages */
.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message.user .chat-message-content {
    align-items: flex-end;
}

.chat-message.user .chat-message-avatar {
    background: var(--color-primary);
}

.chat-message.user .chat-message-bubble {
    background: var(--color-secondary);
    color: white;
    border-color: var(--color-secondary);
}

/* Bot Typing Indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: var(--space-2);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--color-text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* ================================================
   MESSAGE BUTTONS (Call-to-Action)
   ================================================ */

.chat-message-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.chat-message-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
    background: var(--color-secondary);
    color: white;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-base);
    box-shadow: 0 2px 8px rgba(230, 126, 34, 0.2);
}

.chat-message-button:hover {
    background: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
    color: white;
}

.chat-message-button:active {
    transform: translateY(0);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .chat-message-button {
        color: black;
    }
    
    .chat-message-button:hover {
        color: black;
    }
}

/* ================================================
   CHAT INPUT
   ================================================ */

.chat-input-area {
    border-top: 1px solid var(--color-accent);
    padding: var(--space-3);
    display: flex;
    gap: var(--space-2);
}

.chat-input {
    flex: 1;
    background: var(--color-bg);
    border: 1px solid var(--color-accent);
    border-radius: var(--border-radius-md);
    padding: var(--space-2) var(--space-3);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-family: var(--font-body);
    resize: none;
    max-height: 100px;
    transition: all var(--transition-base);
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-secondary);
}

.chat-input::placeholder {
    color: var(--color-text-secondary);
}

.chat-send {
    background: var(--color-secondary);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: var(--font-size-lg);
    transition: all var(--transition-base);
}

.chat-send:hover {
    background: var(--color-primary);
    transform: scale(1.05);
}

.chat-send:disabled {
    background: var(--color-text-secondary);
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
}

/* ================================================
   DARK MODE ANPASSUNGEN
   ================================================ */

@media (prefers-color-scheme: dark) {
    .chat-button,
    .chat-header,
    .chat-send {
        color: black;
    }
    
    .chat-message.user .chat-message-bubble {
        color: black;
    }
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 768px) {
    /* Chat-Button bleibt RECHTS auf Mobile! */
    .chat-button {
        right: var(--space-3);  /* ← RECHTS! */
        left: auto;             /* ← Reset left */
        bottom: var(--space-3);
        width: 56px;
        height: 56px;
    }
    
    /* Chat-Window auch rechts */
    .chat-window {
        right: var(--space-2);  /* ← RECHTS! */
        left: auto;             /* ← Reset left */
        bottom: calc(var(--space-2) + 66px);
        width: calc(100vw - var(--space-4));
        height: calc(100vh - 150px);
    }
}