/*!
 * STAEMMIG WhatsApp Chat – Frontend-Styles
 * Scope: alles unter .swc-widget. Keine globalen Regeln.
 * Kritische Shape-Props des Launchers mit !important gesichert, damit
 * Theme-Defaults fuer <button> den runden Button nicht verzerren.
 */

.swc-widget {
    /* Theme-Tokens */
    --swc-z: 2147482000;
    --swc-bg: #ffffff;
    --swc-surface: #f4f5f6;
    --swc-text: #111827;
    --swc-muted: #6b7280;
    --swc-brand: #009966;
    --swc-brand-dark: #007a51;
    --swc-header-start: #009966;
    --swc-header-end: #007a51;
    --swc-offline: #9ca3af;
    --swc-shadow: 0 20px 50px -15px rgba(15, 23, 42, .25), 0 8px 20px -10px rgba(15, 23, 42, .15);
    --swc-radius: 18px;
    --swc-gap: 22px;
    --swc-launcher-size: 64px;
    --swc-launcher-icon-size: 44px;

    position: fixed;
    right: var(--swc-gap);
    bottom: var(--swc-gap);
    z-index: var(--swc-z);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    color: var(--swc-text);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    pointer-events: none;
}

.swc-widget *,
.swc-widget *::before,
.swc-widget *::after {
    box-sizing: border-box;
}

/* ----------------------------- Launcher ----------------------------- */

.swc-widget .swc-launcher {
    /* Reset vs. Theme-Button-Defaults */
    -webkit-appearance: none !important;
    appearance: none !important;
    font: inherit;
    color: #ffffff;
    text-transform: none;
    letter-spacing: normal;
    text-decoration: none !important;
    text-shadow: none !important;
    cursor: pointer;
    pointer-events: auto;

    /* Form & Groesse, hart gesichert */
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--swc-launcher-size) !important;
    height: var(--swc-launcher-size) !important;
    min-width: var(--swc-launcher-size) !important;
    min-height: var(--swc-launcher-size) !important;
    aspect-ratio: 1 / 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    line-height: 1 !important;

    /* Optik */
    background: radial-gradient(circle at 30% 25%, #1ab97e 0%, #009966 45%, #007a51 100%);
    box-shadow:
        0 14px 28px -10px rgba(18, 140, 126, .55),
        0 6px 14px -6px rgba(0, 0, 0, .28),
        inset 0 1px 0 rgba(255, 255, 255, .18);
    transition: transform 220ms cubic-bezier(.2, .8, .2, 1),
                box-shadow 220ms ease,
                filter 220ms ease;
    overflow: visible;
}

.swc-widget .swc-launcher:hover,
.swc-widget .swc-launcher:focus-visible {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 18px 36px -10px rgba(18, 140, 126, .62),
        0 8px 18px -6px rgba(0, 0, 0, .3),
        inset 0 1px 0 rgba(255, 255, 255, .22);
    filter: saturate(1.05);
}

.swc-widget .swc-launcher:focus-visible {
    outline: 3px solid rgba(37, 211, 102, .45) !important;
    outline-offset: 4px !important;
}

.swc-widget .swc-launcher:active {
    transform: translateY(0) scale(.98);
    transition-duration: 120ms;
}

.swc-widget .swc-launcher__icon-wrap {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: var(--swc-launcher-icon-size) !important;
    height: var(--swc-launcher-icon-size) !important;
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
    line-height: 0;
    pointer-events: none;
    padding: 0 !important;
    margin: 0 !important;
}

.swc-widget .swc-launcher__icon {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #ffffff;
    fill: currentColor;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18));
    pointer-events: none;
}

/* Tooltip */
.swc-launcher__tooltip {
    position: absolute;
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    background: #111827;
    color: #ffffff;
    padding: 9px 14px;
    font-size: 13px;
    line-height: 1.2;
    font-weight: 500;
    border-radius: 999px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
    box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .28);
}

.swc-launcher__tooltip::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #111827;
}

.swc-widget .swc-launcher:hover .swc-launcher__tooltip,
.swc-widget .swc-launcher:focus-visible .swc-launcher__tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ------------------------------ Panel ------------------------------- */

.swc-chat {
    pointer-events: auto;
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    width: min(360px, calc(100vw - 32px));
    background: var(--swc-bg);
    border-radius: var(--swc-radius);
    box-shadow: var(--swc-shadow);
    overflow: hidden;
    transform-origin: bottom right;
    transform: translateY(12px) scale(.96);
    opacity: 0;
    visibility: hidden;
    transition: transform 220ms cubic-bezier(.2, .8, .2, 1),
                opacity 200ms ease,
                visibility 0s linear 240ms;
}

.swc-widget.is-open .swc-chat {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    transition: transform 240ms cubic-bezier(.2, .8, .2, 1),
                opacity 200ms ease,
                visibility 0s;
}

.swc-chat[hidden] {
    display: block;
}

.swc-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--swc-header-start) 0%, var(--swc-header-end) 100%);
    color: #ffffff;
}

.swc-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, .12);
    flex: 0 0 auto;
}

.swc-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.swc-avatar__fallback {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
    text-transform: uppercase;
}

.swc-avatar__status {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--swc-brand);
    border: 2px solid var(--swc-header-end);
}

.swc-chat.is-offline .swc-avatar__status {
    background: var(--swc-offline);
}

.swc-chat__meta {
    flex: 1 1 auto;
    min-width: 0;
}

.swc-chat__name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    color: #ffffff;
    letter-spacing: .2px;
}

.swc-chat__status {
    font-size: 12px;
    opacity: .85;
    line-height: 1.2;
    margin-top: 3px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #ffffff;
}

.swc-chat__status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--swc-brand);
    box-shadow: 0 0 0 2px rgba(37, 211, 102, .25);
}

.swc-chat.is-offline .swc-chat__status::before {
    background: var(--swc-offline);
    box-shadow: 0 0 0 2px rgba(156, 163, 175, .3);
}

.swc-chat__close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 180ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.swc-chat__close:hover,
.swc-chat__close:focus-visible {
    background: rgba(255, 255, 255, .15);
    outline: none;
}

.swc-chat__close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .6);
    outline-offset: 2px;
}

.swc-chat__close svg {
    width: 16px;
    height: 16px;
}

/* ------------------------------ Body -------------------------------- */

.swc-chat__body {
    padding: 18px 16px 14px;
    background: var(--swc-surface);
    min-height: 110px;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(37, 211, 102, .05), transparent 40%),
        radial-gradient(circle at 80% 90%, rgba(18, 140, 126, .06), transparent 40%);
}

.swc-bubble {
    background: #ffffff;
    padding: 10px 12px 6px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
    max-width: 88%;
    font-size: 14px;
    line-height: 1.5;
    color: var(--swc-text);
    position: relative;
    animation: swc-bubble-in 320ms cubic-bezier(.2, .8, .2, 1);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.swc-bubble p {
    margin: 0;
    padding: 0;
}

.swc-bubble__time {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--swc-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.swc-bubble--typing {
    padding: 12px 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 52px;
}

.swc-bubble--typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: swc-typing 1.2s infinite;
}

.swc-bubble--typing span:nth-child(2) { animation-delay: .15s; }
.swc-bubble--typing span:nth-child(3) { animation-delay: .30s; }

.swc-typing[hidden],
.swc-message[hidden] {
    display: none;
}

/* ----------------------------- Footer ------------------------------- */

.swc-chat__footer {
    padding: 12px 14px 14px;
    background: var(--swc-bg);
}

.swc-cta {
    display: inline-flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #ffffff !important;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: .2px;
    text-decoration: none !important;
    border-radius: 999px;
    box-shadow: 0 6px 16px -4px rgba(18, 140, 126, .45);
    transition: transform 200ms cubic-bezier(.2, .8, .2, 1),
                box-shadow 200ms ease,
                filter 200ms ease;
    line-height: 1.2;
}

.swc-cta:hover,
.swc-cta:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px -4px rgba(18, 140, 126, .55);
    filter: brightness(1.05);
    outline: none;
}

.swc-cta:focus-visible {
    outline: 3px solid rgba(37, 211, 102, .4);
    outline-offset: 3px;
}

.swc-cta__icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

/* --------------------------- Animations ---------------------------- */

@keyframes swc-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

@keyframes swc-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------- Responsive ---------------------------- */

@media (max-width: 480px) {
    .swc-widget {
        --swc-gap: 16px;
        --swc-launcher-size: 58px;
        --swc-launcher-icon-size: 40px;
    }
    .swc-chat {
        width: calc(100vw - 28px);
    }
    .swc-launcher__tooltip {
        display: none;
    }
}

/* ------------------------ Reduced motion --------------------------- */

@media (prefers-reduced-motion: reduce) {
    .swc-widget .swc-launcher,
    .swc-chat,
    .swc-cta,
    .swc-bubble {
        transition: none !important;
        animation: none !important;
    }
    .swc-bubble--typing span {
        animation: none !important;
        opacity: .7;
    }
}
