/* =========================================
   Emma – KI-Chat-Assistentin
   Pelikan Apotheke Delmenhorst
   ========================================= */

.emma-chat-btn {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 9100;
    width: 68px;
    height: 68px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(26, 120, 185, 0.35), 0 0 0 3px rgba(26, 120, 185, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: emma-pulse 3s ease-in-out infinite;
    padding: 0;
    overflow: hidden;
}

.emma-chat-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 28px rgba(26, 120, 185, 0.5), 0 0 0 3px rgba(26, 120, 185, 0.35);
}

.emma-chat-btn.emma-hidden {
    display: none;
}

.emma-chat-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.emma-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: #e2001a;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: emma-badge-ping 2s ease-in-out 3;
}

.emma-chat-btn::after {
    content: 'Emma';
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #1a78b9;
    background: #fff;
    padding: 2px 8px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    white-space: nowrap;
    font-family: 'Open Sans', sans-serif;
}

@keyframes emma-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(26, 120, 185, 0.35), 0 0 0 3px rgba(26, 120, 185, 0.2); }
    50% { box-shadow: 0 4px 28px rgba(26, 120, 185, 0.5), 0 0 0 4px rgba(26, 120, 185, 0.3); }
}

@keyframes emma-badge-ping {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Chat Window */
.emma-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 9200;
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.emma-window.emma-open {
    display: flex;
    animation: emma-slide-up 0.3s ease-out;
}

@keyframes emma-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.emma-header {
    background: linear-gradient(135deg, #1a78b9 0%, #1565a0 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.emma-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.emma-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.emma-header-info {
    flex: 1;
    min-width: 0;
}

.emma-header-name {
    font-weight: 700;
    font-size: 16px;
}

.emma-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.emma-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
}

.emma-close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.emma-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* DSGVO Consent Screen */
.emma-consent {
    padding: 24px 18px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
}

.emma-consent-icon {
    font-size: 40px;
}

.emma-consent h3 {
    font-size: 17px;
    color: #252525;
    margin: 0;
}

.emma-consent p {
    font-size: 13px;
    color: #606060;
    margin: 0;
    line-height: 1.6;
}

.emma-consent a {
    color: #1a78b9;
    text-decoration: underline;
}

.emma-consent-accept {
    background: #1a78b9;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.emma-consent-accept:hover {
    background: #155d94;
}

/* Messages */
.emma-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 260px;
    max-height: 360px;
    scroll-behavior: smooth;
}

.emma-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.emma-msg--bot {
    align-self: flex-start;
    background: #f0f4f8;
    color: #252525;
    border-bottom-left-radius: 4px;
}

.emma-msg--user {
    align-self: flex-end;
    background: #1a78b9;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.emma-msg--system {
    align-self: center;
    background: #fff3cd;
    color: #664d03;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    text-align: center;
}

/* Quick Actions */
.emma-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 6px;
    flex-shrink: 0;
}

.emma-quick-btn {
    background: #e8f1f8;
    color: #1a78b9;
    border: 1px solid #c8ddf0;
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.emma-quick-btn:hover {
    background: #1a78b9;
    color: #fff;
    border-color: #1a78b9;
}

/* Typing indicator */
.emma-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: #f0f4f8;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.emma-typing span {
    width: 7px;
    height: 7px;
    background: #90a4ae;
    border-radius: 50%;
    animation: emma-dot 1.4s ease-in-out infinite;
}

.emma-typing span:nth-child(2) { animation-delay: 0.2s; }
.emma-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes emma-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.emma-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #eaeaea;
    flex-shrink: 0;
    background: #fafafa;
}

.emma-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}

.emma-input:focus {
    border-color: #1a78b9;
}

.emma-send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: #1a78b9;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}

.emma-send-btn:hover {
    background: #155d94;
    transform: scale(1.05);
}

.emma-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.emma-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Footer */
.emma-footer {
    padding: 6px 14px 8px;
    text-align: center;
    font-size: 11px;
    color: #999;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.emma-footer a {
    color: #1a78b9;
    text-decoration: none;
}

/* Links in messages */
.emma-link {
    color: #1a78b9;
    text-decoration: underline;
    word-break: break-all;
}

.emma-msg--bot .emma-link {
    color: #1565a0;
}

.emma-msg--bot .emma-link:hover {
    color: #0d47a1;
}

/* Category tags in messages */
.emma-tag {
    display: inline-block;
    background: rgba(26, 120, 185, 0.12);
    color: #1a78b9;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 6px;
}

.emma-msg--bot .emma-tag {
    background: rgba(26, 120, 185, 0.08);
}

/* Forwarded notice */
.emma-forwarded {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: #4caf50;
    font-weight: 600;
}

.emma-forwarded::before {
    content: '\2713';
}

/* Responsive */
@media (max-width: 480px) {
    .emma-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .emma-messages {
        max-height: calc(100vh - 220px);
        max-height: calc(100dvh - 220px);
    }

    .emma-chat-btn {
        bottom: 80px;
        right: 16px;
        width: 60px;
        height: 60px;
    }
}
