/* ===== GEOCENSO AGENTE CHAT (asistente GeoCenso) ===== */
.geocenso-agente-modal {
    position: fixed;
    bottom: 20px;
    right: 24px;
    z-index: 1004; /* Debajo de todos los modales del sistema (min 1005) */
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: geocensoSlideUp 0.3s ease;
    font-family: 'Outfit', 'Inter', 'Segoe UI', sans-serif;
}
.geocenso-agente-modal.open { display: flex; }

@keyframes geocensoSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.geocenso-agente-header {
    background: #4F46E5;
    color: #fff;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.geocenso-agente-header .b-avatar {
    width: 104px;
    height: 104px;
    background: #4F46E5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.geocenso-agente-header .b-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.geocenso-agente-header .b-info { flex: 1; }
.geocenso-agente-header .b-info .b-name { font-weight: 600; font-size: 14px; }
.geocenso-agente-header .b-info .b-status { font-size: 11px; color: #86efac; }
.geocenso-agente-header .b-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.geocenso-agente-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8f9fb;
    min-height: 200px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.geocenso-agente-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.geocenso-agente-msg.bot {
    background: #fff;
    border: 1px solid #e8e8e8;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: #333;
}
.geocenso-agente-msg.user {
    background: #4F46E5;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.geocenso-agente-msg.typing {
    background: #fff;
    border: 1px solid #e8e8e8;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: #999;
    font-style: italic;
    font-size: 13px;
}

.geocenso-agente-footer {
    padding: 10px 14px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    gap: 8px;
    align-items: center;
    background: #fff;
}
.geocenso-agente-footer input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 13px;
    outline: none;
}
.geocenso-agente-footer input:focus { border-color: #4F46E5; }
.geocenso-agente-footer button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #4F46E5;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.geocenso-agente-footer button:hover { background: #4338ca; }
.geocenso-agente-footer button:disabled { background: #ccc; cursor: not-allowed; }

/* Boton de voz (mic) */
.geocenso-agente-footer .geocenso-agente-mic { background: #6c757d; }
.geocenso-agente-footer .geocenso-agente-mic:hover { background: #5a6268; }
.geocenso-agente-footer .geocenso-agente-mic.recording {
    background: #dc3545;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.25);
    animation: geocensoPulse 1.2s infinite;
}
@keyframes geocensoPulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Tablas en respuestas */
.geocenso-agente-table {
    border-collapse: collapse;
    margin: 4px 0;
    font-size: 12px;
    width: 100%;
}
.geocenso-agente-table td {
    border: 1px solid #e3e6ef;
    padding: 4px 6px;
    text-align: left;
}
.geocenso-agente-msg.bot details {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}
.geocenso-agente-msg.bot details summary {
    cursor: pointer;
    color: #4F46E5;
}
.geocenso-agente-msg.bot code {
    display: block;
    background: #f1f3f9;
    border-radius: 6px;
    padding: 8px;
    font-size: 11px;
    color: #1a1a2e;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ===== ARRASTRE: mover a Gio a voluntad ===== */
#chatbot-canvas-container {
    touch-action: none;   /* permite arrastrar en táctil sin scroll */
    cursor: grab;
    -webkit-user-drag: none;
}
#chatbot-canvas-container:active {
    cursor: grabbing;
}
#chatbot-agent-container.gio-arrastrando {
    transition: none;
}

/* ===== MODO DIFUMINADO (páginas de modelado/edición) =====
   Gio queda de fondo: difuminado, sin globos ni chat, hasta que
   se finalice la tarea de edición. El robot sigue siendo arrastrable. */
body.gio-dimmed #chatbot-agent-container {
    pointer-events: none !important;
}
body.gio-dimmed #chatbot-agent-container * {
    pointer-events: none !important;
}
body.gio-dimmed #chatbot-canvas-container {
    pointer-events: auto !important;  /* solo el robot: arrastrable */
    filter: blur(4px) grayscale(0.45);
    opacity: 0.55;
    cursor: grab;
    transform-origin: bottom right;
    transform: scale(0.92);
    transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}
body.gio-dimmed #chatbot-canvas-container:active {
    cursor: grabbing;
}
body.gio-dimmed .chatbot-bubble {
    display: none;
}

.geocenso-agente-dimmed-tag {
    position: relative;
    margin-top: 6px;
    z-index: 1004; /* Debajo de todos los modales del sistema (min 1005) */
    padding: 5px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(79, 70, 229, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
    color: #4F46E5;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    font-family: 'Outfit', 'Inter', 'Segoe UI', sans-serif;
    pointer-events: none;
    user-select: none;
    max-width: 220px;
    text-align: center;
}

@media (max-width: 600px) {
    .geocenso-agente-dimmed-tag {
        max-width: 170px;
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    #chatbot-agent-container {
        bottom: 100px !important;
    }
    .geocenso-agente-modal {
        bottom: 110px !important;
    }
}

@media (max-width: 600px) {
    .geocenso-agente-modal {
        right: 12px;
        left: 12px;
        width: auto;
        max-height: 70vh;
    }
}
