/**
 * Estilos do Chat Hub
 * Base visual do widget, formulários, conversas e mensagens
 */

.chat-widget {
    --chat-safe-bottom: 24px;
    position: fixed;
    right: 24px;
    bottom: var(--chat-safe-bottom);
    z-index: 9999;
    font-family: 'Poppins', sans-serif;
}

.chat-toggle-button {
    position: relative;
    width: 64px;
    height: 64px;
    border: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    box-shadow: 0 18px 40px rgba(37, 99, 235, 0.32);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-toggle-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 22px 48px rgba(37, 99, 235, 0.38);
}

.chat-widget--open .chat-toggle-button {
    display: none;
}

.chat-widget--open .chat-container {
    margin-bottom: 0;
}

.chat-container {
    width: 380px;
    height: 620px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(125, 211, 252, 0.35), transparent 28%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(14px);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    color: #fff;
    background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
}

.status-indicator {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    flex-shrink: 0;
}

.status-indicator--open,
.status-indicator--online {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.status-indicator--offline {
    background: #f97316;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.18);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.16);
    transition: background 0.2s ease, transform 0.2s ease;
}

.chat-header-button:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.04);
}

.chat-messages {
    flex: 1;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(241, 245, 249, 0.92) 100%);
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.5);
}

.chat-input-container {
    flex-shrink: 0;
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.06);
}

.chat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #dbe2ea;
    border-radius: 16px;
    padding: 13px 16px;
    background: #fff;
    color: #0f172a;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.chat-send-button {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.24);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.chat-send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.3);
}

.chat-identification-form,
.chat-conversation-list {
    width: 100%;
    margin: auto 0;
    padding: 4px 2px;
}

.chat-identification-header {
    margin-bottom: 18px;
}

.chat-identification-header h3 {
    margin: 0 0 6px;
    color: #0f172a;
    font-size: 22px;
    line-height: 1.15;
    font-weight: 700;
}

.chat-identification-header p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

#chatIdentificationForm {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    color: #334155;
    font-size: 13px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    padding: 13px 14px;
    background: #fff;
    color: #0f172a;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.form-group input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.form-error {
    min-height: 16px;
    color: #dc2626;
    font-size: 12px;
    line-height: 1.3;
    display: none;
}

.chat-identification-submit,
.btn-primary,
.btn-secondary {
    border: 0;
    border-radius: 16px;
    padding: 14px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-identification-submit,
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.22);
}

.chat-identification-submit:hover,
.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-secondary {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.09);
}

.chat-empty-state {
    min-height: 100%;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    color: #64748b;
}

.chat-empty-state i {
    font-size: 32px;
    color: #3b82f6;
}

.chat-conversation-header {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-conversation-header h4 {
    margin: 0;
    color: #0f172a;
    font-size: 18px;
    font-weight: 700;
}

.chat-conversation-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-conversation-item {
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.chat-conversation-item:hover {
    transform: translateY(-1px);
    border-color: rgba(59, 130, 246, 0.24);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.conversation-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conversation-title {
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
}

.conversation-date {
    color: #64748b;
    font-size: 12px;
}

.chat-message {
    display: grid;
    gap: 6px;
    max-width: 86%;
}

.chat-message--client {
    align-self: flex-end;
    justify-items: end;
}

.chat-message--agent,
.chat-message--system {
    align-self: flex-start;
    justify-items: start;
}

.chat-message-content {
    border-radius: 18px;
    padding: 12px 14px;
    word-break: break-word;
    line-height: 1.5;
    font-size: 14px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.chat-message--client .chat-message-content {
    color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    border-bottom-right-radius: 6px;
}

.chat-message--agent .chat-message-content {
    color: #0f172a;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-bottom-left-radius: 6px;
}

.chat-message--system .chat-message-content {
    color: #7c2d12;
    background: #fff7ed;
    border: 1px solid #fdba74;
}

.chat-message--deleted .chat-message-content {
    color: #64748b;
    background: #f1f5f9;
    font-style: italic;
}

.chat-message--failed .chat-message-content {
    border: 1px solid rgba(239, 68, 68, 0.28);
}

.failed-indicator {
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
}

.chat-message-time {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
}

.chat-message-avatar {
    display: none;
}

.chat-message--highlighted .chat-message-content {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}

.chat-message--updated .chat-message-content {
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.chat-typing-indicator,
.chat-loading-indicator,
.chat-offline-message {
    width: 100%;
    padding: 18px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(148, 163, 184, 0.16);
    color: #475569;
}

.chat-offline-message {
    margin: auto 0;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.offline-icon,
.loading-spinner,
.typing-avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.offline-icon {
    font-size: 18px;
}

.typing-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.typing-name,
.loading-text,
.offline-text h3 {
    color: #0f172a;
    font-size: 13px;
    font-weight: 600;
}

.offline-text p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 13px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
    animation: chat-typing 1.2s infinite ease-in-out;
}

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

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

.chat-notification {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.32);
}

.chat-widget--offline .chat-toggle-button {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 18px 36px rgba(71, 85, 105, 0.26);
}

@keyframes chat-typing {
    0%,
    80%,
    100% {
        transform: scale(0.84);
        opacity: 0.45;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .chat-widget {
        --chat-safe-bottom: 92px;
        left: 12px;
        right: 12px;
    }

    .chat-container {
        width: 100%;
        height: min(74vh, 620px);
        margin-bottom: 0;
        border-radius: 20px;
    }

    .chat-message {
        max-width: 92%;
    }
}
