/* MAK Chat Widget — Frontend Styles */

/* Reset for widget scope */
.mcw-widget,
.mcw-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
}

/* Floating bubble */
.mcw-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mcw-primary, #007A53);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 999998;
    transition: transform 0.2s, box-shadow 0.2s;
}
.mcw-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.mcw-bubble:focus {
    outline: 3px solid var(--mcw-primary, #007A53);
    outline-offset: 2px;
}

/* Chat window */
.mcw-chat {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-height: 600px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mcwSlideUp 0.25s ease-out;
}

@keyframes mcwSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.mcw-header {
    background: var(--mcw-primary, #007A53);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.mcw-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mcw-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.mcw-header-title {
    font-weight: 600;
    font-size: 15px;
}
.mcw-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
}
.mcw-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}
.mcw-close-btn,
.mcw-reset-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    opacity: 0.75;
}
.mcw-close-btn { font-size: 24px; }
.mcw-reset-btn { font-size: 18px; }
.mcw-close-btn:hover,
.mcw-reset-btn:hover {
    opacity: 1;
}

/* Messages area */
.mcw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 250px;
    max-height: 380px;
    background: #f0f2f5;
}

/* Message bubbles */
.mcw-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    word-wrap: break-word;
    animation: mcwFadeIn 0.2s ease-out;
}
@keyframes mcwFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.mcw-msg-bot {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    margin-right: auto;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.mcw-msg-visitor {
    background: var(--mcw-primary, #007A53);
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}
.mcw-msg-system {
    background: transparent;
    color: #666;
    font-size: 12px;
    text-align: center;
    max-width: 100%;
}
.mcw-msg b, .mcw-msg strong {
    font-weight: 600;
}
.mcw-msg a {
    color: inherit;
    text-decoration: underline;
}

/* Typing indicator */
.mcw-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.mcw-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: mcwTyping 1.2s infinite;
}
.mcw-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.mcw-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes mcwTyping {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Quick replies */
.mcw-quick-replies {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f0f2f5;
    flex-shrink: 0;
}
.mcw-qr-btn {
    background: #ffffff !important;
    border: 1.5px solid #007A53 !important;
    color: #007A53 !important;
    padding: 6px 14px !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
    white-space: nowrap !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    box-shadow: none !important;
}
.mcw-qr-btn:hover,
.mcw-qr-btn:focus {
    background: #007A53 !important;
    color: #ffffff !important;
}

/* Input area */
.mcw-input-area {
    display: flex;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e5e5e5;
    gap: 8px;
    flex-shrink: 0;
}
.mcw-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    outline: none;
}
.mcw-chat-input:focus {
    border-color: var(--mcw-primary, #007A53);
}
.mcw-send-btn {
    background: var(--mcw-primary, #007A53);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.mcw-send-btn:hover {
    opacity: 0.9;
}

/* Lead capture form */
.mcw-lead-form {
    padding: 16px;
    background: #fff;
    border-top: 2px solid var(--mcw-primary, #007A53);
}
.mcw-form-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}
.mcw-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}
.mcw-input:focus {
    border-color: var(--mcw-primary, #007A53);
    outline: none;
}
.mcw-hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
}
.mcw-form-error {
    color: #d32f2f;
    font-size: 13px;
    margin-bottom: 8px;
}
.mcw-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}
.mcw-btn-primary {
    background: var(--mcw-primary, #007A53);
    color: #fff;
    width: 100%;
}
.mcw-btn-primary:hover {
    opacity: 0.9;
}
.mcw-btn-ghost {
    background: transparent;
    color: var(--mcw-primary, #007A53);
    border: none;
    width: 100%;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 400;
    text-align: center;
    padding: 4px 0;
    text-decoration: underline;
    cursor: pointer;
}
.mcw-btn-ghost:hover {
    opacity: 0.75;
}

/* WhatsApp button */
.mcw-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    margin-top: 8px;
    transition: opacity 0.15s;
}
.mcw-wa-btn:hover {
    opacity: 0.9;
    color: #fff;
}
.mcw-wa-btn svg {
    width: 20px;
    height: 20px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .mcw-chat {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        max-height: calc(100vh - 100px);
        border-radius: 12px;
    }
    .mcw-bubble {
        bottom: 12px;
        right: 12px;
    }
    .mcw-messages {
        max-height: calc(100vh - 280px);
    }
}
