/* WhatsApp Button Widget - Frontend Styles */

/* SVG Reset - Verhindert externe Interferenzen */
.wa-button-widget svg {
    pointer-events: none !important;
}

:root {
    --wa-button-green: #25d366;
    --wa-button-dark-green: #075e54;
    --wa-button-header-bg: #128c7e;
    --wa-button-chat-bg: #ece5dd;
    --wa-button-white: #ffffff;
    --wa-button-text-dark: #303030;
    --wa-button-text-light: #ffffff;
    --wa-button-shadow: rgba(0, 0, 0, 0.15);
}

/* Widget Container */
.wa-button-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    isolation: isolate;
}

.wa-button-widget * {
    box-sizing: border-box;
}

/* Floating Button */
.wa-button-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--wa-button-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--wa-button-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    color: var(--wa-button-white);
}

.wa-button-widget[data-theme="dunkel"] .wa-button-trigger {
    background-color: var(--wa-button-dark-green);
}

.wa-button-trigger:hover,
.wa-button-trigger:focus {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    background-color: #1fbd5a;
}

.wa-button-trigger svg {
    color: var(--wa-button-white) !important;
}

.wa-button-trigger svg path {
    fill: currentColor !important;
}

.wa-button-trigger.wa-button-hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

.wa-button-trigger svg {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* Tooltip */
.wa-button-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--wa-button-text-dark);
    color: var(--wa-button-white);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.wa-button-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid var(--wa-button-text-dark);
}

.wa-button-trigger:hover .wa-button-tooltip {
    opacity: 1;
}

/* Chat Window */
.wa-button-chat-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 350px;
    max-height: 500px;
    background-color: var(--wa-button-white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    transform-origin: bottom right;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

/* Chat Header */
.wa-button-chat-header {
    background-color: var(--wa-button-header-bg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.wa-button-widget[data-theme="dunkel"] .wa-button-chat-header {
    background-color: var(--wa-button-dark-green);
}

.wa-button-chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background-color: rgba(255, 255, 255, 0.2);
}

.wa-button-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-button-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-button-white);
}

.wa-button-avatar-placeholder svg {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: block !important;
    flex-shrink: 0 !important;
}

.wa-button-chat-info {
    flex: 1;
    color: var(--wa-button-white);
}

.wa-button-chat-name {
    font-size: 16px;
    font-weight: 600;
    line-height: normal;
}

.wa-button-chat-status {
    font-size: 13px;
    line-height: normal;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.wa-button-status-indicator {
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.wa-button-chat-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--wa-button-white);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.wa-button-chat-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.wa-button-chat-close svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* Chat Body */
.wa-button-chat-body {
    background-color: var(--wa-button-chat-bg);
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(255, 255, 255, 0.03) 10px,
            rgba(255, 255, 255, 0.03) 20px
        );
}

.wa-button-widget[data-theme="dunkel"] .wa-button-chat-body {
    background-color: #0d1418;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(255, 255, 255, 0.01) 10px,
            rgba(255, 255, 255, 0.01) 20px
        );
}

.wa-button-message {
    background-color: var(--wa-button-white);
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 85%;
}

.wa-button-widget[data-theme="dunkel"] .wa-button-message {
    background-color: #1f2c33;
    color: #e9edef;
}

.wa-button-message::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--wa-button-white);
}

.wa-button-widget[data-theme="dunkel"] .wa-button-message::before {
    border-right-color: #1f2c33;
}

.wa-button-message-content {
    font-size: 14px;
    line-height: 1.5;
    color: var(--wa-button-text-dark);
    margin-bottom: 4px;
}

/* Typewriter Cursor */
.wa-button-message-content.wa-button-typing::after {
    content: '|';
    animation: wa-button-blink 0.7s infinite;
    margin-left: 2px;
}

@keyframes wa-button-blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

.wa-button-widget[data-theme="dunkel"] .wa-button-message-content {
    color: #e9edef;
}

.wa-button-message-time {
    font-size: 11px;
    color: #667781;
    text-align: right;
}

.wa-button-widget[data-theme="dunkel"] .wa-button-message-time {
    color: #8696a0;
}

/* Chat Footer */
.wa-button-chat-footer {
    padding: 16px;
    background-color: var(--wa-button-white);
    border-top: 1px solid #e9edef;
}

.wa-button-widget[data-theme="dunkel"] .wa-button-chat-footer {
    background-color: #1f2c33;
    border-top-color: #2a3942;
}

.wa-button-start-chat {
    width: 100%;
    padding: 12px 24px;
    background-color: var(--wa-button-green);
    color: var(--wa-button-white);
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.wa-button-widget[data-theme="dunkel"] .wa-button-start-chat {
    background-color: var(--wa-button-dark-green);
}

.wa-button-start-chat:hover,
.wa-button-start-chat:focus,
.wa-button-start-chat:active {
    background-color: #1fbd5a;
}

.wa-button-start-chat svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    display: block !important;
    flex-shrink: 0 !important;
    color: var(--wa-button-white) !important;
}

.wa-button-start-chat svg path {
    fill: currentColor !important;
}

.wa-button-start-chat,
.wa-button-start-chat:hover,
.wa-button-start-chat:focus,
.wa-button-start-chat:active {
    color: var(--wa-button-white) !important;
}

.wa-button-widget[data-theme="dunkel"] .wa-button-start-chat,
.wa-button-widget[data-theme="dunkel"] .wa-button-start-chat:hover,
.wa-button-widget[data-theme="dunkel"] .wa-button-start-chat:focus,
.wa-button-widget[data-theme="dunkel"] .wa-button-start-chat:active {
    color: var(--wa-button-white) !important;
    background-color: #0a7c68;
}

/* Responsive */
@media (max-width: 768px) {
    .wa-button-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .wa-button-trigger {
        width: 56px;
        height: 56px;
    }
    
    .wa-button-trigger svg {
        width: 28px;
        height: 28px;
    }
    
    .wa-button-chat-window {
        width: calc(100vw - 30px);
        max-width: 350px;
    }
    
    .wa-button-tooltip {
        display: none;
    }
}

@media (max-width: 480px) {
    .wa-button-chat-window {
        width: 100vw;
        max-width: none;
        height: 35vh;
        max-height: 600px;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 12px 12px 0 0;
        position: fixed;
    }
    
    .wa-button-chat-window.wa-button-chat-open {
        transform: scale(1) translateY(0);
    }
    
    .wa-button-chat-body {
        flex: 1;
    }
}