/* Amparo — Widget de chat flutuante */
:root {
    --acw-blue-900: #002a66;
    --acw-blue-800: #004aad;
    --acw-blue-700: #0a5ec9;
    --acw-blue-500: #38b6ff;
    --acw-blue-100: #e8f5ff;
    --acw-blue-50: #f4faff;
    --acw-ink: #12253f;
    --acw-muted: #6a7d99;
}

#acw-root {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9500;
    font-family: "Quicksand", sans-serif;
}

#acw-root.acw-page-hidden {
    display: none !important;
    pointer-events: none;
}

#acw-root *,
#acw-root *::before,
#acw-root *::after {
    box-sizing: border-box;
}

#acw-root svg {
    display: block;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    max-width: 100%;
}

.acw-fab {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, var(--acw-blue-500), var(--acw-blue-800));
    box-shadow: 0 10px 26px rgba(0, 42, 102, 0.35);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.acw-fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 14px 30px rgba(0, 42, 102, 0.42);
}

.acw-fab svg {
    width: 26px !important;
    height: 26px !important;
}

.acw-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ff3b5c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(255, 59, 92, 0.4);
}

.acw-badge.acw-hidden {
    display: none;
}

.acw-panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 24, 60, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

/* Filhos com pointer-events:auto (views ativas) não podem “furar” o painel fechado */
.acw-panel:not(.acw-open),
.acw-panel:not(.acw-open) * {
    pointer-events: none !important;
}

.acw-panel.acw-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.acw-head {
    background: linear-gradient(120deg, var(--acw-blue-800), var(--acw-blue-700));
    color: #fff;
    padding: 14px 16px !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-height: 52px;
}

.acw-head-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.acw-head-title svg {
    width: 18px;
    height: 18px;
}

.acw-icon-btn {
    background: rgba(255, 255, 255, 0.16);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.acw-icon-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.acw-icon-btn.is-muted {
    opacity: 0.72;
    background: rgba(0, 0, 0, 0.18);
}

.acw-icon-btn svg {
    width: 16px !important;
    height: 16px !important;
}

.acw-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--acw-blue-50);
}

.acw-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.acw-view.acw-active {
    opacity: 1;
    pointer-events: auto;
}

/* Lista de conversas */
.acw-threads {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.acw-thread {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.acw-thread:hover {
    background: var(--acw-blue-100);
}

.acw-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--acw-blue-500), var(--acw-blue-800));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}

.acw-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.acw-thread-info {
    flex: 1;
    min-width: 0;
}

.acw-thread-name {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--acw-ink);
    display: flex;
    align-items: center;
    gap: 6px;
}

.acw-thread-preview {
    font-size: 12.5px;
    color: var(--acw-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.acw-thread-unread {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ff3b5c;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.acw-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--acw-muted);
    font-size: 13.5px;
}

.acw-empty svg {
    width: 40px !important;
    height: 40px !important;
    color: var(--acw-blue-500);
    margin: 0 auto 8px;
}

/* Thread aberta */
.acw-thread-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 74, 173, 0.1);
    background: #fff;
    flex-shrink: 0;
}

.acw-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--acw-blue-800);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.acw-back-btn:hover {
    background: var(--acw-blue-100);
}

.acw-back-btn svg {
    width: 18px !important;
    height: 18px !important;
}

.acw-thread-head-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--acw-ink);
}

.acw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.acw-msg {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.acw-msg-them {
    align-self: flex-start;
    background: #fff;
    color: var(--acw-ink);
    border: 1px solid rgba(0, 74, 173, 0.1);
    border-bottom-left-radius: 4px;
}

.acw-msg-me {
    align-self: flex-end;
    background: linear-gradient(120deg, var(--acw-blue-700), var(--acw-blue-800));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.acw-msg-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 3px;
    display: block;
}

.acw-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border-top: 1px solid rgba(0, 74, 173, 0.1);
    flex-shrink: 0;
}

.acw-composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid rgba(0, 74, 173, 0.18);
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 13.5px;
    max-height: 80px;
    min-height: 38px;
    outline: none;
    font-family: inherit;
    color: var(--acw-ink);
}

.acw-composer textarea:focus {
    border-color: var(--acw-blue-500);
}

.acw-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, var(--acw-blue-500), var(--acw-blue-800));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.12s ease;
}

.acw-send-btn:hover {
    transform: scale(1.06);
}

.acw-send-btn:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

.acw-send-btn svg {
    width: 17px !important;
    height: 17px !important;
}

.acw-loading {
    padding: 20px;
    text-align: center;
    color: var(--acw-muted);
    font-size: 13px;
}

.acw-new-search-wrap {
    padding: 10px 10px 4px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 74, 173, 0.08);
    flex-shrink: 0;
}

.acw-new-search {
    width: 100%;
    border: 1px solid rgba(0, 74, 173, 0.18);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--acw-ink);
    outline: none;
}

.acw-new-search:focus {
    border-color: var(--acw-blue-500);
}

@media (max-width: 640px) {
    #acw-root {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        left: auto;
        top: auto;
    }

    #acw-root.acw-is-open {
        inset: 0;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        pointer-events: none;
    }

    #acw-root.acw-is-open .acw-panel {
        pointer-events: auto;
    }

    .acw-fab {
        width: 54px;
        height: 54px;
    }

    #acw-root.acw-is-open .acw-fab {
        display: none;
    }

    .acw-panel {
        position: fixed;
        inset: 0;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-width: none;
        height: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        transform: translateY(8px);
    }

    .acw-panel.acw-open {
        transform: translateY(0);
    }

    .acw-head {
        padding: 12px 14px !important;
        padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
        min-height: 56px;
    }

    .acw-composer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .acw-thread-preview {
        max-width: none;
    }

    .acw-msg {
        max-width: 86%;
    }
}
