/* CRM ChatSite Widget CSS */
.chatsite-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Float Button */
.chatsite-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary, #1d4ed8);
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chatsite-button:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.35);
}

.chatsite-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chatsite-button .close-icon {
    display: none;
}

.chatsite-widget-container.open .chatsite-button .chat-icon {
    display: none;
}

.chatsite-widget-container.open .chatsite-button .close-icon {
    display: block;
}

/* Badge de notificação */
.chatsite-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Chat Window */
.chatsite-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: var(--bg-surface);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatsite-widget-container.open .chatsite-window {
    display: flex;
}

/* Header */
.chatsite-header {
    padding: 0.9rem 1rem;
    background: var(--chat-primary, #1d4ed8);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
}

.chatsite-header-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.chatsite-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatsite-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.chatsite-header-text { min-width: 0; }

.chatsite-header-info h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.chatsite-header-info p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

.chatsite-header-menu {
    position: relative;
    flex-shrink: 0;
}

.chatsite-menu-btn {
    background: transparent;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.15s;
}

.chatsite-menu-btn:hover { background: rgba(255, 255, 255, 0.18); }
.chatsite-menu-btn svg { width: 18px; height: 18px; fill: #fff; }

/* Dropdown do menu (⋮) */
.chatsite-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
    padding: 0.3rem;
    display: none;
    z-index: 10;
}

.chatsite-menu.open { display: block; }

.chatsite-menu-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    background: transparent;
    border: none;
    border-radius: 7px;
    font-size: 0.84rem;
    font-weight: 500;
    color: #0f172a;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.chatsite-menu-item:hover { background: rgba(15, 23, 42, 0.05); }
.chatsite-menu-item svg { width: 15px; height: 15px; fill: currentColor; flex-shrink: 0; opacity: 0.7; }
.chatsite-menu-item.is-danger { color: #dc2626; }
.chatsite-menu-item.is-danger:hover { background: rgba(220, 38, 38, 0.08); }

/* Messages Area */
.chatsite-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--bg-surface-2);
}

.chatsite-message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
}

.chatsite-message.visitor {
    background: var(--chat-primary, #1d4ed8);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatsite-message.agent {
    background: var(--bg-surface);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatsite-message.system {
    background: #fef3c7;
    color: #92400e;
    align-self: center;
    font-size: 0.85rem;
    text-align: center;
    max-width: 90%;
}

.chatsite-message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
}

/* Input Area */
.chatsite-input-area {
    padding: 1rem;
    background: var(--bg-surface);
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
}

.chatsite-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.chatsite-input:focus {
    border-color: var(--chat-primary, #1d4ed8);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.10);
}

.chatsite-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary, #1d4ed8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s;
}

.chatsite-send-btn:hover {
    filter: brightness(1.1);
}

.chatsite-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Pre-chat Form */
.chatsite-prechat {
    padding: 1.35rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
}

.chatsite-prechat h4 {
    margin: 0 0 0.35rem;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.chatsite-prechat p {
    margin: 0 0 1.1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Campos com rótulo — mais claro que só placeholder */
.chatsite-field {
    display: block;
    margin-bottom: 0.7rem;
}

.chatsite-field > span {
    display: block;
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.28rem;
}

.chatsite-prechat input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chatsite-prechat input:focus {
    outline: none;
    border-color: var(--chat-primary, #1d4ed8);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.chatsite-identified {
    background: var(--bg-surface-2, #f8fafc);
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.85rem;
    line-height: 1.35;
}

.chatsite-identified strong { display: block; font-size: 0.88rem; color: var(--text-primary); }
.chatsite-identified small { color: var(--text-muted); font-size: 0.78rem; }

.chatsite-hint {
    margin: 0.85rem 0 0 !important;
    font-size: 0.75rem !important;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.85;
}

.chatsite-prechat button {
    width: 100%;
    padding: 0.75rem;
    background: var(--chat-primary, #1d4ed8);
    color: white;
    border: none;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.chatsite-prechat button:hover {
    filter: brightness(1.1);
}

/* Status indicator */
.chatsite-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chatsite-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
}

.chatsite-status-dot.connected {
    background: #22c55e;
}

.chatsite-status-dot.connecting {
    background: #f59e0b;
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Typing indicator */
.chatsite-typing {
    display: flex;
    gap: 4px;
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border-radius: 16px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatsite-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chatsite-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatsite-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* Mobile responsivity */
@media (max-width: 480px) {
    .chatsite-window {
        width: 100vw;
        height: calc(100vh - 100px);
        bottom: 80px;
        right: -20px;
        border-radius: 16px 16px 0 0;
    }
}