/**
 * Madika AI - Floating Chat Widget Stylesheet (Master Suite Module 7)
 * Sleek glassmorphism, responsive, zero-framework.
 * All IDs strictly namespaced to #madika-mms-chat-* to prevent theme collisions.
 */

:root {
    --madika-chat-color: #2563eb;
    --madika-chat-bg: #ffffff;
    --madika-chat-text: #0f172a;
    --madika-chat-bot-bubble: #f1f5f9;
    --madika-chat-shadow: 0 12px 36px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
}

#madika-mms-chat-root {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--madika-chat-text);
}

#madika-mms-chat-root.madika-pos-right {
    right: 24px;
}

#madika-mms-chat-root.madika-pos-left {
    left: 24px;
}

/* Launcher Bubble */
#madika-mms-chat-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--madika-chat-color);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    outline: none;
}

#madika-mms-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.45);
}

#madika-mms-chat-launcher:active {
    transform: scale(0.95);
}

/* Chat Window */
#madika-mms-chat-window {
    position: absolute;
    bottom: 75px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: var(--madika-chat-bg);
    border-radius: 16px;
    box-shadow: var(--madika-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

#madika-mms-chat-root.madika-pos-right #madika-mms-chat-window {
    right: 0;
    transform-origin: bottom right;
}

#madika-mms-chat-root.madika-pos-left #madika-mms-chat-window {
    left: 0;
    transform-origin: bottom left;
}

#madika-mms-chat-window.madika-chat-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px) scale(0.94);
    display: none !important;
}

/* Header */
.madika-chat-header {
    background: var(--madika-chat-color);
    color: #ffffff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.madika-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.madika-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #ffffff;
    position: relative;
}

.madika-chat-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #ffffff;
}

.madika-chat-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.madika-chat-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

#madika-mms-chat-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    padding: 4px;
    transition: opacity 0.15s;
}

#madika-mms-chat-close-btn:hover {
    opacity: 1;
}

/* Chat Body */
.madika-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

.madika-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.45;
    font-size: 13.5px;
    word-break: break-word;
    animation: madikaFadeIn 0.2s ease-out;
}

@keyframes madikaFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.madika-msg-bot {
    align-self: flex-start;
    background: var(--madika-chat-bot-bubble);
    color: #1e293b;
    border-bottom-left-radius: 3px;
}

.madika-msg-user {
    align-self: flex-end;
    background: var(--madika-chat-color);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}

/* Typing indicator */
.madika-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--madika-chat-bot-bubble);
    border-radius: 14px;
    border-bottom-left-radius: 3px;
    align-self: flex-start;
}

.madika-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: madikaBounce 1.4s infinite ease-in-out both;
}

.madika-typing span:nth-child(1) { animation-delay: -0.32s; }
.madika-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes madikaBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Quick Suggestion Chips */
.madika-chat-chips {
    padding: 8px 16px;
    background: #fafafa;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #f1f5f9;
}

.madika-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 5px 10px;
    font-size: 11.5px;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.madika-chip:hover {
    border-color: var(--madika-chat-color);
    color: var(--madika-chat-color);
    background: #eff6ff;
}

/* Footer / Input */
.madika-chat-footer {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 8px;
}

#madika-mms-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s ease;
}

#madika-mms-chat-input:focus {
    border-color: var(--madika-chat-color);
}

#madika-mms-chat-send-btn {
    background: var(--madika-chat-color);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    outline: none;
}

#madika-mms-chat-send-btn:hover {
    transform: scale(1.05);
}

#madika-mms-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #madika-mms-chat-window {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
}
