/* ITmedios Chatbot — estilos del widget flotante
   Paleta institucional: navy + verde ITmedios (itmedios.com = logo verde) */

#itm-chatbot-root {
    --itm-navy: #080B14;
    --itm-navy-2: #0D1220;
    --itm-navy-3: #141B2E;
    --itm-navy-4: #1C2540;
    --itm-green: #82FF1F;
    --itm-crimson: #FB2056;
    --itm-text: #F4F6FB;
    --itm-text-secondary: #8B93A7;
    --itm-text-label: #4C5468;

    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

#itm-chatbot-root * {
    box-sizing: border-box;
}

/* ---------- Botón flotante ---------- */
#itm-chatbot-toggle {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--itm-navy-4), var(--itm-navy-2));
    color: var(--itm-green);
    box-shadow:
        0 0 0 1px rgba(130, 255, 31, 0.25),
        0 8px 24px rgba(0, 0, 0, 0.45),
        0 0 32px rgba(130, 255, 31, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#itm-chatbot-toggle:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 0 0 1px rgba(130, 255, 31, 0.4),
        0 10px 28px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(130, 255, 31, 0.22);
}

#itm-chatbot-toggle svg {
    width: 24px;
    height: 24px;
}

.itm-chatbot-toggle-close {
    display: none;
}

#itm-chatbot-root.itm-chatbot-open .itm-chatbot-toggle-icon {
    display: none;
}
#itm-chatbot-root.itm-chatbot-open .itm-chatbot-toggle-close {
    display: flex;
}

.itm-chatbot-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--itm-green);
    box-shadow: 0 0 0 2px var(--itm-navy);
    animation: itm-pulse 2s ease-in-out infinite;
}

@keyframes itm-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(1.15); }
}

/* ---------- Ventana de chat ---------- */
#itm-chatbot-window {
    position: absolute;
    left: 0;
    bottom: 72px;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--itm-navy);
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 24px 24px;
    border: 1px solid rgba(130, 255, 31, 0.18);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 60px rgba(130, 255, 31, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.itm-chatbot-hidden {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
    pointer-events: none;
}

/* ---------- Header ---------- */
.itm-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, var(--itm-navy-3), var(--itm-navy-2));
    flex-shrink: 0;
}

.itm-chatbot-logo {
    height: 26px;
    width: auto;
}

.itm-chatbot-status-dot {
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--itm-green);
    box-shadow: 0 0 8px rgba(130, 255, 31, 0.7);
    animation: itm-pulse 2s ease-in-out infinite;
}

/* ---------- Mensajes ---------- */
.itm-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.itm-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}
.itm-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--itm-navy-4);
    border-radius: 4px;
}

.itm-msg {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.itm-msg-bot {
    align-self: flex-start;
    background: var(--itm-navy-3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--itm-text);
    border-bottom-left-radius: 4px;
}

.itm-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--itm-green), #6BDB12);
    color: var(--itm-navy);
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

.itm-msg-error {
    align-self: flex-start;
    background: rgba(251, 32, 86, 0.12);
    border: 1px solid rgba(251, 32, 86, 0.3);
    color: var(--itm-text);
}

/* ---------- Typing indicator ---------- */
.itm-chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 0 16px 8px;
    align-items: center;
}
.itm-chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--itm-text-secondary);
    animation: itm-typing 1.2s infinite ease-in-out;
}
.itm-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.itm-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes itm-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Form ---------- */
.itm-chatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--itm-navy-2);
    flex-shrink: 0;
}

#itm-chatbot-input {
    flex: 1;
    resize: none;
    max-height: 90px;
    background: var(--itm-navy-3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    color: var(--itm-text);
    outline: none;
    transition: border-color 0.15s ease;
}

#itm-chatbot-input:focus {
    border-color: rgba(130, 255, 31, 0.45);
}

#itm-chatbot-input::placeholder {
    color: var(--itm-text-label);
}

#itm-chatbot-send {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--itm-green), #6BDB12);
    color: var(--itm-navy);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

#itm-chatbot-send:hover {
    transform: scale(1.06);
}

#itm-chatbot-send:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

#itm-chatbot-send svg {
    width: 16px;
    height: 16px;
}

.itm-chatbot-send-icon-bg {
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    border-top: 6px solid transparent !important;
    border-bottom: 6px solid transparent !important;
    border-left: 10px solid #0A0A0A !important;
    border-right: none !important;
    background: none !important;
    margin-left: 2px;
    pointer-events: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    #itm-chatbot-root {
        left: 12px;
        bottom: 12px;
    }
    #itm-chatbot-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        bottom: 68px;
    }
}
