/* Kajinga Coach AI Widget Styles
 *
 * Frontend-Widget: Nutzt eigene CSS-Variablen mit Fallbacks,
 * da Kajinga Styler Design Tokens nur im Admin geladen werden.
 * --coach-primary wird per PHP aus Widget-Settings gesetzt.
 */

/* Widget-eigene Tokens mit Fallbacks */
.coach-widget {
    --coach-radius-full: 9999px;
    --coach-radius-lg: 16px;
    --coach-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --coach-shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --coach-shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --coach-transition: 0.2s ease;
    --coach-space-1: 4px;
    --coach-space-2: 8px;
    --coach-space-3: 12px;
    --coach-space-4: 16px;
    --coach-space-5: 20px;
    --coach-gray-50: #f9fafb;
    --coach-gray-200: #e5e7eb;
    --coach-gray-800: #1f2937;
    --coach-card-bg: #ffffff;

    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Position Classes */
.coach-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.coach-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.coach-chat-button {
    width: 60px;
    height: 60px;
    border-radius: var(--coach-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--coach-shadow-md);
    transition: all var(--coach-transition);
    position: relative;
}

.coach-chat-button:hover {
    transform: scale(1.1);
    box-shadow: var(--coach-shadow-lg);
}

.coach-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #10b981;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    padding: var(--coach-space-1) var(--coach-space-2);
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Chat Window */
.coach-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: var(--coach-card-bg);
    border-radius: var(--coach-radius-lg);
    box-shadow: var(--coach-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: coachSlideIn 0.3s ease;
}

.coach-widget.bottom-left .coach-chat-window {
    left: 0;
    right: auto;
}

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

/* Chat Header */
.coach-chat-header {
    padding: var(--coach-space-5);
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.coach-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--coach-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.coach-chat-title p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.coach-chat-close {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #ffffff;
    font-size: 28px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity var(--coach-transition);
}

.coach-chat-close:hover {
    opacity: 1;
}

/* Messages Area */
.coach-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--coach-space-5);
    background: var(--coach-gray-50);
}

.coach-message {
    margin-bottom: 15px;
    animation: coachFadeIn 0.3s ease;
}

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

.coach-message p {
    padding: var(--coach-space-3) var(--coach-space-4);
    border-radius: var(--coach-radius-lg);
    margin: 0;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.coach-message-bot p {
    background: var(--coach-card-bg);
    color: var(--coach-gray-800);
    box-shadow: var(--coach-shadow-sm);
}

.coach-message-user {
    text-align: right;
}

.coach-message-user p {
    background: var(--coach-primary, #179AFC);
    color: white;
    margin-left: auto;
}

/* Input Area */
.coach-chat-input {
    padding: var(--coach-space-5);
    background: var(--coach-card-bg);
    border-top: 1px solid var(--coach-gray-200);
    display: flex;
    gap: 10px;
}

.coach-chat-input input {
    flex: 1;
    padding: var(--coach-space-3) var(--coach-space-4);
    border: 2px solid var(--coach-gray-200);
    border-radius: var(--coach-radius-full);
    font-size: 14px;
    outline: none;
    transition: all var(--coach-transition);
}

.coach-chat-input input:focus {
    border-color: var(--coach-primary, #179AFC);
}

.coach-chat-input button {
    width: 44px;
    height: 44px;
    border-radius: var(--coach-radius-full);
    background: var(--coach-primary, #179AFC);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--coach-transition);
    flex-shrink: 0;
}

.coach-chat-input button:hover {
    opacity: 0.9;
    transform: scale(1.1);
}

/* Typing Indicator */
.coach-typing p {
    color: #9ca3af;
    font-style: italic;
}

/* Embedded Version */
.coach-chat-window.coach-embedded {
    position: static;
    width: 100%;
    border-radius: var(--coach-radius-lg);
    box-shadow: var(--coach-shadow-md);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .coach-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
    }

    .coach-widget.bottom-left .coach-chat-window {
        left: 20px;
    }
}
