/* Asistente público de clientes — estilo tipo widget de chat (ver CLAUDE.md, ref. TeamSystem/Atenea) */

:root {
    --asist-azul: #0b4f9e;
    --asist-azul-claro: #eaf2fc;
    --asist-borde: #e2e6ea;
    --asist-texto: #1f2937;
    --asist-gris: #6b7280;
    --asist-fondo: #f4f6f8;
    --asist-blanco: #ffffff;
    --asist-error: #b3261e;
    --asist-error-bg: #fdecea;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--asist-fondo);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--asist-texto);
}

.asist-wrap {
    max-width: 480px;
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    background: var(--asist-blanco);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Móvil pequeño: ocupa toda la pantalla, sin márgenes ni esquinas */
@media (max-width: 420px) {
    .asist-wrap {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        box-shadow: none;
    }
}

/* Tablet: un poco más ancho */
@media (min-width: 700px) {
    .asist-wrap { max-width: 640px; }
}

/* Escritorio: más ancho todavía, para no dejar tanto espacio vacío a los lados */
@media (min-width: 1000px) {
    .asist-wrap {
        max-width: 960px;
        margin: 40px auto;
        min-height: 85vh;
    }
}

.asist-header {
    background: var(--asist-azul);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.asist-header .asist-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.asist-header .asist-titulo {
    font-weight: 600;
    font-size: 15px;
}

.asist-header .asist-subtitulo {
    font-size: 12.5px;
    opacity: .85;
}

.asist-header .asist-ia-aviso {
    font-size: 11px;
    opacity: .8;
    margin-top: 3px;
}

.asist-aviso {
    font-size: 11.5px;
    color: var(--asist-gris);
    text-align: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--asist-borde);
}

.asist-mensajes {
    flex: 1;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.asist-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.45;
    white-space: pre-line;
}

.asist-msg.bot {
    align-self: flex-start;
    background: var(--asist-azul-claro);
    color: var(--asist-texto);
    border-bottom-left-radius: 4px;
}

.asist-msg.usuario {
    align-self: flex-end;
    background: var(--asist-azul);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.asist-msg.error {
    align-self: flex-start;
    background: var(--asist-error-bg);
    color: var(--asist-error);
    border-bottom-left-radius: 4px;
}

.asist-hora {
    text-align: center;
    font-size: 11px;
    color: var(--asist-gris);
    margin: 4px 0;
}

.asist-panel {
    border-top: 1px solid var(--asist-borde);
    padding: 14px 16px 18px;
    background: var(--asist-blanco);
}

.asist-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}

/* Mismos puntos de corte que .asist-wrap más abajo — columnas fijas en vez
   de auto-fit: con minmax() el navegador mete tantas columnas estrechas como
   quepan (llegó a colar 5 en vez de las 4 de siempre), en lugar de mantener
   el número de columnas que ya se veía bien en cada tamaño. */
@media (min-width: 700px) {
    .asist-chips { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1000px) {
    .asist-chips { grid-template-columns: repeat(4, 1fr); }
}

.asist-chips form {
    margin: 0;
}

.asist-chip {
    width: 100%;
    box-sizing: border-box;
    /* Altura fija en vez de "la que pida el texto": con más botones en el
       menú, algunos rótulos ocupan dos líneas y otros una — sin esto, solo
       la fila que contiene el botón largo crecía en el grid, y el resto de
       filas quedaba más baja. min-height + flex centrado da a todos los
       botones la misma altura (la del texto de dos líneas más largo),
       midan lo que midan las demás filas del grid. */
    min-height: 54px;
    display: flex;
    align-items: center;
    border: 1px solid var(--asist-azul);
    color: var(--asist-azul);
    background: #fff;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

.asist-chip:hover { background: var(--asist-azul-claro); }

.asist-campo {
    margin-bottom: 12px;
}

.asist-campo label {
    display: block;
    font-size: 13px;
    color: var(--asist-gris);
    margin-bottom: 4px;
}

.asist-campo input[type="text"],
.asist-campo input[type="number"],
.asist-campo input[type="date"],
.asist-campo input[type="tel"],
.asist-campo textarea,
.asist-campo select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--asist-borde);
    border-radius: 10px;
    font-size: 14.5px;
    font-family: inherit;
}

.asist-campo textarea { min-height: 70px; resize: vertical; }

.asist-fila-input {
    display: flex;
    gap: 8px;
}

.asist-fila-input input[type="text"],
.asist-fila-input input[type="email"] { flex: 1; min-width: 0; }

.asist-btn {
    background: var(--asist-azul);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14.5px;
    cursor: pointer;
}

.asist-btn:hover { opacity: .92; }

.asist-btn.secundario {
    background: #fff;
    color: var(--asist-azul);
    border: 1px solid var(--asist-azul);
}

.asist-btn.ancho { width: 100%; }

.asist-btn-whatsapp {
    background: #25D366;
    color: #fff;
}
.asist-btn-whatsapp:hover { opacity: .92; }

/* Fila de acciones (descargar / volver) por ENCIMA de una tabla larga —
   así no obligan a bajar del todo la barra de desplazamiento de la tabla
   para llegar a ellas. Los dos botones se reparten el ancho a partes
   iguales en una sola línea, en vez de apilarse uno debajo del otro. */
.asist-acciones-fila {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.asist-acciones-fila .asist-btn {
    flex: 1;
    min-width: 0;
}

.asist-ayuda {
    font-size: 12px;
    color: var(--asist-gris);
    margin-top: 6px;
}

.asist-ayuda.aviso { color: var(--asist-error); }

.asist-faq-item {
    border: 1px solid var(--asist-borde);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.asist-faq-item .asist-faq-p { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.asist-faq-item .asist-faq-r { font-size: 13.5px; color: var(--asist-texto); }

.asist-resumen-347 {
    background: var(--asist-azul-claro);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}
.asist-resumen-347 .asist-347-total { font-size: 20px; font-weight: 700; color: var(--asist-azul); }

.asist-modelo-card {
    display: flex;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--asist-borde);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}

.asist-modelo-foto {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--asist-fondo);
    flex-shrink: 0;
    cursor: zoom-in;
}

.asist-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    cursor: zoom-out;
}

.asist-lightbox[hidden] { display: none; }

.asist-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.asist-modelo-nombre { font-weight: 600; font-size: 14.5px; }
.asist-modelo-tarifa { color: var(--asist-azul); font-size: 13.5px; margin-top: 2px; }

.asist-recogida {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff3e0;
    border: 1.5px solid #ff9800;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #7a3e00;
}
.asist-recogida input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.asist-referencia {
    background: var(--asist-azul-claro);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    margin-top: 4px;
}

.asist-tabla-wrap {
    width: 100%;
    max-height: 480px;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--asist-borde);
    border-radius: 10px;
    margin-bottom: 12px;
}

.asist-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.asist-tabla th,
.asist-tabla td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--asist-borde);
    white-space: nowrap;
}

/* Descripción (modelo) es el dato más importante — se deja envolver en 2-3 líneas
   en vez de truncarla, y va primera para que se vea sin hacer scroll horizontal. */
.asist-tabla td.asist-col-desc {
    white-space: normal;
    max-width: 260px;
    min-width: 160px;
}

/* Su número puede ser largo — se envuelve en vez de ensanchar la tabla */
.asist-tabla td.asist-col-wrap {
    white-space: normal;
    max-width: 140px;
}

.asist-tabla th {
    background: var(--asist-fondo);
    color: var(--asist-gris);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.asist-tabla th.asist-th-sortable {
    cursor: pointer;
    user-select: none;
}
.asist-tabla th.asist-th-sortable:hover { color: var(--asist-azul); }
.asist-tabla th.asist-th-asc::after  { content: " \25B2"; font-size: 9px; }
.asist-tabla th.asist-th-desc::after { content: " \25BC"; font-size: 9px; }

.asist-tabla tr:last-child td { border-bottom: none; }

.asist-estado {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

.asist-estado.pendiente       { background: #fff3cd; color: #7a5b00; }
.asist-estado.en_ultima_carga { background: #d7f3e3; color: #0f6b3d; }
.asist-estado.entregado       { background: #e2e6ea; color: #374151; }

/* Próxima carga: se destaca a propósito frente al resto (más saturado, negrita) */
.asist-estado.proxima_carga {
    background: #ff9800;
    color: #ffffff;
    font-weight: 700;
    padding: 4px 10px;
    box-shadow: 0 0 0 1px #e07600 inset;
}
