/* ============================================================
   ASISTENTE CONEXIÓN LOCAL - Estilos aislados (Etapa 2)
   Prefijo: .asist-* para no chocar con el CSS existente
   Colores reutilizados: #14213D (primary), #FCA311 (action)
   ============================================================ */

.asist-root,
#asistRoot {
    --asist-primary: #14213D;
    --asist-action: #FCA311;
    --asist-bg: #ffffff;
    --asist-text: #1f2937;
    --asist-text-soft: #6b7280;
    --asist-border: #e5e7eb;
    --asist-bubble-asist: #f3f4f6;
    --asist-bubble-user: #14213D;
    --asist-shadow: 0 20px 60px rgba(20, 33, 61, 0.25);
    --asist-radius: 1.25rem;
    font-family: inherit;
}

/* ---------------- BOTÓN FLOTANTE ---------------- */
.asist-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #FCA311 0%, #e5940a 100%);
    color: #14213D;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(252, 163, 17, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9990;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: asist-fab-in 0.4s ease;
}

.asist-fab:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 12px 28px rgba(252, 163, 17, 0.55), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.asist-fab:active {
    transform: translateY(0) scale(0.98);
}

.asist-fab:focus-visible {
    outline: 3px solid #14213D;
    outline-offset: 3px;
}

.asist-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #14213D;
    color: #FCA311;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

@keyframes asist-fab-in {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

/* Cuando el panel está abierto, ocultamos el FAB en móvil */
@media (max-width: 640px) {
    body.asist-open .asist-fab {
        display: none;
    }
}

/* ---------------- OVERLAY (móvil) ---------------- */
.asist-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9994;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.asist-overlay.is-visible {
    opacity: 1;
}

/* ---------------- PANEL ---------------- */
.asist-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--asist-bg);
    border-radius: var(--asist-radius);
    box-shadow: var(--asist-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9995;
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.asist-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ---------------- CABECERA ---------------- */
.asist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #14213D 0%, #26358C 100%);
    color: #ffffff;
    flex-shrink: 0;
}

.asist-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.asist-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #FCA311;
    color: #14213D;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.asist-header-text {
    min-width: 0;
}

.asist-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asist-subtitle {
    margin: 0.15rem 0 0 0;
    font-size: 0.75rem;
    opacity: 0.85;
    line-height: 1.2;
}

.asist-header-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.asist-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

.asist-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.asist-icon-btn:focus-visible {
    outline: 2px solid #FCA311;
    outline-offset: 2px;
}

/* ---------------- CUERPO ---------------- */
.asist-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: #fafbfc;
    scroll-behavior: smooth;
}

.asist-body::-webkit-scrollbar {
    width: 6px;
}

.asist-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ---------------- BURBUJAS ---------------- */
.asist-bubble {
    max-width: 82%;
    padding: 0.65rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.92rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: asist-bubble-in 0.25s ease;
    white-space: pre-wrap;
}

@keyframes asist-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.asist-bubble-asist {
    align-self: flex-start;
    background: var(--asist-bubble-asist);
    color: var(--asist-text);
    border-bottom-left-radius: 0.25rem;
    border-left: 3px solid var(--asist-action);
}

.asist-bubble-user {
    align-self: flex-end;
    background: var(--asist-bubble-user);
    color: #ffffff;
    border-bottom-right-radius: 0.25rem;
}

/* ---------------- INDICADOR "ESCRIBIENDO..." ---------------- */
.asist-typing {
    align-self: flex-start;
    background: var(--asist-bubble-asist);
    padding: 0.7rem 0.95rem;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
}

.asist-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: asist-typing 1.2s infinite ease-in-out;
}

.asist-typing span:nth-child(2) { animation-delay: 0.15s; }
.asist-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes asist-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------------- PIE ---------------- */
.asist-footer {
    padding: 0.75rem 1rem 1rem 1rem;
    border-top: 1px solid var(--asist-border);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.asist-footer:empty {
    display: none;
}

/* ---------------- CHIPS DE OPCIÓN ---------------- */
.asist-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.asist-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.95rem;
    border: 2px solid var(--asist-border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--asist-text);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: left;
}

.asist-chip:hover {
    border-color: var(--asist-action);
    background: rgba(252, 163, 17, 0.08);
    transform: translateY(-1px);
}

.asist-chip:active {
    transform: translateY(0);
}

.asist-chip:focus-visible {
    outline: 2px solid var(--asist-primary);
    outline-offset: 2px;
}

.asist-chip i {
    color: var(--asist-action);
    font-size: 0.85rem;
}

/* ---------------- BOTÓN DE ACCIÓN ---------------- */
.asist-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.65rem;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    width: 100%;
}

.asist-btn-primary {
    background: linear-gradient(135deg, #FCA311 0%, #e5940a 100%);
    color: #14213D;
    box-shadow: 0 3px 10px rgba(252, 163, 17, 0.35);
}

.asist-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(252, 163, 17, 0.45);
}

.asist-btn-primary:focus-visible {
    outline: 2px solid #14213D;
    outline-offset: 2px;
}

/* ---------------- RESPONSIVE MÓVIL ---------------- */
@media (max-width: 640px) {
    .asist-fab {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
        bottom: 16px;
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        right: calc(16px + env(safe-area-inset-right, 0px));
    }

    .asist-fab-badge {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
    }

    .asist-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        transform: translateY(100%);
    }

    .asist-panel.is-open {
        transform: translateY(0);
    }

    .asist-header {
        padding: 1rem;
    }

    .asist-body {
        padding: 0.9rem;
    }

    .asist-bubble {
        max-width: 88%;
        font-size: 0.95rem;
    }
}

/* ---------------- ACCESIBILIDAD ---------------- */
@media (prefers-reduced-motion: reduce) {
    .asist-fab,
    .asist-panel,
    .asist-overlay,
    .asist-bubble,
    .asist-typing span,
    .asist-chip,
    .asist-btn {
        animation: none !important;
        transition: none !important;
    }
}

/* Evitar que el FAB tape el teclado en móvil */
@media (max-width: 640px) {
    body.asist-open .asist-panel {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}



/* ============================================================
   ETAPA 3 - Estilos complementarios
   ============================================================ */

.asist-bubble-error {
    align-self: flex-start;
    background: #fef2f2;
    color: #b91c1c;
    border-left: 3px solid #dc2626;
    border-bottom-left-radius: 0.25rem;
}

.asist-input-wrap { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }

.asist-input,
.asist-textarea {
    width: 100%; padding: 0.7rem 0.85rem;
    border: 2px solid #e5e7eb; border-radius: 0.65rem;
    font-size: 0.95rem; font-family: inherit; color: #1f2937;
    background: #ffffff; box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.asist-input:focus,
.asist-textarea:focus {
    outline: none; border-color: #FCA311;
    box-shadow: 0 0 0 3px rgba(252, 163, 17, 0.15);
}
.asist-textarea { resize: vertical; min-height: 70px; max-height: 160px; }

.asist-contador {
    align-self: flex-end; font-size: 0.75rem;
    color: #9ca3af; font-variant-numeric: tabular-nums;
}
.asist-contador.is-limit { color: #dc2626; font-weight: 600; }

.asist-input-acciones {
    display: flex; gap: 0.5rem;
    justify-content: flex-end; flex-wrap: wrap;
}
.asist-btn-sm { width: auto; padding: 0.5rem 0.9rem; font-size: 0.82rem; }
.asist-btn-secondary { background: #f3f4f6; color: #374151; }
.asist-btn-secondary:hover { background: #e5e7eb; }
.asist-mt { margin-top: 0.75rem; }
.asist-mt-sm { margin-top: 0.5rem; }

.asist-categorias { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.asist-categorias-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem; max-height: 260px; overflow-y: auto; padding: 0.25rem;
}
.asist-categoria-item {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 0.7rem; border: 2px solid #e5e7eb;
    border-radius: 0.6rem; background: #ffffff; color: #1f2937;
    font-size: 0.8rem; font-weight: 500; cursor: pointer;
    text-align: left; transition: all 0.15s ease;
    font-family: inherit; line-height: 1.2;
}
.asist-categoria-item:hover {
    border-color: #FCA311; background: rgba(252, 163, 17, 0.06);
}
.asist-categoria-item:focus-visible { outline: 2px solid #14213D; outline-offset: 2px; }
.asist-categoria-item i { color: #FCA311; font-size: 0.85rem; flex-shrink: 0; }

.asist-upload-wrap { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; }
.asist-upload-zone {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 0.3rem; padding: 1.2rem 0.8rem;
    border: 2px dashed #d1d5db; border-radius: 0.75rem;
    background: #fafbfc; cursor: pointer; text-align: center;
    transition: all 0.2s ease;
}
.asist-upload-zone:hover,
.asist-upload-zone.is-dragover {
    border-color: #FCA311; background: rgba(252, 163, 17, 0.06);
}
.asist-upload-zone i { font-size: 1.5rem; color: #FCA311; }
.asist-upload-text { font-size: 0.88rem; font-weight: 600; color: #374151; }
.asist-upload-hint { font-size: 0.75rem; color: #9ca3af; }
.asist-upload-preview { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.asist-upload-item {
    position: relative; width: 64px; height: 64px;
    border-radius: 0.5rem; overflow: hidden; border: 1px solid #e5e7eb;
}
.asist-upload-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asist-upload-del {
    position: absolute; top: 2px; right: 2px;
    width: 20px; height: 20px; border-radius: 50%; border: none;
    background: rgba(0, 0, 0, 0.65); color: #ffffff; font-size: 0.7rem;
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; padding: 0; line-height: 1;
}
.asist-upload-del:hover { background: #dc2626; }

.asist-multicheck { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.asist-check-item {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.55rem 0.7rem; border: 2px solid #e5e7eb;
    border-radius: 0.6rem; cursor: pointer; font-size: 0.88rem;
    transition: all 0.15s ease; background: #ffffff;
}
.asist-check-item:hover { border-color: #FCA311; }
.asist-check-item input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: #FCA311;
    cursor: pointer; flex-shrink: 0;
}
.asist-check-item:has(input:checked) {
    border-color: #FCA311; background: rgba(252, 163, 17, 0.06);
}

.asist-resumen {
    display: flex; flex-direction: column; gap: 0.6rem;
    width: 100%; max-height: 300px; overflow-y: auto; padding-right: 4px;
}
.asist-resumen-card {
    border: 1px solid #e5e7eb; border-radius: 0.65rem;
    background: #ffffff; padding: 0.65rem 0.8rem;
}
.asist-resumen-head {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 0.4rem;
}
.asist-resumen-head h4 {
    margin: 0; font-size: 0.85rem; font-weight: 700; color: #14213D;
}
.asist-resumen-edit {
    display: inline-flex; align-items: center; gap: 0.25rem;
    border: none; background: transparent; color: #FCA311;
    font-size: 0.75rem; font-weight: 600; cursor: pointer;
    padding: 0.2rem 0.4rem; border-radius: 0.35rem; font-family: inherit;
}
.asist-resumen-edit:hover { background: rgba(252, 163, 17, 0.1); }
.asist-resumen-list {
    display: grid; grid-template-columns: 1fr 1.5fr;
    gap: 0.2rem 0.6rem; margin: 0; font-size: 0.8rem;
}
.asist-resumen-list dt { color: #6b7280; font-weight: 500; }
.asist-resumen-list dd { margin: 0; color: #1f2937; word-break: break-word; }

@media (max-width: 640px) {
    .asist-categorias-grid { grid-template-columns: 1fr; max-height: 220px; }
    .asist-resumen { max-height: 260px; }
}



/* ============================================================
   FIX: Hover de los chips del asistente
   Fondo amarillo + texto azul al pasar el mouse.
   ============================================================ */

#asistPanel button,
#asistPanel .asist-chip,
#asistPanel .asist-btn,
#asistPanel .asist-icon-btn,
#asistPanel .asist-categoria-item,
#asistPanel .asist-resumen-edit,
#asistPanel .asist-upload-del {
    font-family: inherit;
    text-decoration: none;
}

/* Chips: estado normal */
#asistPanel .asist-chip {
    background: #ffffff !important;
    color: #1f2937 !important;
    border: 2px solid #e5e7eb !important;
    transition: all 0.2s ease;
}

#asistPanel .asist-chip i {
    color: #FCA311 !important;
}

/* Chips: hover — fondo amarillo, texto azul */
#asistPanel .asist-chip:hover,
#asistPanel .asist-chip:focus-visible {
    background: #FCA311 !important;
    color: #14213D !important;
    border-color: #FCA311 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(252, 163, 17, 0.35) !important;
}

#asistPanel .asist-chip:hover i,
#asistPanel .asist-chip:focus-visible i {
    color: #14213D !important;
}

/* Chips: clic */
#asistPanel .asist-chip:active {
    background: #e5940a !important;
    color: #14213D !important;
    transform: translateY(0);
}



/* ============================================================
   FIX: Texto de Términos y Condiciones
   Fuerza texto oscuro y enlaces visibles dentro del panel.
   ============================================================ */

/* Texto general del label de términos */
#asistPanel .asist-check-item,
#asistPanel .asist-check-item span {
    color: #1f2937 !important;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Enlaces dentro de términos (Términos, Privacidad, Reglas) */
#asistPanel .asist-check-item a,
#asistPanel .asist-check-item span a {
    color: #14213D !important;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: #FCA311;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

#asistPanel .asist-check-item a:hover,
#asistPanel .asist-check-item span a:hover {
    color: #FCA311 !important;
    text-decoration-color: #14213D;
}

/* El checkbox en sí */
#asistPanel .asist-check-item input[type="checkbox"] {
    accent-color: #FCA311;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Estado "checked" del contenedor: borde amarillo */
#asistPanel .asist-check-item:has(input:checked) {
    background: rgba(252, 163, 17, 0.06) !important;
    border-color: #FCA311 !important;
}

/* Aplicar también a los multicheck (entrega: domicilio, sucursal, etc.) */
#asistPanel .asist-multicheck .asist-check-item span {
    color: #1f2937 !important;
}