/* ============================================
   BrSwap Chat Widget - Adam
   ============================================ */

/* Toggle Button */
.brswap-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 54px;
    height: 54px;
    padding: 0;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    outline: none;
    animation: brswap-toggle-pulse 2s ease-in-out infinite;
}

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

.brswap-chat-toggle:hover {
    transform: scale(1.08);
    animation: none;
    box-shadow: none;
}

.brswap-chat-toggle:active {
    transform: scale(0.95);
}

.brswap-toggle-online {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #111111;
}

/* Container */
.brswap-chat-container {
    position: fixed;
    bottom: 86px;
    right: 20px;
    width: 370px;
    height: 500px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    background: #111111;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    opacity: 0;
    transform: scale(0.85) translateY(16px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.brswap-chat-container.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Header */
.brswap-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #141414;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.brswap-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brswap-chat-avatar {
    position: relative;
    font-size: 18px;
    color: #ffffff;
    flex-shrink: 0;
}

.brswap-chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brswap-chat-header-title {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.brswap-chat-header-sub {
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    font-weight: 400;
}

.brswap-chat-close {
    background: rgba(239, 68, 68, 0.15);
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s ease;
    line-height: 1;
}

.brswap-chat-close:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: rotate(90deg);
}

/* Messages Area */
.brswap-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #111111;
}

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

.brswap-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.brswap-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.brswap-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

/* Message Row */
.brswap-chat-msg-row {
    display: flex;
    gap: 8px;
    animation: brswap-msg-in 0.2s ease;
}

.brswap-chat-msg-row.user {
    justify-content: flex-end;
}

.brswap-chat-msg-row.bot {
    align-items: flex-start;
}

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

/* Bot Avatar in Messages */
.brswap-chat-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Message Bubble */
.brswap-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.55;
    word-wrap: break-word;
}

.brswap-chat-msg.user {
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border-radius: 14px 14px 2px 14px;
}

.brswap-chat-msg.bot {
    background: #1d3b6e;
    color: rgba(255, 255, 255, 0.85);
    border-radius: 14px 14px 14px 2px;
}

.brswap-chat-msg.bot a {
    color: #22c55e;
    text-decoration: underline;
}

.brswap-chat-msg.bot a:hover {
    color: #4ade80;
}

.brswap-chat-msg.bot strong {
    color: #f0f0f0;
}

/* Typing Indicator */
.brswap-chat-typing-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: brswap-msg-in 0.2s ease;
}

.brswap-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #1a1a1a;
    border-radius: 14px 14px 14px 2px;
}

.brswap-chat-typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    animation: brswap-typing-bounce 1.2s ease-in-out infinite;
}

.brswap-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.brswap-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes brswap-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-5px); opacity: 0.8; }
}

/* Input Area */
.brswap-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #111111;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.brswap-chat-input {
    flex: 1;
    padding: 10px 16px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.brswap-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.brswap-chat-input:focus {
    border-color: rgba(34, 197, 94, 0.4);
}

.brswap-chat-send {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.brswap-chat-send:hover {
    filter: brightness(1.1);
}

.brswap-chat-send:disabled {
    background: rgba(255, 255, 255, 0.06);
    cursor: not-allowed;
    opacity: 0.4;
    filter: none;
}

/* Mobile */
@media (max-width: 768px) {
    .brswap-chat-toggle {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .brswap-chat-container {
        bottom: 76px;
        right: 8px;
        left: 8px;
        width: auto;
        height: 70vh;
        max-height: 520px;
    }
}

@media (max-width: 380px) {
    .brswap-chat-container {
        right: 4px;
        left: 4px;
        bottom: 72px;
        height: 75vh;
    }
}
