/* Milita Chat Widget */

#milita-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6B2035, #a33355);
    border: 3px solid #fff;
    box-shadow: 0 4px 15px rgba(107, 32, 53, 0.4);
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

#milita-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(107, 32, 53, 0.6);
}

#milita-bubble img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

#milita-bubble .milita-icon {
    font-size: 28px;
    color: #fff;
    line-height: 1;
}

/* Pulse animation on first visit */
#milita-bubble.milita-pulse {
    animation: milita-pulse-anim 2s ease-in-out 3;
}

@keyframes milita-pulse-anim {
    0%, 100% { box-shadow: 0 4px 15px rgba(107, 32, 53, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(107, 32, 53, 0.8), 0 0 0 10px rgba(107, 32, 53, 0.1); }
}

/* Chat panel */
#milita-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#milita-panel.milita-open {
    display: flex;
}

/* Header */
#milita-header {
    background: linear-gradient(135deg, #6B2035, #a33355);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#milita-header .milita-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

#milita-header .milita-avatar-small img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

#milita-header .milita-info {
    flex: 1;
}

#milita-header .milita-name {
    font-weight: 600;
    font-size: 15px;
}

#milita-header .milita-status {
    font-size: 12px;
    opacity: 0.85;
}

#milita-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

#milita-close:hover {
    opacity: 1;
}

/* Messages area */
#milita-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f7f8;
}

.milita-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.milita-msg-user {
    align-self: flex-end;
    background: #6B2035;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.milita-msg-assistant {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #e5e5e5;
    border-bottom-left-radius: 4px;
}

.milita-msg-system {
    align-self: center;
    background: #fff3cd;
    color: #856404;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    text-align: center;
}

/* Typing indicator */
.milita-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.milita-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: milita-typing-dot 1.4s ease-in-out infinite;
}

.milita-typing span:nth-child(2) { animation-delay: 0.2s; }
.milita-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes milita-typing-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
#milita-input-area {
    display: flex;
    align-items: center;
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}

#milita-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.4;
}

#milita-input:focus {
    border-color: #6B2035;
}

#milita-input::placeholder {
    color: #aaa;
}

#milita-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #6B2035;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#milita-send:hover {
    background: #a33355;
}

#milita-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #milita-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 10px;
        border-radius: 12px;
    }

    #milita-bubble {
        bottom: 12px;
        right: 12px;
        width: 52px;
        height: 52px;
    }
}

/* Scrollbar */
#milita-messages::-webkit-scrollbar {
    width: 5px;
}

#milita-messages::-webkit-scrollbar-track {
    background: transparent;
}

#milita-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
