/* ============================================================
   Chat IA Cursos (nativo BCM) — Estilos con prefijo mcbcm
   ============================================================ */

/* --- Variables CSS --- */
:root {
    --mcbcm-primary: #2563eb;
    --mcbcm-hover: #1d4ed8;
    --mcbcm-bg: #ffffff;
    --mcbcm-bg-messages: #f8fafc;
    --mcbcm-bot-bubble: #f1f5f9;
    --mcbcm-user-bubble: var(--mcbcm-primary);
    --mcbcm-text: #1e293b;
    --mcbcm-text-light: #64748b;
    --mcbcm-border: #e2e8f0;
    --mcbcm-radius: 12px;
    --mcbcm-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --mcbcm-z-button: 9998;
    --mcbcm-z-modal: 9999;
    --mcbcm-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* --- Botón flotante --- */
.mcbcm-float-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, var(--mcbcm-primary), var(--mcbcm-hover));
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
    cursor: pointer;
    z-index: var(--mcbcm-z-button);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    animation: mcbcm-pulse 2.5s infinite;
    outline: none;
}

.mcbcm-float-button:hover,
.mcbcm-float-button:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}

.mcbcm-float-button svg {
    pointer-events: none;
    flex-shrink: 0;
}

/* Etiqueta de texto en hover */
.mcbcm-button-label {
    position: absolute;
    right: 72px;
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #ffffff;
    padding: 7px 13px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease, right 0.25s ease;
    font-family: var(--mcbcm-font);
    pointer-events: none;
}

.mcbcm-button-label::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -5px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid #1e293b;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

.mcbcm-float-button:hover .mcbcm-button-label,
.mcbcm-float-button:focus .mcbcm-button-label {
    opacity: 1;
    visibility: visible;
    right: 76px;
}

/* Estado: botón oculto al hacer scroll */
.mcbcm-float-button.mcbcm-hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

/* --- Modal overlay --- */
.mcbcm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--mcbcm-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: mcbcm-fade-in 0.25s ease;
}

.mcbcm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* --- Contenido del modal --- */
.mcbcm-modal-content {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 680px;
    height: 82vh;
    max-height: 680px;
    background: var(--mcbcm-bg);
    border-radius: var(--mcbcm-radius);
    box-shadow: var(--mcbcm-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mcbcm-slide-up 0.3s ease;
    font-family: var(--mcbcm-font);
}

/* --- Cabecera --- */
.mcbcm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: #ffffff;
    flex-shrink: 0;
}

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

.mcbcm-status-dot {
    width: 10px;
    height: 10px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
    animation: mcbcm-blink 2s infinite;
    flex-shrink: 0;
}

.mcbcm-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
}

.mcbcm-subtitle {
    margin: 0;
    font-size: 12px;
    opacity: 0.85;
    line-height: 1.2;
}

.mcbcm-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ffffff;
    transition: background 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.mcbcm-close-btn:hover,
.mcbcm-close-btn:focus {
    background: rgba(255, 255, 255, 0.35);
    outline: none;
}

/* --- Área de mensajes --- */
.mcbcm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--mcbcm-bg-messages);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.mcbcm-messages::-webkit-scrollbar {
    width: 5px;
}

.mcbcm-messages::-webkit-scrollbar-track {
    background: transparent;
}

.mcbcm-messages::-webkit-scrollbar-thumb {
    background: var(--mcbcm-border);
    border-radius: 10px;
}

/* --- Burbujas de mensajes --- */
.mcbcm-message {
    display: flex;
    max-width: 85%;
}

.mcbcm-message--bot {
    align-self: flex-start;
}

.mcbcm-message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.mcbcm-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--mcbcm-text);
    word-break: break-word;
}

.mcbcm-message--bot .mcbcm-message-bubble {
    background: var(--mcbcm-bot-bubble);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.mcbcm-message--user .mcbcm-message-bubble {
    background: var(--mcbcm-user-bubble);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Estilos para el Markdown renderizado en burbujas de bot */
.mcbcm-message--bot .mcbcm-message-bubble p {
    margin: 0 0 8px 0;
}

.mcbcm-message--bot .mcbcm-message-bubble p:last-child {
    margin-bottom: 0;
}

.mcbcm-message--bot .mcbcm-message-bubble strong {
    font-weight: 700;
    color: #0f172a;
}

.mcbcm-message--bot .mcbcm-message-bubble a {
    color: var(--mcbcm-primary);
    text-decoration: underline;
    word-break: break-all;
}

.mcbcm-message--bot .mcbcm-message-bubble a:hover {
    color: var(--mcbcm-hover);
}

.mcbcm-message--bot .mcbcm-message-bubble ul,
.mcbcm-message--bot .mcbcm-message-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.mcbcm-message--bot .mcbcm-message-bubble li {
    margin-bottom: 4px;
}

.mcbcm-message--bot .mcbcm-message-bubble h1,
.mcbcm-message--bot .mcbcm-message-bubble h2,
.mcbcm-message--bot .mcbcm-message-bubble h3 {
    margin: 10px 0 6px 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.mcbcm-message--bot .mcbcm-message-bubble code {
    background: #e2e8f0;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: monospace;
}

.mcbcm-message--bot .mcbcm-message-bubble hr {
    border: none;
    border-top: 1px solid var(--mcbcm-border);
    margin: 10px 0;
}

/* --- Indicador de escritura --- */
.mcbcm-typing {
    padding: 0 16px 10px;
    background: var(--mcbcm-bg-messages);
}

.mcbcm-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--mcbcm-bot-bubble);
    padding: 10px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.mcbcm-typing-bubble span {
    display: block;
    width: 7px;
    height: 7px;
    background: var(--mcbcm-text-light);
    border-radius: 50%;
    animation: mcbcm-bounce 1.2s infinite;
}

.mcbcm-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.mcbcm-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

/* --- Área de input --- */
.mcbcm-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--mcbcm-bg);
    border-top: 1px solid var(--mcbcm-border);
    flex-shrink: 0;
}

.mcbcm-input {
    flex: 1;
    border: 1.5px solid var(--mcbcm-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--mcbcm-font);
    color: var(--mcbcm-text);
    background: var(--mcbcm-bg-messages);
    resize: none;
    outline: none;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s ease;
}

.mcbcm-input:focus {
    border-color: var(--mcbcm-primary);
}

.mcbcm-input::placeholder {
    color: var(--mcbcm-text-light);
}

.mcbcm-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.mcbcm-send-btn:hover {
    transform: scale(1.08);
}

.mcbcm-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* --- Animaciones --- */
@keyframes mcbcm-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3); }
    50% { box-shadow: 0 4px 32px rgba(37, 99, 235, 0.55); }
}

@keyframes mcbcm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mcbcm-slide-up {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mcbcm-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

@keyframes mcbcm-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .mcbcm-float-button {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 18px;
    }

    .mcbcm-button-label {
        display: none;
    }

    .mcbcm-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .mcbcm-modal {
        align-items: flex-end;
    }

    .mcbcm-message {
        max-width: 92%;
    }
}
