/* ── OpenClaw Chat Widget ── */
.chat-widget-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004dff, #00c6ff);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 77, 255, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: chat-pulse 2s infinite;
}

.chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 77, 255, 0.5);
}

.chat-widget-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.chat-widget-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4444;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    font-weight: 700;
}

@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 77, 255, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(0, 77, 255, 0.6); }
}

/* ── Chat Window ── */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: chat-slide-up 0.3s ease-out;
}

.chat-window.open {
    display: flex;
}

@keyframes chat-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
.chat-header {
    position: relative;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004dff, #00c6ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.chat-header-info span {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}

.chat-header-info .status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #28a745;
    margin-right: 4px;
    vertical-align: middle;
}

.chat-countdown {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 198, 255, 0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    animation: countdown-fade 0.3s ease-out;
    z-index: 1;
}

@keyframes countdown-fade {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.chat-close:hover {
    color: #fff;
}

/* ── Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fa;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msg-fade 0.3s ease-out;
}

@keyframes msg-fade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
    background: linear-gradient(135deg, #004dff, #0066ff);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot {
    background: #fff;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-msg .time {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
    display: block;
}

.chat-msg.bot .time {
    color: #aaa;
}

/* Typing indicator */
.chat-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 16px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

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

.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: typing-dot 1.4s infinite;
}

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

@keyframes typing-dot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Input ── */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: center;
    background: #fff;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #004dff;
}

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004dff, #00c6ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.05);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ── Connect status ── */
.chat-status {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #999;
    background: #f7f8fa;
}

.chat-status.error {
    color: #dc3545;
    background: #fff5f5;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 140px);
        right: 10px;
        bottom: 80px;
        border-radius: 12px;
    }

    .chat-widget-btn {
        right: 16px;
        bottom: 16px;
    }
}
