/* public/assets/css/chat-external-login.css — Chat Externo na Tela de Login */

#ext-chat-wrapper {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 999999;
    pointer-events: auto;
}

.ext-chat-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999999;
    background: linear-gradient(135deg, var(--color-primary, #0b3d91), #1d4ed8);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 0.85rem 1.4rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(11, 61, 145, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ext-chat-fab:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 30px rgba(11, 61, 145, 0.45);
}

.ext-chat-fab svg {
    width: 1.3rem;
    height: 1.3rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.ext-chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

/* Container Modal do Chat Externo */
.ext-chat-modal {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 520px;
    max-height: calc(100vh - 7rem);
    z-index: 99999;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ext-chat-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* A confirmação de encerramento deve ficar acima da janela do atendimento. */
.swal2-container {
    z-index: 1000001 !important;
}

/* Header */
.ext-chat-header {
    background: linear-gradient(135deg, var(--color-primary, #0b3d91), #1e40af);
    color: #ffffff;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ext-chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ext-chat-header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ext-chat-header-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.ext-chat-header-subtitle {
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 2px;
}

.ext-chat-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s;
}

.ext-chat-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

/* Form de Pré-Atendimento */
.ext-chat-form-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ext-chat-form-intro {
    font-size: 0.88rem;
    color: #4b5563;
    line-height: 1.45;
}

.ext-chat-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ext-chat-form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
}

.ext-chat-form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.ext-chat-form-control:focus {
    border-color: var(--color-primary, #0b3d91);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.15);
}

.ext-chat-btn-submit {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background: var(--color-primary, #0b3d91);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ext-chat-btn-submit:hover {
    background: #082d6c;
}

.ext-chat-alert {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: none;
}

/* Área de Mensagens */
.ext-chat-messages-container {
    flex: 1 1 0;
    min-height: 0;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #f9fafb;
}

.ext-chat-msg {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ext-chat-msg.visitor {
    align-self: flex-end;
}

.ext-chat-msg.staff {
    align-self: flex-start;
}

.ext-chat-msg-sender {
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7280;
    padding: 0 4px;
}

.ext-chat-msg-bubble {
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
}

.ext-chat-msg.visitor .ext-chat-msg-bubble {
    background: var(--color-primary, #0b3d91);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}

.ext-chat-msg.staff .ext-chat-msg-bubble {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ext-chat-msg-time {
    font-size: 0.68rem;
    color: #9ca3af;
    align-self: flex-end;
    margin-top: 2px;
}

.ext-chat-msg.visitor .ext-chat-msg-time {
    color: rgba(255, 255, 255, 0.75);
}

/* Footer do Chat Ativo */
.ext-chat-footer {
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-top: auto;
}

.ext-chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.ext-chat-input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 0.88rem;
    outline: none;
    font-family: inherit;
}

.ext-chat-input:focus {
    border-color: var(--color-primary, #0b3d91);
}

.ext-chat-send-btn {
    background: var(--color-primary, #0b3d91);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.ext-chat-send-btn:hover {
    background: #082d6c;
}

.ext-chat-send-btn svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
}

.ext-chat-end-link {
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
    text-decoration: none;
    cursor: pointer;
}

.ext-chat-end-link:hover {
    color: #ef4444;
    text-decoration: underline;
}

/* Adaptativo para Telas Menores */
@media (max-width: 480px) {
    .ext-chat-modal {
        right: 0.75rem;
        bottom: 5rem;
        width: calc(100vw - 1.5rem);
        height: 480px;
    }
}

@media print {
    #ext-chat-wrapper { display: none !important; }
}

