/* ============================================================
   MultiDesk Chat — 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;
    height: auto;
    max-height: calc(100vh - 120px);
    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;
    min-height: 0;
    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 1 auto;
    min-height: 0;   /* permite que #mwa-messages haga scroll y la barra de escritura siempre se vea */
}

#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 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-wrap: anywhere;
    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: 20px; height: 20px; 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; }
}


/* ── Limpiar conversación / nota 24 h ─────────────────────── */
#mwa-widget .mwa-chat-clear {
    margin-left: auto;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: rgba(255,255,255,.85) !important;
    cursor: pointer;
    padding: 6px !important;
    width: 32px;
    height: 32px;
    min-width: 0;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
#mwa-widget .mwa-chat-clear svg { width: 18px; height: 18px; fill: currentColor; }
#mwa-widget .mwa-chat-clear:hover { background: rgba(255,255,255,.15) !important; color: #fff !important; }

.mwa-chat-note {
    background: #ECE5DD;
    color: #8a8a8a;
    font-size: 11px;
    text-align: center;
    padding: 0 12px 4px;
    flex-shrink: 0;
}
.mwa-chat-input-bar { flex: 0 0 auto; }
.mwa-bubble-text { white-space: pre-wrap; }


/* ── Lista tipo tarjetas (departamentos + asistente) ───────── */
#mwa-widget #mwa-dept-panel { background: #ECE5DD; padding-bottom: 10px; }
#mwa-widget .mwa-w-header-logo.has-img { background:#fff; overflow:hidden; }
#mwa-widget .mwa-w-header-logo img { width:100%; height:100%; object-fit:cover; display:block; }

#mwa-widget .mwa-notice {
    margin: 14px 12px 4px; background:#fff; border-radius:12px; padding:12px 14px;
    font-size:14px; line-height:1.5; color:#27272a; box-shadow:0 1px 2px rgba(0,0,0,.12);
}
#mwa-widget .mwa-notice a { color:#128C7E; font-weight:700; text-decoration:none; }
#mwa-widget .mwa-notice a:hover { text-decoration:underline; }

#mwa-widget .mwa-dept-list-header { padding:14px 16px 6px; color:#54656f; font-size:11px; font-weight:800; letter-spacing:.08em; }
#mwa-widget .mwa-dept-item {
    margin: 0 12px 8px; border-radius:12px; border:1px solid transparent; background:#fff;
    padding:10px 12px; transition:border-color .15s, transform .15s;
}
#mwa-widget .mwa-dept-item:hover { background:#fff; border-color:#25D366; transform:translateY(-1px); }
#mwa-widget .mwa-dept-avatar { overflow:visible; }
#mwa-widget .mwa-dept-avatar img { width:100%; height:100%; border-radius:50%; object-fit:cover; }
#mwa-widget .mwa-dept-st { font-size:12px; font-weight:700; color:#8a8f94; margin-top:2px; }
#mwa-widget .mwa-dept-st.on { color:#128C7E; }
#mwa-widget .mwa-wa-ico { color:#25D366; width:22px; height:22px; display:flex; transform:scaleX(-1); }
#mwa-widget .mwa-wa-ico svg { width:22px; height:22px; fill:currentColor; }

#mwa-widget .mwa-ai-section { background:transparent; border-top:0; padding:6px 0 0; }
#mwa-widget .mwa-ai-section-label { padding:8px 16px 8px; color:#54656f; font-size:11px; font-weight:800; letter-spacing:.08em; display:flex; align-items:center; gap:10px; }
#mwa-widget .mwa-ai-section-label:before, #mwa-widget .mwa-ai-section-label:after { content:''; flex:1; height:1px; background:rgba(0,0,0,.12); }
#mwa-widget .mwa-ai-item {
    margin: 0 12px; border-radius:12px; border:1px solid rgba(0,0,0,.08); padding:10px 12px;
    transition:border-color .15s, filter .15s;
}
#mwa-widget .mwa-ai-item:hover { background:inherit; filter:brightness(.97); border-color:var(--mwa-ai-accent,#2563B8); }
#mwa-widget .mwa-ai-avatar { overflow:visible; }
#mwa-widget .mwa-ai-avatar img { width:100%; height:100%; border-radius:50%; object-fit:contain; padding:5px; box-sizing:border-box; }
#mwa-widget .mwa-ai-name { font-size:14.5px; font-weight:700; color:#111b21; }
#mwa-widget .mwa-ai-st { font-size:12px; font-weight:700; color:var(--mwa-ai-accent,#2563B8); margin-top:2px; }
#mwa-widget .mwa-ai-chevron { color:var(--mwa-ai-accent,#2563B8); display:flex; flex-shrink:0; }

#mwa-widget.mwa-chat-view { height: 560px; }

.mwa-bubble.assistant a { color:#128C7E; font-weight:700; text-decoration:underline; word-break:break-word; }
