/* ============================================================
   Master WhatsApp — Widget Stylesheet
   ============================================================ */

/* ── Toggle Button ───────────────────────────────────────── */

#mwa-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,211,102,.5);
    z-index: 9990;
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
}

#mwa-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(37,211,102,.6);
}

#mwa-toggle-btn svg {
    width: 32px;
    height: 32px;
    fill: #fff;
}

#mwa-toggle-btn.mwa-pos-left {
    right: auto;
    left: 24px;
}

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

/* ── Widget Popup ─────────────────────────────────────────── */

#mwa-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    z-index: 9991;
    display: none;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

#mwa-widget.mwa-open { display: flex; }

#mwa-widget.mwa-pos-left {
    right: auto;
    left: 24px;
}

/* ── Header ──────────────────────────────────────────────── */

.mwa-w-header {
    background: #075E54;
    padding: 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.mwa-w-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mwa-w-header-logo {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mwa-w-header-logo svg { width: 22px; height: 22px; fill: #fff; }

.mwa-w-company-name {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.mwa-w-tagline {
    color: rgba(255,255,255,.8);
    font-size: 12px;
}

.mwa-w-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color .15s;
}

.mwa-w-close:hover { color: #fff; }

/* ── Department List Panel ────────────────────────────────── */

#mwa-dept-panel {
    flex: 1;
    overflow-y: auto;
    background: #f0f0f0;
}

.mwa-dept-list-header {
    padding: 14px 16px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #5f6368;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.mwa-dept-item {
    background: #fff;
    margin: 0 0 1px 0;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}

.mwa-dept-item:hover { background: #f9f9f9; }

.mwa-dept-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

.mwa-dept-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #25D366;
    border: 2px solid #fff;
}

.mwa-dept-status-dot.offline { background: #9ca3af; }

.mwa-dept-info { flex: 1; min-width: 0; }

.mwa-dept-name {
    font-size: 14px;
    font-weight: 600;
    color: #111b21;
    margin-bottom: 2px;
}

.mwa-dept-role {
    font-size: 12px;
    color: #667781;
}

.mwa-dept-schedule {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.mwa-dept-arrow {
    color: #9ca3af;
    font-size: 16px;
    flex-shrink: 0;
}

/* ── AI Assistant Section ─────────────────────────────────── */

.mwa-ai-section {
    background: #fff;
    border-top: 1px solid #e9edef;
    padding: 0;
}

.mwa-ai-section-label {
    padding: 10px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #5f6368;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.mwa-ai-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background .15s;
}

.mwa-ai-item:hover { background: #f9f9f9; }

.mwa-ai-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    flex-shrink: 0;
    position: relative;
}

.mwa-ai-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #25D366;
    border: 2px solid #fff;
}

.mwa-ai-info { flex: 1; }

.mwa-ai-name {
    font-size: 14px;
    font-weight: 600;
    color: #111b21;
}

.mwa-ai-subtitle {
    font-size: 12px;
    color: #667781;
}

/* ── AI Chat Panel ────────────────────────────────────────── */

#mwa-chat-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

#mwa-chat-panel.mwa-open { display: flex; }

.mwa-chat-header {
    background: #075E54;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.mwa-chat-back {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color .15s;
}
.mwa-chat-back:hover { color: #fff; }

.mwa-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}

.mwa-chat-ai-name {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.mwa-chat-ai-status {
    color: rgba(255,255,255,.7);
    font-size: 12px;
}

/* ── Chat Messages ────────────────────────────────────────── */

#mwa-messages {
    flex: 1;
    overflow-y: auto;
    background: #ECE5DD;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mwa-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.mwa-bubble.user {
    background: #DCF8C6;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.mwa-bubble.assistant {
    background: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

.mwa-bubble-time {
    font-size: 10px;
    color: #8696a0;
    text-align: right;
    margin-top: 3px;
}

/* Typing indicator */
.mwa-typing {
    background: #fff;
    align-self: flex-start;
    border-radius: 8px;
    border-bottom-left-radius: 2px;
    padding: 10px 14px;
    display: none;
}

.mwa-typing.visible { display: flex; gap: 4px; align-items: center; }

.mwa-dot {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: mwa-bounce .8s infinite;
}

.mwa-dot:nth-child(2) { animation-delay: .15s; }
.mwa-dot:nth-child(3) { animation-delay: .3s; }

@keyframes mwa-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-5px); }
}

/* ── Input Bar ────────────────────────────────────────────── */

.mwa-chat-input-bar {
    background: #f0f2f5;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#mwa-chat-input {
    flex: 1;
    background: #fff;
    border: none;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    outline: none;
    resize: none;
    max-height: 80px;
    overflow-y: auto;
    color: #111;
    font-family: inherit;
}

#mwa-chat-send {
    width: 40px;
    height: 40px;
    background: #25D366;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}

#mwa-chat-send:hover { background: #1da851; }
#mwa-chat-send:disabled { background: #ccc; cursor: default; }

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

/* ── Animations ───────────────────────────────────────────── */

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

#mwa-widget.mwa-open { animation: mwa-slide-up .2s ease; }

/* ── Mobile ───────────────────────────────────────────────── */

@media (max-width: 480px) {
    #mwa-widget {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 84px;
    }

    #mwa-widget.mwa-pos-left {
        left: 10px;
        right: auto;
    }

    #mwa-toggle-btn { right: 16px; bottom: 16px; }
    #mwa-toggle-btn.mwa-pos-left { left: 16px; right: auto; }
}
