/* =====================================================================
   CMH · PÁGINAS PÚBLICAS
   Carga de documentos, franja de contacto y asistente virtual.
   Usa las variables definidas en cmh-theme.css.
   ===================================================================== */

/* ---------- Carga de documentos ---------- */
.cmh-aviso-carga {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--cmh-info-fondo); color: var(--cmh-info-texto);
    border: 1px solid #bcd2f7; border-radius: var(--cmh-radio);
    padding: 12px 16px; margin-bottom: 20px; font-size: .92rem; line-height: 1.5;
}
.cmh-aviso-carga i { font-size: 1.2rem; margin-top: 1px; }

.cmh-archivos-titulo {
    font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--cmh-suave); margin: 0 0 8px;
}
.cmh-archivos { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.cmh-archivos:empty { margin: 0; }

.cmh-archivo,
.cmh-subiendo {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--cmh-verde-50); border: 1px solid #cfe8d4;
    border-radius: var(--cmh-radio); padding: 10px 12px;
}
.cmh-archivo-nuevo { animation: cmh-aparecer .35s ease-out; }
.cmh-archivo-icono,
.cmh-subiendo-vista {
    width: 44px; height: 44px; flex: 0 0 44px; border-radius: 10px; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; border: 1px solid #cfe8d4; color: var(--cmh-verde-700); font-size: 1.35rem;
}
.cmh-subiendo-vista img { width: 100%; height: 100%; object-fit: cover; }
.cmh-archivo-datos { flex: 1 1 160px; min-width: 0; display: flex; flex-direction: column; }
.cmh-archivo-nombre { font-weight: 600; color: var(--cmh-tinta); font-size: .92rem; overflow-wrap: anywhere; }
.cmh-archivo-meta { font-size: .8rem; color: var(--cmh-suave); }

.cmh-subiendo { background: #fff; border-style: dashed; border-color: var(--cmh-verde-500); margin-bottom: 14px; }
.cmh-subiendo .cmh-medidor { margin: 6px 0 0; }
.cmh-subiendo .cmh-medidor > span { transition: width .2s linear; }
.cmh-subiendo-porcentaje { font-weight: 700; color: var(--cmh-verde-800); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

.cmh-carga-acciones { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cmh-carga-ayuda { font-size: .82rem; color: var(--cmh-suave); }
.cmh-carga-acciones .input-documento:focus-visible + .cmh-carga-ayuda,
.cmh-carga-acciones .btn-seleccionar:focus-within { outline: 3px solid var(--cmh-dorado-500); outline-offset: 2px; }
.cmh-otra-parte { margin: 12px 0 0; font-size: .86rem; color: var(--cmh-verde-800); font-weight: 500; }

@keyframes cmh-aparecer {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Franja de contacto ---------- */
.cmh-contacto {
    background: #fff; border-top: 1px solid var(--cmh-borde); border-bottom: 1px solid var(--cmh-borde);
    padding: 18px 0;
}
.cmh-contacto-interior { display: flex; align-items: center; gap: 18px 28px; flex-wrap: wrap; }
.cmh-contacto-titulo { display: flex; align-items: center; gap: 12px; flex: 1 1 240px; }
.cmh-contacto-titulo > i {
    width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; font-size: 1.25rem;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--cmh-verde-100); color: var(--cmh-verde-700);
}
.cmh-contacto-titulo strong { display: block; color: var(--cmh-tinta); }
.cmh-contacto-titulo span { font-size: .86rem; color: var(--cmh-suave); }
.cmh-contacto-medios { display: flex; gap: 8px; flex-wrap: wrap; }
.cmh-contacto-medio {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--cmh-borde); border-radius: 999px; padding: 8px 14px;
    background: var(--cmh-verde-50); color: var(--cmh-tinta); font-weight: 600; font-size: .9rem;
    text-decoration: none; transition: background var(--cmh-transicion), border-color var(--cmh-transicion);
}
.cmh-contacto-medio i { color: var(--cmh-verde-700); }
a.cmh-contacto-medio:hover { background: var(--cmh-verde-100); border-color: #c4e6ca; color: var(--cmh-tinta); }

/* =====================================================================
   ASISTENTE VIRTUAL (robot)
   ===================================================================== */
.cmh-bot { position: fixed; right: 20px; bottom: 20px; z-index: 1050; font-family: var(--cmh-fuente); }

.cmh-bot-boton {
    width: 76px; height: 76px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    background: radial-gradient(circle at 30% 25%, #fff 0%, var(--cmh-verde-50) 60%, var(--cmh-verde-100) 100%);
    box-shadow: 0 10px 26px rgba(28, 90, 42, .28), 0 0 0 3px #fff, 0 0 0 5px var(--cmh-lima-500);
    display: flex; align-items: center; justify-content: center;
    animation: cmh-bot-flotar 3.2s ease-in-out infinite;
    transition: transform .2s ease;
}
.cmh-bot-boton:hover { transform: scale(1.06); }
.cmh-bot-boton:focus-visible { outline: 3px solid var(--cmh-dorado-500); outline-offset: 6px; }
.cmh-bot-boton svg { width: 56px; height: 56px; overflow: visible; }

/* Piezas del robot */
.cmh-robot-ojo { transform-origin: center; transform-box: fill-box; animation: cmh-bot-parpadeo 4.5s infinite; }
.cmh-robot-antena { transform-origin: 50% 100%; transform-box: fill-box; animation: cmh-bot-antena 2.4s ease-in-out infinite; }
.cmh-robot-luz { animation: cmh-bot-luz 1.6s ease-in-out infinite; }
.cmh-robot-brazo { transform-origin: 15% 20%; transform-box: fill-box; }
.cmh-bot-boton:hover .cmh-robot-brazo,
.cmh-bot.saludando .cmh-robot-brazo { animation: cmh-bot-saludo .7s ease-in-out 3; }
.cmh-robot-boca { transition: d .2s ease; }

@keyframes cmh-bot-flotar   { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes cmh-bot-parpadeo { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes cmh-bot-antena   { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes cmh-bot-luz      { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes cmh-bot-saludo   { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-38deg); } }

/* Globo de saludo */
.cmh-bot-globo {
    position: absolute; right: 88px; bottom: 16px; width: max-content; max-width: 230px;
    background: #fff; color: var(--cmh-tinta); border: 1px solid var(--cmh-borde);
    border-radius: 16px 16px 4px 16px; padding: 10px 34px 10px 14px; font-size: .88rem; line-height: 1.4;
    box-shadow: var(--cmh-sombra); animation: cmh-aparecer .4s ease-out;
}
.cmh-bot-globo button {
    position: absolute; top: 4px; right: 6px; border: 0; background: none; color: var(--cmh-suave);
    font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 4px;
}

/* Panel de conversación */
.cmh-bot-panel {
    position: absolute; right: 0; bottom: 92px; width: 370px; max-width: calc(100vw - 24px);
    height: 540px; max-height: calc(100vh - 130px);
    background: #fff; border: 1px solid var(--cmh-borde); border-radius: 20px; overflow: hidden;
    box-shadow: 0 22px 54px rgba(28, 90, 42, .24);
    display: flex; flex-direction: column;
    transform-origin: bottom right; animation: cmh-bot-abrir .25s ease-out;
}
.cmh-bot-panel[hidden], .cmh-bot-globo[hidden] { display: none; }
@keyframes cmh-bot-abrir { from { opacity: 0; transform: scale(.85) translateY(14px); } to { opacity: 1; transform: none; } }

.cmh-bot-cabecera {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    background: linear-gradient(120deg, var(--cmh-verde-100) 0%, var(--cmh-lima-100) 70%, var(--cmh-dorado-100) 100%);
    border-bottom: 1px solid #cfe8d4;
}
.cmh-bot-cabecera svg { width: 42px; height: 42px; flex: 0 0 42px; overflow: visible; }
.cmh-bot-cabecera strong { display: block; color: var(--cmh-verde-900); font-size: 1rem; }
.cmh-bot-cabecera span { font-size: .78rem; color: var(--cmh-texto); display: flex; align-items: center; gap: 6px; }
.cmh-bot-cabecera span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cmh-verde-600); }
.cmh-bot-cerrar {
    margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
    background: rgba(255, 255, 255, .7); color: var(--cmh-verde-900); font-size: 1.2rem; line-height: 1;
}
.cmh-bot-cerrar:hover { background: #fff; }

.cmh-bot-mensajes { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--cmh-fondo); }
.cmh-bot-msj {
    max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: .9rem; line-height: 1.45;
    animation: cmh-aparecer .25s ease-out; overflow-wrap: anywhere;
}
.cmh-bot-msj.bot { align-self: flex-start; background: #fff; border: 1px solid var(--cmh-borde); color: var(--cmh-texto); border-bottom-left-radius: 4px; }
.cmh-bot-msj.yo  { align-self: flex-end; background: var(--cmh-verde-700); color: #fff; border-bottom-right-radius: 4px; }
.cmh-bot-msj strong { color: var(--cmh-tinta); }
.cmh-bot-msj ol, .cmh-bot-msj ul { margin: 6px 0 0; padding-left: 18px; }
.cmh-bot-msj li { margin-bottom: 4px; }
.cmh-bot-msj a { color: var(--cmh-verde-700); font-weight: 600; }

.cmh-bot-escribiendo { display: inline-flex; gap: 4px; padding: 14px 13px; }
.cmh-bot-escribiendo i { width: 7px; height: 7px; border-radius: 50%; background: var(--cmh-verde-500); animation: cmh-bot-punto 1s infinite; }
.cmh-bot-escribiendo i:nth-child(2) { animation-delay: .15s; }
.cmh-bot-escribiendo i:nth-child(3) { animation-delay: .3s; }
@keyframes cmh-bot-punto { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.cmh-bot-opciones { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; }
.cmh-bot-opcion {
    border: 1px solid #c4e6ca; background: #fff; color: var(--cmh-verde-800);
    border-radius: 999px; padding: 6px 12px; font-size: .82rem; font-weight: 600; cursor: pointer;
    transition: background var(--cmh-transicion), transform var(--cmh-transicion);
}
.cmh-bot-opcion:hover { background: var(--cmh-verde-100); transform: translateY(-1px); }
.cmh-bot-opcion:focus-visible { outline: 3px solid var(--cmh-dorado-500); outline-offset: 2px; }

.cmh-bot-entrada { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--cmh-borde); background: #fff; }
.cmh-bot-entrada input {
    flex: 1 1 auto; min-width: 0; border: 1px solid #c9d1cd; border-radius: 999px; padding: 9px 14px; font-size: .9rem;
    font-family: inherit; color: var(--cmh-tinta);
}
.cmh-bot-entrada input:focus { outline: none; border-color: var(--cmh-verde-600); box-shadow: var(--cmh-foco); }
.cmh-bot-entrada button {
    width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--cmh-verde-700); color: #fff; font-size: 1rem;
}
.cmh-bot-entrada button:hover { background: var(--cmh-verde-800); }

@media (max-width: 575.98px) {
    .cmh-bot { right: 12px; bottom: 12px; }
    .cmh-bot-boton { width: 64px; height: 64px; }
    .cmh-bot-boton svg { width: 46px; height: 46px; }
    .cmh-bot-panel { bottom: 78px; height: calc(100vh - 110px); }
    .cmh-bot-globo { right: 74px; max-width: 190px; }
    .cmh-contacto-interior { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    .cmh-bot *, .cmh-bot-boton, .cmh-archivo-nuevo { animation: none !important; transition: none !important; }
}

.cmh-subiendo-botones { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.cmh-pendiente-aviso { color: var(--cmh-aviso-texto); font-weight: 600; }
