/* MarketStar Chat Widget Styles */
:root {
    --ms-primary: #E8540C;
    --ms-primary-dark: #c94700;
    --ms-dark: #1a1a2e;
    --ms-gray: #f4f5f7;
    --ms-text: #333;
    --ms-text-light: #666;
    --ms-white: #fff;
    --ms-shadow: 0 4px 24px rgba(0,0,0,0.15);
    --ms-radius: 12px;
}

/* Launcher Button */
#ms-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ms-primary);
    border: none;
    cursor: pointer;
    box-shadow: var(--ms-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: transform 0.2s, background 0.2s;
}
#ms-chat-launcher:hover {
    transform: scale(1.08);
    background: var(--ms-primary-dark);
}
#ms-chat-launcher svg {
    width: 28px;
    height: 28px;
    fill: var(--ms-white);
}

/* Chat Window */
#ms-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--ms-white);
    border-radius: var(--ms-radius);
    box-shadow: var(--ms-shadow);
    display: none;
    flex-direction: column;
    z-index: 99998;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}
#ms-chat-window.open {
    display: flex;
}

/* Header */
#ms-chat-header {
    background: var(--ms-dark);
    color: var(--ms-white);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#ms-chat-header .ms-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
#ms-chat-header .ms-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ms-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
#ms-chat-header .ms-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
#ms-chat-header .ms-header-info span {
    font-size: 11px;
    opacity: 0.7;
}
#ms-chat-header .ms-header-actions {
    display: flex;
    gap: 6px;
}
#ms-chat-header .ms-header-actions button {
    background: none;
    border: none;
    color: var(--ms-white);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
#ms-chat-header .ms-header-actions button:hover {
    opacity: 1;
}
#ms-chat-header .ms-header-actions #ms-btn-end {
    opacity: 1;
    background: rgba(255, 68, 68, 0.15);
    color: #ff4444;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
#ms-chat-header .ms-header-actions #ms-btn-end:hover {
    background: rgba(255, 68, 68, 0.3);
    color: #ff2222;
}
#ms-chat-header .ms-header-actions #ms-btn-end::after {
    content: "End";
}

/* Messages Area */
#ms-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--ms-gray);
}

.ms-message {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: ms-fadeIn 0.3s ease;
}
@keyframes ms-fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.ms-message.bot {
    background: var(--ms-white);
    color: var(--ms-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ms-message.user {
    background: var(--ms-primary);
    color: var(--ms-white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.ms-message a {
    color: var(--ms-primary);
    text-decoration: underline;
}
.ms-message.user a {
    color: var(--ms-white);
}

/* Typing indicator */
.ms-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--ms-white);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ms-typing span {
    width: 7px;
    height: 7px;
    background: #bbb;
    border-radius: 50%;
    animation: ms-bounce 1.4s infinite;
}
.ms-typing span:nth-child(2) { animation-delay: 0.2s; }
.ms-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ms-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input Area */
#ms-chat-input-area {
    padding: 12px 14px;
    background: var(--ms-white);
    border-top: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
#ms-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
#ms-chat-input:focus {
    border-color: var(--ms-primary);
}
#ms-chat-input::placeholder {
    color: #aaa;
}

/* Buttons in input area */
.ms-btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}
#ms-btn-send {
    background: var(--ms-primary);
}
#ms-btn-send:hover {
    background: var(--ms-primary-dark);
}
#ms-btn-send svg {
    fill: var(--ms-white);
    width: 18px;
    height: 18px;
}
#ms-btn-voice {
    background: var(--ms-gray);
}
#ms-btn-voice:hover {
    background: #e0e0e0;
}
#ms-btn-voice svg {
    fill: var(--ms-text);
    width: 18px;
    height: 18px;
}
#ms-btn-voice.recording {
    background: #ff4444;
    animation: ms-pulse 1.2s infinite;
}
#ms-btn-voice.recording svg {
    fill: var(--ms-white);
}
@keyframes ms-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255,68,68,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,68,68,0); }
}

/* Voice mode indicator */
#ms-voice-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: #fff3f0;
    color: var(--ms-primary);
    font-size: 12px;
    font-weight: 500;
}
#ms-voice-indicator.active {
    display: flex;
}

/* Responsive */
@media (max-width: 480px) {
    #ms-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    #ms-chat-launcher {
        bottom: 16px;
        right: 16px;
    }
}
