/* aba-webchat v0.9.3 — widget styles (source of truth: docs/WebChat/) */
#aba-webchat {
    --aba-primary: #075e54;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #111827;
}

.aba-chat-shell {
    position: fixed;
    z-index: 999999;
}

.aba-chat-widget-shell {
    bottom: 0;
    right: 18px;
    width: min(420px, calc(100vw - 36px));
}

.aba-chat-fullscreen {
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

#aba-chat-button {
    display: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background-color: var(--aba-primary);
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#aba-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.aba-chat-launcher-icon {
    position: relative;
    width: 24px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 7px;
}

.aba-chat-launcher-icon::after {
    content: "";
    position: absolute;
    right: 2px;
    bottom: -5px;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: skewY(35deg);
}

#aba-chat-window {
    width: 100%;
    min-height: 0;
    height: 600px;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    background: #efeae2;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
}

.aba-chat-widget-shell #aba-chat-window {
    width: 100%;
    height: 50vh;
    min-height: 360px;
    max-height: calc(100vh - 20px);
    border-radius: 14px 14px 0 0;
    transition: height 280ms ease, transform 280ms ease, opacity 180ms ease;
}

.aba-chat-widget-shell.aba-chat-state-icon #aba-chat-window {
    display: none;
}

/* Icon state: the shell must shrink to the launcher, never keep the panel box. */
.aba-chat-widget-shell.aba-chat-state-icon {
    width: auto;
}

/* defect 1 (v0.9.1): the launcher is the ONLY way back from `icon`, so it must
   be visible at every width — not just inside the mobile media query. */
.aba-chat-widget-shell.aba-chat-state-icon #aba-chat-button {
    display: flex;
}

.aba-chat-widget-shell.aba-chat-state-half #aba-chat-window {
    height: 50vh;
    max-height: calc(100vh - 20px);
}

.aba-chat-widget-shell.aba-chat-state-full #aba-chat-window {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    height: 100%;
    max-height: none;
    border-radius: 0;
}

.aba-chat-fullscreen #aba-chat-window {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
}

.aba-chat-header {
    padding: 12px 16px;
    background-color: var(--aba-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


.aba-chat-title {
    font-weight: 600;
    font-size: 16px;
}

.aba-chat-status {
    font-size: 12px;
    opacity: 0.85;
}

.aba-chat-state-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.aba-chat-state-controls button {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.aba-chat-state-controls button:hover { opacity: 1; }
.aba-chat-state-controls button[hidden] { display: none !important; }

#aba-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    /* NOTE: never use `justify-content: flex-end` here. With overflowing
       content Chrome/Safari make the top overflow unreachable — the list
       looks frozen. A leading auto-margin spacer keeps messages pinned to
       the bottom while the whole range stays scrollable (v0.8.2 fix). */
    justify-content: flex-start;
    padding: 12px;
    gap: 8px;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

#aba-chat-messages::before {
    content: "";
    margin-top: auto;
}

.aba-message {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.aba-message-body {
    white-space: pre-wrap;
}

/* Abá-style stamp: HH:mm today, DD/MM HH:mm from yesterday back. */
.aba-message-time {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    line-height: 1;
    opacity: 0.55;
    text-align: right;
}


.aba-message-user {
    align-self: flex-end;
    background-color: #dcf8c6;
    color: #111827;
    border-top-right-radius: 0;
}

.aba-message-bot {
    align-self: flex-start;
    background-color: #ffffff;
    color: #111827;
    border-top-left-radius: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.aba-media-image {
    max-width: 100%;
    border-radius: 6px;
    display: block;
    cursor: pointer;
}

.aba-media-video {
    width: 100%;
    max-width: 260px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    background: #000;
}

.aba-audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.aba-audio-player audio {
    width: 100%;
    height: 36px;
    outline: none;
}

.aba-system-message {
    align-self: center;
    background-color: rgba(254, 243, 199, 0.9);
    color: #92400e;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    text-align: center;
    max-width: 90%;
}

.aba-chat-input-area {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    min-width: 0;
    background-color: #f0f2f5;
    border-top: 1px solid #e5e7eb;
}

.aba-chat-tool-btn {
    background: transparent;
    border: none;
    color: #54656f;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.aba-chat-tool-btn:hover {
    background-color: #e4e6eb;
    color: #111827;
}

.aba-chat-tool-btn.aba-recording {
    color: #ef4444;
    animation: aba-pulse 1.2s infinite;
}

@keyframes aba-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

#aba-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 100px;
    background: #ffffff;
    font-family: inherit;
    line-height: 1.3;
}

#aba-chat-send {
    background-color: var(--aba-primary);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

#aba-chat-send:hover {
    background-color: #128c7e;
}

#aba-chat-send:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.aba-chat-hidden {
    display: none !important;
}

@media (max-width: 480px) {
    html.aba-chat-overlay-open,
    html.aba-chat-overlay-open body {
        overflow: hidden !important;
    }

    .aba-chat-widget-shell {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        width: auto;
    }

    .aba-chat-widget-shell #aba-chat-button {
        display: flex;
    }

    .aba-chat-button-copy {
        display: none;
    }

    .aba-chat-widget-shell.aba-chat-state-icon #aba-chat-window {
        display: none;
    }

    .aba-chat-widget-shell.aba-chat-state-icon #aba-chat-button {
        display: flex;
    }

    .aba-chat-widget-shell #aba-chat-window {
        width: 100vw;
        width: 100dvw;
        max-width: 100dvw;
        max-height: none;
        display: flex;
        flex-direction: column;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        opacity: 1;
        transform: none;
        overscroll-behavior: none;
    }

    .aba-chat-widget-shell.aba-chat-state-icon #aba-chat-window {
        display: none;
    }

    .aba-chat-widget-shell.aba-chat-state-full #aba-chat-window {
        top: 0;
        left: 0;
        right: auto;
        height: 100dvh;
        max-height: none;
        position: fixed;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aba-chat-widget-window,
    #aba-chat-button {
        transition: none;
    }
}
/* --- Emoji popover: navigable grid floating above the input bar (v0.7.0) --- */
.aba-chat-input-area { position: relative; }

.aba-emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 2px;
    padding: 8px;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.18);
    z-index: 20;
}

.aba-emoji-option {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 6px 0;
    border-radius: 8px;
    transition: background 0.15s, transform 0.15s;
}

.aba-emoji-option:hover {
    background: rgba(7, 94, 84, 0.1);
    transform: scale(1.15);
}

/* --- Desktop live camera viewfinder (v0.7.0) --- */
.aba-camera-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.aba-camera-overlay video {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aba-camera-controls {
    position: absolute;
    bottom: 14px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.aba-camera-capture,
.aba-camera-cancel {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.aba-camera-cancel { background: rgba(0, 0, 0, 0.4); }

/* --- Mobile hard scroll-lock while the overlay is open (v0.7.0) --- */
html.aba-chat-overlay-open,
html.aba-chat-overlay-open body {
    overflow: hidden;
    overscroll-behavior: none;
}

/* v0.9.3 — a media bubble whose upload failed stays visible but muted. */
.aba-message-failed {
    opacity: 0.55;
    filter: grayscale(0.6);
}
