/* Cliniminds.AI — floating help chatbot (public + LMS) */
/* Wrapper: no layout steal; LMS body often has overflow:hidden — keep children position:fixed painting above shell */
.cm-ai-chat-root {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: visible !important;
    pointer-events: none !important;
    z-index: 2147483646 !important;
    background: transparent !important;
    font-family: 'Segoe UI', Inter, system-ui, sans-serif;
    font-size: 14px;
    color: #0f172a;
}

.cm-ai-chat-fab {
    position: fixed !important;
    left: auto !important;
    right: 18px !important;
    bottom: 22px !important;
    z-index: 2147483646 !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #0ea5e9, #0369a1);
    color: #fff;
    box-shadow: 0 10px 28px rgba(2, 132, 199, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    -webkit-tap-highlight-color: transparent;
}

    .cm-ai-chat-fab:hover {
        transform: scale(1.05);
        box-shadow: 0 14px 34px rgba(2, 132, 199, 0.55);
    }

    .cm-ai-chat-fab svg {
        width: 26px;
        height: 26px;
        fill: currentColor;
    }

.cm-ai-chat-backdrop {
    position: fixed !important;
    inset: 0;
    z-index: 2147483645 !important;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    pointer-events: auto !important;
}

    .cm-ai-chat-backdrop.cm-ai-chat-open {
        display: block;
    }

.cm-ai-chat-panel,
.cm-ai-chat-email {
    position: fixed !important;
    z-index: 2147483646 !important;
    pointer-events: auto !important;
    left: auto;
    right: 16px;
    bottom: 88px;
    width: min(400px, calc(100vw - 32px));
    max-height: min(560px, calc(100vh - 120px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

    .cm-ai-chat-panel.cm-ai-chat-open,
    .cm-ai-chat-email.cm-ai-chat-open {
        display: flex;
    }

.cm-ai-chat-head {
    padding: 14px 16px;
    background: linear-gradient(120deg, #0f172a, #1e3a5f);
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

    .cm-ai-chat-head h2 {
        margin: 0;
        font-size: 15px;
        font-weight: 700;
        letter-spacing: 0.02em;
    }

    .cm-ai-chat-head p {
        margin: 4px 0 0;
        font-size: 12px;
        opacity: 0.88;
        line-height: 1.35;
    }

.cm-ai-chat-close {
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

    .cm-ai-chat-close:hover {
        background: rgba(255, 255, 255, 0.2);
    }

.cm-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    background: #f8fafc;
    min-height: 200px;
}

.cm-ai-chat-msg {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    line-height: 1.45;
    max-width: 92%;
    word-break: break-word;
}

    .cm-ai-chat-msg.user {
        margin-left: auto;
        background: #e0f2fe;
        color: #0c4a6e;
        border: 1px solid #bae6fd;
    }

    .cm-ai-chat-msg.bot {
        margin-right: auto;
        background: #fff;
        border: 1px solid #e2e8f0;
        color: #1e293b;
    }

.cm-ai-chat-foot {
    padding: 10px 12px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    gap: 8px;
}

    .cm-ai-chat-foot .cm-ai-chat-icon-btn {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border: 1px solid #cbd5e1;
        border-radius: 12px;
        background: #fff;
        color: #334155;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    }

        .cm-ai-chat-foot .cm-ai-chat-icon-btn svg {
            width: 21px;
            height: 21px;
            fill: currentColor;
        }

        .cm-ai-chat-foot .cm-ai-chat-icon-btn:hover {
            background: #f8fafc;
            border-color: #38bdf8;
            color: #0369a1;
        }

        .cm-ai-chat-foot .cm-ai-chat-icon-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .cm-ai-chat-foot .cm-ai-chat-icon-btn.cm-ai-chat-voice-on {
            background: #ecfeff;
            border-color: #67e8f9;
            color: #0e7490;
        }

        .cm-ai-chat-foot .cm-ai-chat-icon-btn.cm-ai-chat-listening {
            background: #fee2e2;
            border-color: #f87171;
            color: #b91c1c;
            box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.18);
        }

    .cm-ai-chat-foot textarea {
        flex: 1;
        resize: none;
        min-height: 44px;
        max-height: 120px;
        padding: 10px 12px;
        border-radius: 12px;
        border: 1px solid #cbd5e1;
        font: inherit;
        line-height: 1.35;
    }

        .cm-ai-chat-foot textarea:focus {
            outline: 2px solid rgba(14, 165, 233, 0.35);
            border-color: #38bdf8;
        }

.cm-ai-chat-send {
    border: none;
    border-radius: 12px;
    padding: 0 16px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(145deg, #0ea5e9, #0284c7);
    color: #fff;
    white-space: nowrap;
}

    .cm-ai-chat-send:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

.cm-ai-chat-email-body {
    padding: 16px;
}

    .cm-ai-chat-email-body label {
        display: block;
        font-weight: 600;
        margin-bottom: 6px;
        font-size: 13px;
    }

    .cm-ai-chat-email-body input[type="email"],
    .cm-ai-chat-email-body input[type="tel"] {
        width: 100%;
        padding: 11px 12px;
        border-radius: 10px;
        border: 1px solid #cbd5e1;
        font: inherit;
        margin-bottom: 12px;
    }

    .cm-ai-chat-email-body input:focus {
        outline: 2px solid rgba(14, 165, 233, 0.35);
        border-color: #38bdf8;
    }

    .cm-ai-chat-email-body .cm-ai-chat-hint {
        font-size: 12px;
        color: #64748b;
        margin: 0 0 14px;
        line-height: 1.45;
    }

.cm-ai-chat-email-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.cm-ai-chat-btn-secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 600;
}

.cm-ai-chat-error {
    color: #b91c1c;
    font-size: 13px;
    margin: 0 0 10px;
}

.cm-ai-course-form {
    max-width: 100%;
}

.cm-ai-course-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.cm-ai-course-sub {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.cm-ai-course-form label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    color: #334155;
    margin-bottom: 8px;
}

.cm-ai-course-form input,
.cm-ai-course-form select,
.cm-ai-course-form textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    color: #0f172a;
}

.cm-ai-course-form textarea {
    resize: vertical;
    min-height: 54px;
}

.cm-ai-course-form input:focus,
.cm-ai-course-form select:focus,
.cm-ai-course-form textarea:focus {
    outline: 2px solid rgba(14, 165, 233, 0.35);
    border-color: #38bdf8;
}

.cm-ai-course-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cm-ai-course-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

@media (max-width: 575px) {
    .cm-ai-chat-fab {
        left: auto !important;
        right: 12px !important;
        bottom: 16px !important;
        width: 52px !important;
        height: 52px !important;
    }

    .cm-ai-chat-panel,
    .cm-ai-chat-email {
        left: 10px;
        right: 10px;
        bottom: 78px;
        width: auto;
    }

    .cm-ai-course-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
}
