/* Chico Chat - Widget */
#chico-chat-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Bubble */
#cc-bubble {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cc-widget-color, #1a1a2e);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform .2s, box-shadow .2s;
}

#cc-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(0,0,0,.3);
}

#cc-bubble svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}

#cc-bubble .cc-unread {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e74c3c;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
}

#cc-bubble.has-unread .cc-unread {
    display: flex;
}

/* Window */
#cc-window {
    position: fixed;
    bottom: 90px;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    transform: scale(.95) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: all .25s cubic-bezier(.34,1.56,.64,1);
    /* Necessário para posicionamento absoluto dos filhos */
    position: fixed;
}#cc-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Position */
.cc-pos-right #cc-bubble,
.cc-pos-right #cc-window {
    right: 24px;
}

.cc-pos-left #cc-bubble,
.cc-pos-left #cc-window {
    left: 24px;
}

/* Header */
.cc-header {
    background: var(--cc-widget-color, #1a1a2e);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    height: 64px;
    box-sizing: border-box;
    position: relative;
    z-index: 3;
}

.cc-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 26px;
}

.cc-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cc-header-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.cc-header-status {
    font-size: 11px;
    opacity: .8;
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
}

.cc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2ecc71;
    display: inline-block;
}

.cc-status-dot.offline {
    background: #95a5a6;
}

.cc-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background .15s;
}

.cc-close-btn:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}

/* Messages — ocupa todo espaço disponível acima do input */
.cc-messages {
    position: absolute;
    top: 64px; /* altura do header */
    left: 0;
    right: 0;
    bottom: 115px; /* input 70px + handoff 45px = 115px */
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
}

.cc-messages::-webkit-scrollbar { width: 4px; }
.cc-messages::-webkit-scrollbar-track { background: transparent; }
.cc-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.cc-msg {
    max-width: 80%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    animation: cc-msg-in .2s ease;
}

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

.cc-msg.bot,
.cc-msg.agent {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.cc-msg.agent {
    border-left: 3px solid var(--cc-widget-color, #1a1a2e);
}

.cc-msg.user {
    align-self: flex-end;
    background: var(--cc-widget-color, #1a1a2e);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cc-typing {
    align-self: flex-start;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.cc-typing span {
    width: 7px;
    height: 7px;
    background: #bbb;
    border-radius: 50%;
    animation: cc-bounce 1.2s infinite;
}

.cc-typing span:nth-child(2) { animation-delay: .2s; }
.cc-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes cc-bounce {
    0%,60%,100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Input area */
.cc-input-area {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 44px; /* altura do handoff */
    border-top: 2px solid #e8e8e8;
    padding: 12px;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    z-index: 10;
}

.cc-input-area textarea {
    flex: 1;
    border: 2px solid var(--cc-widget-color, #1a1a2e);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    height: 44px;
    max-height: 100px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.4;
    overflow: hidden;
    box-shadow: 0 0 0 0 transparent;
}

.cc-input-area textarea:focus {
    border-color: var(--cc-widget-color, #1a1a2e);
    box-shadow: 0 0 0 3px rgba(26,26,46,0.1);
}

.cc-send-btn {
    width: 44px;
    height: 44px;
    background: var(--cc-widget-color, #1a1a2e);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}

.cc-send-btn:hover { opacity: .85; }
.cc-send-btn svg { width: 20px; height: 20px; fill: #fff; }

/* Handoff button — abaixo do input */
.cc-handoff-area {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 4px 12px 10px;
    background: #fff;
    text-align: center;
    z-index: 10;
}

.cc-handoff-btn {
    padding: 6px 14px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: color .15s;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cc-handoff-btn:hover {
    color: var(--cc-widget-color, #1a1a2e);
}

/* Email form */
.cc-email-form {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #eee;
}

.cc-email-form p {
    font-size: 13px;
    color: #555;
    margin: 0 0 10px;
}

.cc-email-form input,
.cc-email-form textarea {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 8px;
    outline: none;
}

.cc-email-form input:focus,
.cc-email-form textarea:focus {
    border-color: var(--cc-widget-color, #1a1a2e);
}

.cc-email-form textarea {
    resize: none;
    height: 60px;
}

.cc-email-form .cc-submit-email {
    width: 100%;
    padding: 9px;
    background: var(--cc-widget-color, #1a1a2e);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: opacity .15s;
}

.cc-email-form .cc-submit-email:hover { opacity: .85; }

.cc-email-cancel {
    background: none;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
    padding: 6px;
    text-align: center;
}

/* Mobile */
@media (max-width: 480px) {
    /* Fullscreen fixo — sem animação de tamanho */
    #cc-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        /* Deixa 64px no fundo para a barra de navegação do Android */
        bottom: 40px !important;
        width: 100vw !important;
        height: auto !important;
        border-radius: 0 !important;
        max-height: none !important;
        transform: none !important;
        transition: opacity .2s !important;
        overflow: hidden !important;
    }

    #cc-window.open {
        transform: none !important;
    }

    /* Bolinha sempre no canto inferior direito */
    .cc-pos-right #cc-bubble,
    .cc-pos-left #cc-bubble {
        bottom: 16px;
        right: 16px !important;
        left: auto !important;
    }

    .cc-messages {
        -webkit-overflow-scrolling: touch;
    }

    .cc-input-area {
        padding-bottom: max(env(safe-area-inset-bottom, 12px), 12px);
        padding-top: 12px;
    }

    .cc-input-area textarea {
        font-size: 16px !important;
        color: #1a1a2e !important;
        height: 52px !important;
        padding: 14px 16px !important;
    }
}

/* Links clicáveis dentro das mensagens */
.cc-msg a {
    pointer-events: auto !important;
    cursor: pointer !important;
    text-decoration: underline;
    color: #f0a500;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: inline-block;
}

.cc-msg.user a {
    color: #ffe082;
}

.cc-msg.agent a {
    color: #2980b9;
}

/* ── Mobile: texto maior e sem cinzas fracos ─────────────────── */
@media (max-width: 480px) {
    /* Mensagens */
    .cc-msg {
        font-size: 16px !important;
        line-height: 1.55 !important;
    }

    /* Status no header */
    .cc-header-status {
        font-size: 13px !important;
        color: rgba(255,255,255,0.9) !important;
    }

    /* Input */
    .cc-input-area textarea {
        font-size: 16px !important;  /* evita zoom automático no iOS */
        color: #1a1a2e !important;
    }

    /* Hora/data das mensagens */
    .cc-msg-time {
        font-size: 12px !important;
        color: #555 !important;
    }

    /* Botão falar com atendente — discreto no mobile também */
    .cc-handoff-btn {
        font-size: 13px !important;
        padding: 6px 14px !important;
        color: #888 !important;
    }

    /* Status offline/typing */
    #cc-status-text {
        color: rgba(255,255,255,0.9) !important;
        font-size: 13px !important;
    }

    /* Remove todos os cinzas fracos nas mensagens do bot */
    .cc-msg.bot {
        color: #222 !important;
    }

    .cc-msg.user {
        color: #fff !important;
    }

    /* Links dentro das mensagens */
    .cc-msg a {
        font-size: 16px !important;
        font-weight: 600 !important;
    }

    /* Email form */
    .cc-email-form p,
    .cc-email-form input,
    .cc-email-form textarea {
        font-size: 16px !important;
        color: #222 !important;
    }
}

/* Sem quebra de palavra nos links de ação */
.cc-msg a {
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    white-space: normal !important;
    .cc-input-area {
        bottom: max(env(safe-area-inset-bottom, 0px), 36px) !important;
        padding-bottom: max(env(safe-area-inset-bottom, 12px), 12px) !important;
        padding-top: 12px !important;
    }


}
.cc-header-disclaimer {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    font-style: italic;
    letter-spacing: 0.1px;
    line-height: 1;
    margin: 0;
}

/* ── Labels rápidos ──────────────────────────────────── */
.cc-quick-labels {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 8px;
}

.cc-quick-label-btn {
    background: #fff;
    border: 2px solid var(--cc-widget-color, #1a1a2e);
    border-radius: 10px;
    color: var(--cc-widget-color, #1a1a2e);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    text-align: left;
    transition: background .15s, color .15s;
    width: 100%;
}

.cc-quick-label-btn:hover {
    background: var(--cc-widget-color, #1a1a2e);
    color: #fff;
}

@media (max-width: 480px) {
    .cc-quick-label-btn {
        font-size: 15px !important;
        padding: 12px 16px !important;
    }
}
