/* Chatwoot (opcional): acima do mapa */
.woot-widget-holder {
    z-index: 10060 !important;
}

/*
 * Atendente iGo — layout alinhado ao app (modais claros, azul #003580 / #1a73e8).
 * Melhores práticas: autoatendimento primeiro; contraste AA; scroll visível.
 */
.igo-att-root {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    top: calc(var(--header-height, 64px) + 8px);
    bottom: auto;
    z-index: 10050;
    font-family: Roboto, system-ui, sans-serif;
    /* Paleta clara = mesmo contraste dos menus / conta do mapa */
    --att-bg: #ffffff;
    --att-bg2: #f1f3f4;
    --att-bg3: #e8eaed;
    --att-border: #dadce0;
    --att-text: #202124;
    --att-muted: #5f6368;
    --att-accent: #1a73e8;
    --att-brand: #003580;
    --att-accent2: #174ea6;
    --att-ok: #137333;
    --att-warn: #b06000;
    --att-bot-bg: #f1f3f4;
    --att-user-bg: #1a73e8;
    --att-scroll: #9aa0a6;
    --att-scroll-hover: #5f6368;
}

/* Tema escuro do app */
html[data-theme="dark"] .igo-att-root,
body.dark-mode .igo-att-root {
    --att-bg: #1e2128;
    --att-bg2: #2a2f38;
    --att-bg3: #343a46;
    --att-border: rgba(255, 255, 255, 0.14);
    --att-text: #e8eaed;
    --att-muted: #9aa0a6;
    --att-bot-bg: #2a2f38;
    --att-user-bg: #1a73e8;
    --att-scroll: rgba(255, 255, 255, 0.35);
    --att-scroll-hover: rgba(255, 255, 255, 0.55);
}

.igo-att-fab {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, #1a73e8, #003580);
    color: #fff;
    box-shadow: 0 4px 18px rgba(0, 53, 128, 0.4);
    display: grid;
    place-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.igo-att-fab:hover {
    transform: scale(1.05);
}

.igo-att-fab svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.igo-att-fab-badge,
.igo-att-bell {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ea4335;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    display: none;
}

.igo-att-fab-badge.show,
.igo-att-bell.show {
    display: block;
}

.igo-att-bell {
    left: -6px;
    right: auto;
    top: -6px;
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0;
    line-height: 26px;
    background: #fbbc04;
    color: #202124;
    animation: igo-att-pulse 1.6s ease-in-out infinite;
}

.igo-att-bell svg {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
}

@keyframes igo-att-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.igo-att-panel {
    position: absolute;
    right: 0;
    top: 48px;
    bottom: auto;
    width: min(360px, calc(100vw - 24px));
    height: min(420px, calc(100vh - var(--header-height, 64px) - 88px));
    max-height: min(420px, calc(100vh - var(--header-height, 64px) - 88px));
    background: var(--att-bg);
    color: var(--att-text);
    border: 1px solid var(--att-border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 53, 128, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.96);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    pointer-events: none;
}

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

.igo-att-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 10px 12px 14px;
    background: linear-gradient(135deg, #003580, #1a73e8);
    color: #fff;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.igo-att-head:active {
    cursor: grabbing;
}

.igo-att-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
    font-size: 18px;
    flex-shrink: 0;
}

.igo-att-head-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.igo-att-head-text strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.igo-att-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34a853;
    box-shadow: 0 0 0 2px rgba(52, 168, 83, 0.35);
    flex-shrink: 0;
}

.igo-att-online-dot.busy {
    background: #fbbc04;
    box-shadow: 0 0 0 2px rgba(251, 188, 4, 0.35);
}

.igo-att-head-text > span {
    display: block;
    font-size: 0.72rem;
    opacity: 0.92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.igo-att-head-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
    touch-action: manipulation;
}

.igo-att-head-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.igo-att-head-btn svg {
    display: block;
    margin: 0 auto;
}

/* Mensagens: área principal com scroll bem visível (estilo WhatsApp/Crisp) */
.igo-att-messages {
    flex: 1 1 auto;
    min-height: 72px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 14px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(26, 115, 232, 0.06), transparent 55%),
        var(--att-bg);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--att-scroll) var(--att-bg2);
}

.igo-att-messages::-webkit-scrollbar,
.igo-att-options::-webkit-scrollbar {
    width: 8px;
}

.igo-att-messages::-webkit-scrollbar-track,
.igo-att-options::-webkit-scrollbar-track {
    background: var(--att-bg2);
    border-radius: 8px;
}

.igo-att-messages::-webkit-scrollbar-thumb,
.igo-att-options::-webkit-scrollbar-thumb {
    background: var(--att-scroll);
    border-radius: 8px;
    border: 2px solid var(--att-bg2);
    min-height: 32px;
}

.igo-att-messages::-webkit-scrollbar-thumb:hover,
.igo-att-options::-webkit-scrollbar-thumb:hover {
    background: var(--att-scroll-hover);
}

.igo-att-bubble {
    position: relative;
    max-width: 88%;
    padding: 8px 12px 6px;
    border-radius: 16px;
    font-size: 0.84rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    animation: igo-att-in 0.22s ease-out;
    margin-bottom: 6px;
}

@keyframes igo-att-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.igo-att-bubble.bot {
    align-self: flex-start;
    background: var(--att-bot-bg);
    color: var(--att-text);
    border: 1px solid var(--att-border);
    border-bottom-left-radius: 4px;
}

.igo-att-bubble.user {
    align-self: flex-end;
    background: var(--att-user-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.igo-att-bubble.human {
    align-self: flex-start;
    background: #e6f4ea;
    border: 1px solid #ceead6;
    color: #137333;
    border-bottom-left-radius: 4px;
}

/* Agrupamento estilo WhatsApp: bolhas do mesmo lado coladas */
.igo-att-bubble.igo-att-cont {
    margin-bottom: 2px;
    margin-top: 0;
}

.igo-att-bubble.bot.igo-att-cont,
.igo-att-bubble.human.igo-att-cont {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.igo-att-bubble.user.igo-att-cont {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

.igo-att-bubble.bot.igo-att-last,
.igo-att-bubble.human.igo-att-last {
    border-bottom-left-radius: 4px;
    margin-bottom: 10px;
}

.igo-att-bubble.user.igo-att-last {
    border-bottom-right-radius: 4px;
    margin-bottom: 10px;
}

.igo-att-bubble-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.62rem;
    line-height: 1;
    opacity: 0.72;
    user-select: none;
}

.igo-att-bubble.user .igo-att-bubble-meta {
    color: rgba(255, 255, 255, 0.85);
}

.igo-att-bubble.bot .igo-att-bubble-meta,
.igo-att-bubble.human .igo-att-bubble-meta {
    color: var(--att-muted);
}

html[data-theme="dark"] .igo-att-bubble.human,
body.dark-mode .igo-att-bubble.human {
    background: #2e3b2e;
    border-color: rgba(52, 168, 83, 0.35);
    color: #81c995;
}

.igo-att-bubble.human::before {
    content: 'Equipe iGo';
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--att-ok);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.igo-att-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 10px 12px;
    background: var(--att-bot-bg);
    border: 1px solid var(--att-border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.igo-att-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--att-muted);
    animation: igo-att-dot 1.2s ease-in-out infinite;
}

.igo-att-typing span:nth-child(2) { animation-delay: 0.15s; }
.igo-att-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes igo-att-dot {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.igo-att-hint {
    font-size: 0.7rem;
    color: var(--att-muted);
    margin: 0 0 4px;
    line-height: 1.25;
}

.igo-att-hint-warn {
    color: var(--att-warn);
    font-weight: 600;
}

.igo-att-privacy {
    margin: 6px 0 0;
    font-size: 0.65rem;
    color: var(--att-muted);
    text-align: center;
}

/* Opções: altura do conteúdo; scroll só se passar do teto */
.igo-att-options {
    min-height: 0;
    max-height: 42%;
    flex: 0 0 auto;
    padding: 8px 10px 8px;
    border-top: 1px solid var(--att-border);
    background: var(--att-bg2);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--att-scroll) var(--att-bg3);
}

.igo-att-opt-list {
    max-height: none;
    overflow: visible;
}

.igo-att-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--att-border);
    background: var(--att-bg);
    flex-shrink: 0;
}

.igo-att-footer input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--att-border);
    background: #fff;
    color: var(--att-text);
    border-radius: 22px;
    padding: 11px 16px;
    font-size: 0.86rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

html[data-theme="dark"] .igo-att-footer input,
body.dark-mode .igo-att-footer input {
    background: var(--att-bg2);
}

.igo-att-footer input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.22);
}

.igo-att-footer input::placeholder {
    color: var(--att-muted);
}

.igo-att-live-go {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    padding: 0;
    background: #003580;
    color: #fff;
    font-size: 0;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    transition: transform 0.15s, background 0.15s;
}

.igo-att-live-go svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.igo-att-live-go:hover {
    background: #1a73e8;
    transform: scale(1.05);
}

.igo-att-live-go:active {
    transform: scale(0.96);
}

.igo-att-chip {
    border: 1px solid #1a73e8;
    background: #fff;
    color: #1a73e8;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    transition: transform 0.12s, background 0.15s;
}

html[data-theme="dark"] .igo-att-chip,
body.dark-mode .igo-att-chip {
    background: transparent;
    color: #8ab4f8;
    border-color: #8ab4f8;
}

.igo-att-chip:hover {
    background: #e8f0fe;
}

.igo-att-chip:active {
    transform: scale(0.96);
}

.igo-att-search,
.igo-att-opt,
.igo-att-chip,
.igo-att-resolve button,
.igo-att-send-row button,
.igo-att-nav button {
    font-family: inherit;
    cursor: pointer;
}

.igo-att-opt {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--att-border);
    background: #fff;
    color: var(--att-text);
    border-radius: 10px;
    padding: 9px 11px;
    margin-bottom: 6px;
    font-size: 0.82rem;
    line-height: 1.35;
    transition: border-color 0.15s, background 0.15s;
}

html[data-theme="dark"] .igo-att-opt,
body.dark-mode .igo-att-opt {
    background: var(--att-bg3);
}

.igo-att-opt:hover {
    border-color: #1a73e8;
    background: #e8f0fe;
}

html[data-theme="dark"] .igo-att-opt:hover,
body.dark-mode .igo-att-opt:hover {
    background: rgba(26, 115, 232, 0.18);
}

.igo-att-opt small {
    display: block;
    color: var(--att-muted);
    font-size: 0.7rem;
    margin-top: 2px;
}

.igo-att-opt-human {
    border-color: #ceead6;
    color: #137333;
    background: #e6f4ea;
    font-weight: 600;
}

.igo-att-opt-new {
    border-color: rgba(26, 115, 232, 0.45);
    margin-bottom: 10px;
}

.igo-att-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.igo-att-followups {
    margin-top: 8px;
}

.igo-att-resolve {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.igo-att-resolve button {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 9px 8px;
    font-size: 0.78rem;
    font-weight: 600;
}

.igo-att-resolve .yes {
    background: #e6f4ea;
    color: #137333;
}

.igo-att-resolve .partial {
    background: #fef7e0;
    color: #b06000;
}

.igo-att-resolve .no {
    background: #fce8e6;
    color: #c5221f;
}

.igo-att-nav {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.igo-att-nav button {
    flex: 1;
    border: 1px solid var(--att-border);
    background: #fff;
    color: var(--att-muted);
    border-radius: 8px;
    padding: 5px;
    font-size: 0.7rem;
}

html[data-theme="dark"] .igo-att-nav button,
body.dark-mode .igo-att-nav button {
    background: var(--att-bg3);
}

.igo-att-nav button:hover {
    border-color: #1a73e8;
    color: #1a73e8;
}

.igo-att-hist-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--att-border);
    background: #fff;
    color: var(--att-text);
    border-radius: 10px;
    padding: 9px 11px;
    margin-bottom: 6px;
    cursor: pointer;
    font-family: inherit;
}

.igo-att-hist-item:hover,
.igo-att-hist-item.current {
    border-color: #1a73e8;
    background: #e8f0fe;
}

.igo-att-hist-when {
    display: block;
    font-size: 0.68rem;
    color: var(--att-muted);
    margin-bottom: 2px;
}

.igo-att-hist-item strong {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.35;
}

.igo-att-hist-item small {
    display: block;
    color: #1a73e8;
    font-size: 0.7rem;
    margin-top: 3px;
}

.igo-att-compose {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.igo-att-compose.show {
    display: flex;
}

.igo-att-compose textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
    border: 1px solid var(--att-border);
    background: #fff;
    color: var(--att-text);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    box-sizing: border-box;
}

.igo-att-send-row {
    display: flex;
    gap: 6px;
}

.igo-att-send-row button {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 9px;
    font-size: 0.78rem;
    font-weight: 600;
}

.igo-att-send-row .primary {
    background: #003580;
    color: #fff;
}

.igo-att-send-row .ghost {
    background: transparent;
    color: var(--att-muted);
    border: 1px solid var(--att-border);
}

.igo-att-toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%) translateY(12px);
    background: #202124;
    color: #fff;
    border: 1px solid rgba(251, 188, 4, 0.5);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.82rem;
    z-index: 10060;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    max-width: min(320px, calc(100vw - 32px));
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.igo-att-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .igo-att-root {
        top: calc(var(--header-height, 52px) + 6px);
        right: max(8px, env(safe-area-inset-right));
    }
    .igo-att-panel {
        position: fixed;
        max-width: calc(100vw - 16px);
        display: flex;
        flex-direction: column;
        border-radius: 12px;
    }
    .igo-att-head {
        padding: 8px 8px 8px 10px;
    }
}
