/* === SimpleX Chat Widget === */
#scw-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Floating mascot button */
#scw-toggle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: none;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.22);
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}
#scw-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.28);
}
#scw-toggle img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

/* Notification badge */
.scw-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.scw-badge.scw-hidden { display: none; }

/* Chat popup */
#scw-popup {
    position: absolute;
    bottom: 82px;
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform-origin: bottom right;
}
#scw-popup.scw-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(8px);
}

/* Header */
#scw-header {
    background: #1a1a2e;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.scw-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}
#scw-header span {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
}
#scw-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
#scw-close:hover { color: #fff; }

/* SimpleX link bar */
#scw-simplex-bar {
    background: #0d1b2a;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.65);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
#scw-simplex-btn {
    background: #26a69a;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    transition: background 0.15s;
}
#scw-simplex-btn:hover { background: #2bbbaf; }

/* Messages area */
#scw-messages {
    flex: 1;
    min-height: 240px;
    max-height: 340px;
    overflow-y: auto;
    padding: 14px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f7f8fc;
}

.scw-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}
.scw-msg.scw-bot {
    background: #fff;
    color: #1a1a2e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.scw-msg.scw-user {
    background: #1a1a2e;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.scw-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 13px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.scw-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: scw-bounce 1.2s infinite;
}
.scw-typing span:nth-child(2) { animation-delay: 0.2s; }
.scw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes scw-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input row */
#scw-input-row {
    display: flex;
    padding: 10px;
    gap: 8px;
    border-top: 1px solid #eee;
    background: #fff;
}
#scw-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
#scw-input:focus { border-color: #1a1a2e; }
#scw-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #1a1a2e;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
#scw-send:hover { background: #2d2d4e; }

/* Mobile */
@media (max-width: 400px) {
    #scw-popup { width: calc(100vw - 32px); right: 0; }
}
